• substa

    (@substa)


    Hello,

    I’m happily using ACF and polylang in my multilingual website.
    Now, I need to translate choice of checkbox field.

    Example:
    FIELD TYPE: CHECKBOX

    Choices:
    1 : One
    2 : Two
    3: Three

    I need to show “One, Two, Three” to English editor, and “Uno, Due, Tre” to Italian editor.
    (Choices are syncronized)

    Is it possible?

    https://www.ads-software.com/plugins/advanced-custom-fields/

Viewing 2 replies - 1 through 2 (of 2 total)
  • +1

    I found a solution that worked well for me.

    1. Register every choices in your functions.php

    <?php 
    pll_register_string("one", "One", "group" );
    pll_register_string("two", "Two", "group" );
    pll_register_string("three", "Three", "group" );
    ?>
    

    2. Show the translated value on your theme page

    <?php 
    $my_field_name = get_field_object('my_field_name'); //Get the object
    $value_my_field_name = get_field('my_field_name'); //Get the value
    pll_e($my_field_name['choices'][$value_my_field_name]); //Translate the selected value
    ?>
    

    3. Go to Settings > Languages > Strings translations and translate.

    • This reply was modified 8 years, 1 month ago by hugolaporte.
    • This reply was modified 8 years, 1 month ago by hugolaporte.
    • This reply was modified 8 years, 1 month ago by hugolaporte.
    • This reply was modified 8 years, 1 month ago by hugolaporte.
    • This reply was modified 8 years, 1 month ago by hugolaporte.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Translate ACF Select choices with polylang’ is closed to new replies.