Support

Account

Home Forums ACF PRO How to translate own option fields at backend?

Solved

How to translate own option fields at backend?

  • Hey,

    I love this amazing ACF pro plugin, but I can’t find an solution for my issue.
    Is there a way to translate the own added option field labels at WordPress backend?

    Perhaps there is a way, without WPML, to create a .PO file with all my own option field labels?
    I want to translate these fields into other languages.

    Thanks for any help.

  • I have the generated .JSON files at my theme in the folder “acf-json”, with all my own field labels.

    But how I can change the output from label value to a textdomain value?

  • Ok, I find a solution. I can export manually the field group to php and load these in the function.php.

    Than I set the textdomain:

    
    function custom_acf_settings_textdomain($domain) {
      	return 'textdomain';
    }
    
    add_filter('acf/settings/l10n_textdomain', 'custom_acf_settings_textdomain');
    
    

    And all labels be found by Poedit template import. Thats fine 🙂

    Is there a way to generate the php field group export automatically, by edit and saving the fields in ACF admin?

  • Any idea for automatically generated php file by editing and saving from ACF admin?

  • Hi @wootimes

    For something like that, you need to create custom code that will generate the PHP code. Please check how ACF does it in “wp-content/plugins/advanced-custom-fields-pro/admin/settings-tools.php”. After that, you can hook it to WordPress save_post hook.

    I hope this makes sense 🙂

  • @acf-support

    Thanks for your help. My PHP knowledge is not enough, for creating this . 🙂
    I can copy the code, but I don’t know, how I create the automatically file export with all selected field to my theme folder. 🙁

  • Hi @wootimes

    I’m afraid to do it you need advanced PHP skill. If you don’t have time to learn PHP, I suggest you hire a developer to help you out with it, and I’d recommend looking for one on https://studio.envato.com/, https://www.upwork.com/, or https://codeable.io/.

    Also, could you please tell me what do you want to do with the exported code? Maybe we can find another method to achieve it.

    Thanks 🙂

  • @acf-support I’m a web designer and not a developer, but I would like to learn some things for myself. I’m happy that there is this acf plugin. It gives me more freedom in the template development. It’s amazing 🙂

    In most cases, few PHP skills are sufficient. Sorry for my question.

    But, I can’t unterstand, why the automatically export is no main feature? The PHP export is the best way to get all of the fields to the different theme users. With the JSON export, each user must be sync the new fields manually. With a theme update, which include the new fields in the exported php file is the better way for me. Because then the user has all new fields, without doing something.

    That’s the reason, because I want create a automatically generated file export. It is less error-prone, if you should forget to update the file. Or is there a better way?

    My english is not the best, I hope you can understand me 🙂

  • Hi @wootimes

    The problem is that you are not supposed to add field groups using both PHP code and the backend editor as it can cause conflict on your site. That’s why there’s Local JSON feature.

    The correct way of using the PHP code generation feature is to generate the PHP code first, copy it to your functions.php and then delete the field group from the backend.

    If later you need to modify the field group, you can always modify the PHP code instead. You can also export the field group to JSON before deleting it, and then import the field group back when you need to edit it. Then you can repeat the code generation process like before.

    I hope this makes sense 🙂

  • Hi James @acf-support

    ok, this plugin logic makes sense 🙂

    Nice to know that, thanks for your help

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

The topic ‘How to translate own option fields at backend?’ is closed to new replies.