Script translation through load_script_translations #65316
Unanswered
giuliodelmastro
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Good morning! I'm experiencing some problems with the translation of my plugin and I can't seem to get to the bottom of it!
My plugin is completely custom, it's an quote-generator for a client of mine.
I used @wordpress/scripts to develop the form that is displayed on the fronted I used @wordpress/element. The rendering is through react.
It is not a block as my client is still using shortcodes.
I created the po and mo files, through Poedit. Both files are generated correctly. On the admin side where I display a wp-list-table there are no problems, the translation is loaded and displayed correctly.
Fronted side on the form instead I use @wordpress/i18n (__()) for translations.
I then created with wp cli wp i18n make-json languages the json.
Here I encounter the first problem, only 4 of the strings in the .po file are displayed.
When I then use wp_set_script_translations (which returns true) the json file is not loaded on the fronted.
`
foreach ($this->get_scripts() as $script) {
`
I anticipate that I use wp_set_script_translations after queuing the script, and the script has i18n as a dependency.
Where could the problem be?
Beta Was this translation helpful? Give feedback.
All reactions