Situation
Since some version ago (currently running 5.0.3) some plugin updates generate translation files like wp-content/languages/de_DE-1aeac217128913231c1a10ae951869.json
We use two systems, one for local testing, and a live system. Updates are performed on the local system and then pushed to live via git.
We use two languages, English as 1st and German as 2nd
Questions
- what are these language files for? (I guess it is for localizing javascript?)
- is it necessary to add/commit/push them to the live server?
- why do they have such a strange name scheme? Nobody can guess what they're for from just looking at the file name...
Situation
Since some version ago (currently running 5.0.3) some plugin updates generate translation files like wp-content/languages/de_DE-1aeac217128913231c1a10ae951869.json
We use two systems, one for local testing, and a live system. Updates are performed on the local system and then pushed to live via git.
We use two languages, English as 1st and German as 2nd
Questions
- what are these language files for? (I guess it is for localizing javascript?)
- is it necessary to add/commit/push them to the live server?
- why do they have such a strange name scheme? Nobody can guess what they're for from just looking at the file name...
2 Answers
Reset to default 6
- what are these language files for? (I guess it is for localizing javascript?)
You guessed right. The JSONs are for use specifically with the new wp_set_script_translations function in WordPress 5.
- is it necessary to add/commit/push them to the live server?
They are used at runtime, just like .mo
files are. So yes, add them to your deployment if you want the translations to work.
(Note that currently the JSON translations are only used by admin screens, but this could change at any time and will also start applying to theme and plugin translations)
- why do they have such a strange name scheme? Nobody can guess what they're for from just looking at the file name...
The names are derived from the script that uses each file.
From your example: the first string in the file is "Reusable Blocks"
. This is used by the script at wp-includes/js/dist/blocks.min.js
- Take off the .min
and the MD5 hash is 1a0cd6a7128913b15c1a10dd68951869
.
It's not possible to know which script it's required for without searching the code, but there's a ticket open about that.
That's is a translation file, generated from GlotPress that store the translation strings since WordPress Version 5.0.
It should get create via the translation API on 'wordpress' for public plugins. It store all the translation strings for a plugin in the language there you are define in your install - in your example a translation to de_DE
. Store the same date like the .po files, there WordPress use since longer time.
The md5 key (1aeac217128913231c1a10ae951869
) is used to identify the plugin, that should use the json file and is the result of the 'strange' name scheme. Is readable and unique to parse the right one. The file will create by this scheme ${domain}-${locale}-${md5}.json
.
I'm note sure if is only for JavaScript, however I think it is only in use in javascript solutions. The initial idea was to get the translations as JSON to easier parse in the JavaScript context. Especially Gutenberg should use them.
If the live server have access to the API from wp then is a push from the local system not necessary, the live system will check that automatically. But if you have no access outside and you need the control, the file is necessary for the translation.
More background information:
- JavaScript i18n support in WordPress 5.0
- GlotPress-WP Issue 523
- Initial Core Issue 20491