$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>translation - Unknown language json files|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

translation - Unknown language json files

matteradmin10PV0评论

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

  1. what are these language files for? (I guess it is for localizing javascript?)
  2. is it necessary to add/commit/push them to the live server?
  3. 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

  1. what are these language files for? (I guess it is for localizing javascript?)
  2. is it necessary to add/commit/push them to the live server?
  3. why do they have such a strange name scheme? Nobody can guess what they're for from just looking at the file name...
Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked Jan 22, 2019 at 12:23 xmoexxmoex 1431 silver badge6 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 6
  1. 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.

  1. 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)

  1. 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

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far