Hi @dcrystalj
You can use wpm_is_ml_string() for check if it is multilingual string. Then You can use preg_match for find multilinagual tag for needed language.
Thank you.
I managed to write helper for this:
function wpm_trans_exists($str, $lang) {
if (!wpm_is_ml_string($str)) {
return false;
}
preg_match('/\[:'. $lang .'\]/', $str, $matches, PREG_OFFSET_CAPTURE, 0);
return count($matches) > 0;
}
do you know how can i get current selected language string? like ‘en’ ?
-
This reply was modified 8 years, 3 months ago by
dcrystalj.
Hi @dcrystalj
What language are You need? Current localization language or current edit language?
For get current language, You can use ‘wpm_get_language()’. For get current edit language(only in admin) You can use: $edit_lang = !empty($_GET['edit_lang']) ? $_GET['edit_lang'] : get_user_meta( get_current_user_id(), 'edit_lang', true );.
-
This reply was modified 8 years, 3 months ago by
VaLeXaR.
thank you sir!
wpm_get_language saved my day. You really should add this function to github readme/docs
-
This reply was modified 8 years, 3 months ago by
dcrystalj.