-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
acf-json + fields' translation #48
Comments
Hi @drzraf Thanks for the topic. ACF provides basic functionality for translating each field plus a filter for full customization. This function is called for each field (either from the DB or from JSON) and will translate the label and instructions using the 'l10n_textdomain' setting. You can hook into the filter "acf/translate_field" to apply your own translations to the $field array. |
But:
We should not think that if that string is translatable and has been translated we will grab its value in So how do we know ACF-JSON files (or fields) are translatable and needs to be extracted to build a catalog? That's where metadata are needed which indicate whether or not something is translatable, and what is the source language. Source language can be made easy: same as PHP code. Several possibilities exist to define which keys to translate and which not to, see https://zanata.atlassian.net/browse/ZNTA-667 For a, more simple, Example 1:Eg, adding a key at the end of a field-group file (but UI would be needed to configure these keys):
PO JSON extractor's job is just to recursively look at every key to see whether it may be translated and create a PO file like:
It could hold below 100 LoC within a standalone executable PHP script, bundled with ACF, that can be referenced in Poedit. Example 2:For Google Chrome extension inspired solution (see above link):
The advantage of this kind of solutions are that they work on the file-format level (JSON) without entering into the detail of ACF-specific structuration (list of fields, expected keys, ...) ping wp-cli/i18n-command/issues/52 / @swissspidy and @aduth (WordPress/gutenberg@c539390) since they may provide some input? |
Hi @drzraf Thanks for the reply and awesome info! |
Is there any update on this? |
Hi @DhrRob - No update on this issue as of yet. Apologies, but we must remain focused on the larger priorities right now such as Gutenberg compatibility and REST API updates. |
I would like to use fields (defined, versioned and deployed using ACF-JSON) for various sites having different languages.
Is there a plan to handle ACF JSON when it comes to i18n fields?
A couple of hooks (are available at load-time/save-time to load/write translations (
acf/prepare_field_group_for_export
, NB:acf_import_field_group
is missing a similar hook, onlyacf/update_field_group
is provided) but formalize it (and why not, implement it), would be appreciated for forward-compatibility.w3c issued a couple of guideline and draft on this topic some months ago:
See also:
The text was updated successfully, but these errors were encountered: