Home › Forums › Backend Issues (wp-admin) › Multilingual field labels
I develop multilingual sites for multilingual editors: primarily German and French speakers. I love the ACF plugin and its add-ons, but there is one slight issue: how to create multilingual labels for the backend.
An example. I create a field called “Project title” in the backend which receives the field key “project_title”. The key is used for saving the data and for showing it on the website. All good there.
On my website, I can use POEdit to ensure that the field labels are displayed in the language appropriate to the user’s browser.
What I need to be able to do, though, is have the field label in the backend show “Projekttitel” for (e.g.) German-speaking editors. For English-speaking editors, the label must remain “Project title”.
Is this possible? Can I achieve this directly? Do I need to work with PoEdit files? (I’m already handling the multilingual environment, no issue there.)
Hi @Mark Howells-Mead | mhm.li
Currently, ACF deos not translate the label value in the wp-admin area.
You could get around this by hooking into the load_field filter (please see docs for more info) and set the $field’s label to itself using the WP translate function like so:
$field['label'] = __($field['label']);
I’ll add this to the to-do as it should be part of the core.
Thanks
E
Thanks Elliott; that works a treat for the top-level fields. There doesn’t appear to be a filter hook for all elements; e.g. sub_fields. Have I overseen something?
Do you foresee an ongoing requirement to handle multilingual issues like this via gettext functions and external .po / .mo files?
Hi @Mark Howells-Mead | mhm.li
your right, hmmm. Perhaps instead of the load_field filter, you can use the ‘acf/load_field_defaults’ filter instead.
Looking at the repeater add-on, this filter is used on all sub fields so it should fix the issue for you.
Thanks
E
Thanks for the suggestion. I’ll give it a try and respond with feedback in a few days’ time.
Working well, thanks for the tip. Thanks Elliot. I could do with exactly the same filter on $field[‘layouts’], placeholders and so on too, so that I can translate all of the text which can be defined by the BE user.
The topic ‘Multilingual field labels’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc
— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.
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.