Plugin Author
Tim W
(@timwhitlock)
My plugin simply cannot generate this JSON file. There is no fix for this.
Have a look at the following threads by someone else who wanted to generate this file:
https://wordpress.org/support/topic/regenerate-the-woocommerce-uk-wc-admin-app-json/
https://wordpress.org/support/topic/how-to-create-file-woocommerce-uk-wc-admin-app-json/
It’s my understanding that these admin functions have been rolled into the main plugin making the separate wc admin plugin redundant. Regardless, that is a WooCommerce topic and not something I know much about.
@timwhitlock Thanks for the reply. I read the topics you mentioned and tried some hacks to force Woocommerce generate the file but no luck yet. If I manage somehow, I’ll post here for future referances.
@timwhitlock I guess I found the problem.
https://github.com/woocommerce/woocommerce/blob/0f0b2d5064079429f30e52335b66c91fcf081d44/plugins/woocommerce/src/Internal/Admin/Translations.php#L96
At Line 96, the function checks if the JSON file has [“comment”][“reference”] value, which doesn’t exist in the generated JSON file. Translations downloaded from remote server and manually generated have different scheme. Here is the comparison for the same file.
This is remotely downloaded original Woocommerce JSON file.
{
"translation-revision-date": "2022-11-01 19:37:59+0000",
"generator": "GlotPress/4.0.0-alpha.3",
"domain": "messages",
"locale_data": {
"messages": {
"": {
"domain": "messages",
"plural-forms": "nplurals=2; plural=n > 1;",
"lang": "tr"
},
"Edit selected product": [
"Seçili ürünü düzenle"
]
}
},
"comment": {
"reference": "packages/woocommerce-blocks/assets/js/blocks/single-product/edit/editor-block-controls.js"
}
}
And this is generated JSON file.
{
"translation-revision-date": "2022-11-02 17:33+0300",
"generator": "WP-CLI\/2.7.1",
"source": "packages\/woocommerce-blocks\/assets\/js\/blocks\/single-product\/edit\/editor-block-controls.js",
"domain": "messages",
"locale_data": {
"messages": {
"": {
"domain": "messages",
"lang": "az",
"plural-forms": "nplurals=2; plural=n > 1;"
},
"Edit selected product": [
"Se\u00e7ili \u00fcr\u00fcn\u00fc d\u00fczenle"
]
}
}
}
As you can see, because generated file doesn’t have [“comment”][“reference”], Woocommerce function ignores it while generating the wc-admin-app.json file.
This gets even more complicated more I dig into. There is also mismatch in how translation strings stored in JSON files.
{
"translation-revision-date":"2022-11-03 19:12+0000",
"generator":"Loco https:\/\/localise.biz\/",
"source":"assets\/client\/admin\/date\/index.js",
"domain":"woocommerce",
"locale_data":{
"woocommerce":{
"":{
"domain":"woocommerce",
"lang":"az",
"plural-forms":"nplurals=2; plural=n != 1;"
},
"Month to date":[
"Ay\u0131n \u0259vv\u0259lind\u0259n bu g\u00fcn\u0259 q\u0259d\u0259r"
],
"Previous year":[
"\u018fvv\u0259lki il"
]
}
}
}
WP-Cli and GlotPress uses [‘locale_data’][‘messages’] format for strings, while Loco uses [‘locale_data’][$textdomain] format. This also causes the same mentioned file can not read translated strings from Loco generated JSONs.
——————————————————-
Edit: Looks like for some reason the keyword “messages” is used as text-domain instead of “woocommerce”. Looks like Loco translate generates files with correct text-domain, while Woocommerce itself generates incorrect files. This needs more investigation.
Plugin Author
Tim W
(@timwhitlock)
If you read the JavaScript that loads the JSON files you will see that the text domain or “messages” are both accepted keys.
I cannot help you with any functions that aren’t a part of my plugin. JSON generation works as documented in my help pages, and does not include this custom file generation.
For people who are experiencing the same issue, you can follow the GitHub thread below for Woocommerce team’s replies. Since Loco plugin is not responsible for this issue.
https://github.com/woocommerce/woocommerce/issues/35500
Plugin Author
Tim W
(@timwhitlock)
Thanks very much for posting this. I’ve bookmarked this thread in case others contact me about the same issue.
@timwhitlock FYI, Fix for this issue will be live with the upcoming WooCommerce 7.6.0 release.
https://github.com/woocommerce/woocommerce/pull/36739