Support

Account

Home Forums Bug Reports acf php settings translation problem

Solving

acf php settings translation problem

  • hi
    i used below code for translate options string in exported php option fields.

    add_filter('acf/settings/l10n', 'mytheme_acf_settings_localization');
    if ( ! function_exists('mytheme_acf_settings_localization')) {
    	function mytheme_acf_settings_localization($localization){
    		return true;
    	}
    }
    
    add_filter('acf/settings/l10n_textdomain', 'mytheme_acf_settings_textdomain');
    if ( ! function_exists('mytheme_acf_settings_textdomain')) {
    	function mytheme_acf_settings_textdomain($domain){
    		return 'mytheme';
    	}
    }

    but in exported php settings, there are some strings that do not have translate functions around.

    example 1 :
    ‘label’ => ‘Onsale Products Text’,

    that should be like below :
    ‘label’ => __(‘Onsale Products Text’,’mytheme’),

    example 2 :

    'choices' => array(
    'desc-before-loop' => 'Yes, before product loop',
    'desc-after-loop' => 'Yes, after product loop',
    'desc-hide' => 'No, hide description',
    ),

    that should be like below :

    'choices' => array(
    'desc-before-loop' => __('Yes, before product loop','mytheme'),
    'desc-after-loop' => __('Yes, after product loop','mytheme'),
    'desc-hide' => __('No, hide description','mytheme'),
    ),

    please help me because i have to find this string every time options changed and replace theme manually

    thanks

  • What version of ACF are you using? I just tried a simple test in the latest version of pro and the textdomain is being applied to choices

  • i’m using 5.8.12 .
    You are right
    textdomain is applied to the choices and other options, But not on all of them.
    For example, if there are 1000 strings in the file, Few strings have problems.
    And I have to fix these manually.

    And another problem is that the names of the field groups have textdomain, but are not displayed in the POEDIT program for translation.

    An example of this problem is as follows
    ‘title’ => __(‘Public Settings’, ‘mytheme’),

    ‘Public Settings’ is not displayed in the POEDIT software for translation
    Thank you

  • Can you narrow this down to what types of fields? Could it be something to do with sub fields of one kind or another? It seems odd that only some fields have a problem. These fields must have something in common.

    • enter64

    • August 1, 2020 at 7:24 am

    I uploaded the output file for you
    https://gofile.io/d/plZV1t
    or
    https://file.io/0b8KlwthrQrJ
    or
    https://filebin.net/k5if7h2lx4xw93di/settings.php?t=tfflp5x1

    For example, you can check the following lines in this file :
    8826
    9125
    9145
    9186

    thanks

  • I can’t see by looking that this what the cause could be.

    For example, two fields, one right after the other

    
    // first field label 
    'label' => 'Onsale Products Text',
    // next field label
    'label' => __('" Add To Cart " Button Text - in Product Page', 'kanishop'),
    

    both are text fields, one is correct and the the other not. I see nothing in common where this is happening

    Have you tried smaller exports? Narrow it down to a group where the problem happens, narrow it down to a field, then see if there are any filters that might be interfering with that specific field?

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.