Home Forums General Issues \"Translate\" checkbox values with string replace


\"Translate\" checkbox values with string replace

  • Hello,

    i have on a multilanguage site a checkbox field with 18 different choices.
    Now i need to print the checkbox values in frontend in different languages. For different reasons i don’t want to translate the field groups with WPML.

    My idea is to work with PHP str_replace to show different strings for the same value dependending on which language is shown. I tried something like tis:

    $string = array("/string-1/","/string-2/","/string-3/","/string-4/" );
    $replace = array("new-string-1","new-string-2","new-string-3","new-string-4");
    $fieldname = get_field('fieldname', $term); // it is a meta-field for a taxonomy term
    $fieldname_new = str_replace($string, $replace, $fieldname);
    echo $fieldname_new;

    But of course it doesn’t work because it is an array!
    Does anyone have an elegant idea to implement my plan. My last option is to do it with JavaScript.

    Many many thanks in advance!

Viewing 1 post (of 1 total)

The topic ‘\"Translate\" checkbox values with string replace’ is closed to new replies.