Closed fiwa closed 2 years ago
@fiwa Perfect, it works!
Do you think it would be better to use po2json? Because we COULD bump down node to v14. If not I think this should be merged!
@fiwa Perfect, it works!
Do you think it would be better to use po2json? Because we COULD bump down node to v14. If not I think this should be merged!
@perarnborg I think an extra step in the translation process is worth it in order to use Node 16.
Closes https://github.com/Aventyret/solarplexus/issues/60
Problem
When running
wp i18n make-json
separate files are created based on where the strings are extracted. The naming convention for each source file is {textdomain}-{locale}-{md5(source)}.json.How WordPress looks for translation files:
"Source" in this case is build/index.js added with the handle
solarplexus-script
. This results in translations extracted from others sources not being loaded.Example Translations extracted from src/components/dynamic-inspector-controls.js ends up in a file named {textdomain}-{locale}-{md5(src/components/dynamic-inspector-controls.js)}.json. The file is not loaded separately, resulting in the translations for the file not being loaded.
Solution
Translations needs to be extracted from "build/index.js" BUT that does not work on the minified version. Instead the translation scripts needs to be run in the
yarn start
state.Steps to update translations
yarn start
to create a non-minified build/index.js.yarn translate
to update splx.pot and existing splx-{locale}.po files.yarn translate:compile
to update splx-{locale}.mo and json files.An alternative to the steps above could be to use po2json to convert the mo files to json. But currently the package generates warnings with Node 16.