Home Forums General Issues translate choices of radio/select/checkbox fields


translate choices of radio/select/checkbox fields

  • How do I translate the choices for a raido/select/checkbox field.

    I’ve translated the field_label, left the field_name the same in both languages.
    Field type = select.
    No I need to translate the choices
    In English I have:

    On the Hebrew translation should I translate this?
    How does ACF know which translation is for which term. Is the order important here?

    If I save this and look at a Hebrew post I still don’t see the translation, only the English.
    How do I translate the choice correctly?

  • Hi @renar

    Could you please test the field object on the translated page by using this code:

    echo "<pre>";
    $select_object = get_field_object('select_field_name', 99);
    echo "</pre>";

    Where ’99’ is the ID of the post/page that has the custom field.

    I believe you should add the choices in English like this:

    short : Short
    medium : Medium
    long : Long

    and like this in Hebrew:

    short : קצר
    medium : בינוני
    long : ארוך

    After that, you can get the label based on the value like the example on this page:

    Thanks 🙂

  • I did var_dump and it returned:

    array(22) {
      string(19) "field_56d2d662eda3d"
      string(11) "I work with"
      string(11) "i_work_with"
      string(0) ""
      string(8) "checkbox"
      array(2) {
        string(7) "Couples"
        string(3) "Men"
      string(0) ""
      string(0) ""
      string(0) ""
      array(3) {
        string(0) ""
        string(0) ""
        string(0) ""
      string(11) "i_work_with"
      string(0) ""
      array(9) {
        string(8) "Children"
        string(11) "Adolescents"
        string(6) "Adults"
        string(7) "Couples"
        string(8) "Families"
        string(3) "Men"
        string(5) "Women"
        string(9) "Geriatric"
        string(5) "Other"
      array(0) {
      string(8) "vertical"

    The translation is working for the ‘edit post’ but when I view the page it still only shows the English.
    How do I make it show the Hebrew on the hebrew page?

    I’ve set the choice in the field to:
    Children : יְלָדִים
    Adolescents : מתבגר
    Adults : מבוגרים
    Couples : זוגות
    Families : משפחות
    Men : גברים
    Women : נשים
    Geriatric : גֵרִיאַטרִי
    Other : אחר

    I’m using the_field(‘i_work_with’);
    Do I need to use something different for a translation language?
    The field_name is the same in both languages…

  • Hi @renar

    The the_field() function will only show the value of the selected choice, not the label. Could you please check the var_dump() result on the Hebrew page? Please keep in mind that the translated page has a different ID than the original page. If the choices show the Hebrew label, then you can show the label like this:

    $field = get_field_object('field_name');
    $value = get_field('field_name');
    $label = $field['choices'][ $value ];
    <p>Color: <?php echo $label; ?></p>

    Please check the link I gave you before to learn more about it.

    If it doesn’t show the Hebrew label, could you please var_dump() it without the ID of the page like the following?

    echo "<pre>";
    $select_object = get_field_object('select_field_name');
    echo "</pre>";

    If still no joy, I’m afraid you need to translate it by using WordPress localization functions. This page should give you more idea about it:

    Hope this helps 🙂

  • Thank you, this was helpful and I can get the Hebrew showing now.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘translate choices of radio/select/checkbox fields’ is closed to new replies.