• Resolved W?odz Mur

    (@iwpresss)


    Hello,

    Help me to understand.
    I updated the translation of the WooCommerce plugin and when, after the translation is completed, I upload a new woocommerce-{locale}.po (I have locale = uk) using the Loco Translate plugin to my site, all the necessary *.mo and *.json files are created. All but one woocommerce-uk-wc-admin-app.json.

    How to create file woocommerce-uk-wc-admin-app.json?
    What could be wrong with me?
    Best Regards.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Tim W

    (@timwhitlock)

    JSON files are generated from file references in the PO file. To understand this see https://localise.biz/wordpress/plugin/manual/json#compiler

    How to create file woocommerce-uk-wc-admin-app.json?

    This doesn’t look like the usual hashed file name pattern you would get from script dependencies. I can’t say how it should be generated or why it is missing. Does it actually come from WooCommerce? What is “wc-admin-app”? Some other plugin?

    Thread Starter W?odz Mur

    (@iwpresss)

    Hello @timwhitlock,
    Thanks for your help.

    The fact is that if I delete all WooCommerce translation files (*.po, *.mo and *.json) from the website and update them from the WordPress admin panel, then all translation files will be restored, including woocommerce-uk-wc- admin-app.json
    And if, after deleting all the files again, I try to load the woocommerce-uk.po file from the Loco Translate plugin, then all new files (*.mo and *.json) are created, everything except woocommerce-uk-wc-admin-app.json.
    I also thought that this is a file for the WooCommerce Admin plugin, but this plugin is not installed on my site.

    Best Regards.

    Plugin Author Tim W

    (@timwhitlock)

    I will have to look closely at the WooCommerce plugin to see how this file gets generated and whether Loco Translate can support it via standard WordPress methods. Give me a few days to get back.

    Thread Starter W?odz Mur

    (@iwpresss)

    Hello @timwhitlock,
    Excuse me for burdening you with my problem. But your help is very important to me. Thank you for helping me.

    I think that the problem is still in WooCommerce, or rather with the transfer of functionality from the WooCommece Admin plugin to the WooCommerce plugin (I will definitely write about this on the WooCommerce forum).
    What I found out after “dancing with a tambourine around WooCommerce”:
    1) Start – I have the WooCommerce plugin installed and using the Loco Translate plugin, all the language files (woocommerce-uk.mo and 259 *.json files) are created from the woocommerce-uk.po file in the /wp-content/languages/plugins folder.
    2) I install the WooCommece Admin plugin, but do not activate it (although it is not possible to activate it).
    3) A woocommerce-uk-wc-admin-app.json file is created in my /wp-content/languages/plugins folder containing the old translation of the WooCommerce plugin part.

    Remember that I started all this because I need to update this part of the translation, which is contained in the woocommerce-uk-wc-admin-app.json file.

    4) I checked the translation of the WooCommerce plugin on my website very carefully – the translation is old.
    5) Using the Loco Translate plugin, I load my new translation of the WooCommece Admin plugin (the bad thing is that some of the translation lines of the WooCommece plugin (woocommerce-uk.po) duplicate the translation lines of the WooCommece Admin plugin (woocommerce-admin-uk.po). That’s it and confused me.
    6) In my /wp-content/languages/plugins folder woocommerce-admin-uk.mo, woocommerce-admin-uk.mo and 49 *.json files are created. The main problem remains: the woocommerce-uk-wc-admin-app.json file has not changed after this download.
    7) Rechecking the translation of the WooCommerce plugin on my website – the translation is old. I didn’t get the desired result.
    8) I delete the language files of the WooCommece Admin plugin from the Loco Translate plugin. Removed woocommerce-admin-uk.po, woocommerce-admin-uk.mo and 49 *.json files in my /wp-content/languages/plugins folder. The woocommerce-uk-wc-admin-app.json file has not been removed. His (old) part of the translation of the WooCommerce plugin remained on the site.
    9) I remove the language files of the WooCommece plugin from the Loco Translate plugin. Removed woocommerce-uk.po, woocommerce-uk.mo and 259 *.json files in my /wp-content/languages/plugins folder. The woocommerce-uk-wc-admin-app.json file has not been removed. His (old) part of the translation of the WooCommerce plugin remained on the site.
    10) In my /wp-content/languages/plugins folder, I manually delete the woocommerce-uk-wc-admin-app.json file – the old translation of the WooCommerce plugin part disappears.

    I don’t know what to do with this ;).

    I really hope that you managed to understand my terrible English.

    Best Regards Wlodz Mur.

    Plugin Author Tim W

    (@timwhitlock)

    Can you please provide a link to download the “WooCommece Admin” plugin?

    Thread Starter W?odz Mur

    (@iwpresss)

    I took from here:
    https://www.ads-software.com/plugins/woocommerce-admin/

    Plugin Author Tim W

    (@timwhitlock)

    This is all getting very complicated.

    The first thing I notice is that the official translations of “woocommerce-admin” don’t provide a JSON file named woocommerce-{locale}-wc-admin-app The Ukrainian project is only 88% complete so wouldn’t install. I checked instead with the Czech translations and they don’t include any such file.

    Are you sure this is where your file comes from?

    Perhaps you can provide an example source string which this file contains.

    Thread Starter W?odz Mur

    (@iwpresss)

    Hello @timwhitlock,
    Thank you very much for your help. It is very important for me.

    The Ukrainian project is only 88% complete so wouldn’t install.

    After the message from the WooCommerce team that WooCommerce Admin functionality was ported to WooCommerce, we stopped translating WooCommerce Admin.

    Are you sure this is where your file comes from?

    The main problem is that I don’t know who creates it.
    The existence of the file was also confirmed by @lioneldaniel (locale=GB) on the WooCommerce forum:

    I will try to describe in detail on the example of the line:
    “Your inbox is empty”

    Here I put some screenshots, maybe they will help me to clarify my problem.

    Fig. 1 Woocommerce language files removed. woocommerce-admin plugin – not installed
    Fig. 2 After loading woocommerce.po with Loco Translate plugin. woocommerce-admin plugin – not installed. File woocommerce-uk-wc-admin-app.json – no
    Fig. 3 WooCommerce Admin plugin installed. The woocommerce-uk-wc-admin-app.json file appeared, which contains the old translation.
    Fig. 4 Removed woocommerce-uk-wc-admin-app.json manually. The old translation is gone.

    Perhaps you can provide an example source string which this file contains.

    The line “Your inbox is empty” is in the woocommerce.pot and woocommerce-admin.pot language files

    Lines from my woocommerce-uk.po:

    #: /assets/client/admin/chunks/activity-panels-inbox.js:1/
    #: /assets/client/admin/chunks/homescreen.js:1/
    msgid “Your inbox is empty”
    msgstr “Ваша поштова скринька порожня-woo”

    /assets/client/admin/chunks/activity-panels-inbox.js
    title:0,c.__)(“Your inbox is empty”,”woocommerce”)

    /assets/client/admin/chunks/homescreen.js
    title:0,o.__)(“Your inbox is empty”,”woocommerce”)

    Lines from my woocommerce-uk.po:

    #: /dist/chunks/3.js:455/ /dist/chunks/4.js:1188/
    msgid “Your inbox is empty”
    msgstr “Ваша поштова скринька порожня-admin”
    

    /dist/chunks/3.js
    title: /Object/(external_wp_i18n_[“__”])(’Your inbox is empty’, ’woocommerce-admin’)
    /dist/chunks/4.js
    title: /Object/(external_wp_i18n_[“__”])(’Your inbox is empty’, ’woocommerce-admin’)

    I really hope that you managed to understand my terrible English.

    Best Regards Wlodz Mur.

    Plugin Author Tim W

    (@timwhitlock)

    Fig. 3 WooCommerce Admin plugin installed. The woocommerce-uk-wc-admin-app.json file appeared

    I can’t account for this. It does not happen for me in any of the languages I’ve tried, including en-GB. You say the WooCommerce Admin plugin is now ported into WooCommerce, so why are we still discussing it? If it’s redundant then you should delete it because it’s only confusing matters.

    “Your inbox is empty”

    This string (as you show) is used by the main WooCommerce plugin in two .js scripts (homescreen.js and activity-panels-inbox.js). As such it appears in 2 .json files (woocommerce-uk-1dee949f3bc3eacc1513cb13c32c60bd.json and woocommerce-uk-cff9e44defb88755b784b7f92a6c4f85.json) I have verified that Loco Translate also generates these files correctly.

    The other references you show (dist/chunks/3.js and dist/chunks/4.js) seem to come from woocommerce-admin not woocommerce, so – as mentioned – shall we remove this plugin from the conversation?

    The main problem is that I don’t know who creates it.

    I don’t know either and I can’t reproduce the installation of this file using any language. I would expect WooCommerce support might know, but they don’t seem to be addressing that specific question.

    A quick look through the code suggests that “wc-admin-app” is a prefix used for various script handles. Loco Translate won’t generate JSON files directly from script handles, so if this JSON file matches a loaded script then it will short-circuit the normal loading of files as shown above (woocommerce-uk-{hash}.json). This will likely cause problems overriding strings in custom translation files.

    I am reaching the end of what I can do for you here. My plugin supports JSON file generation as documented only. To your original question “How to create file woocommerce-uk-wc-admin-app.json?” the answer is my plugin won’t do it. As to whether this file is needed, or why it appears, I cannot answer that. As it’s not present in the official language packs then I’d suggest it’s not needed by woocommerce directly.

    Thread Starter W?odz Mur

    (@iwpresss)

    Hello @timwhitlock,

    Thank you very much, you explained everything to me in great detail. It really doesn’t make any sense to go into the WooCommerce Admin plugin here as well, but that was the only thing that linked to the woocommerce-uk-wc-admin-app.json file.
    Files you specified:

    woocommerce-uk-1dee949f3bc3eacc1513cb13c32c60bd.json
    woocommerce-uk-cff9e44defb88755b784b7f92a6c4f85.json

    is indeed in my /wp-content/languages/loco/plugins folder.

    I have already checked my translation a million times in the woocommerce-uk.po file. I uniquely marked it by adding ‘-woo‘ to the end. I can see my translation in the editor of the Loco Translate plugin.
    So I see my translation in woocommerce-uk-1dee949f3bc3eacc1513cb13c32c60bd.json:

    “Your inbox is empty”: [
                    “\u0412\u0430\u0448\u0430 \u043f\u043e\u0448\u0442\u043e\u0432\u0430 \u0441\u043a\u0440\u0438\u043d\u044c\u043a\u0430 \u043f\u043e\u0440\u043e\u0436\u043d\u044f-woo”
                ],

    There is my ‘-woo‘ at the end of the line.

    But on the site this line is displayed not translated. And as soon as I returned the woocommerce-uk-wc-admin-app.json file to the site, the old frontend is displayed on the site (without my ‘-woo’ at the end of the line).
    And the main thing is that this translation is really in the woocommerce-uk-wc-admin-app.json file:

    “Your inbox is empty”:[
    “\u0412\u0430\u0448\u0430 \u043f\u043e
    \u0448\u0442\u043e\u0432\u0430 \u0441
    \u043a\u0440\u0438\u043d\u044c\u043a\u0430 \u043f\u043e\u0440\u043e\u0436\u043d\u044f”
    ],

    Once again, thank you very much for your help, I have already written all this more for the WooCommerce team.
    I want to add all this in the answer to you in the WooCommerce thread, maybe it will somehow help me.

    Best Regards.

    • This reply was modified 2 years, 2 months ago by W?odz Mur.
    • This reply was modified 2 years, 2 months ago by W?odz Mur.
    • This reply was modified 2 years, 2 months ago by W?odz Mur.
    Thread Starter W?odz Mur

    (@iwpresss)

    Hello @timwhitlock,

    Maybe this will be of interest to you.
    I have been looking for a long time for someone from the WooCommerce team to provide at least some information about the woocommerce-XX-wc-admin-app.json (xx = locale) file and here is Mike Jolley (@mikejolley) from the WooCommerce team wrote me:

    “I don’t think that .org post is relevant here. WC Admin seems to have a special mechanism for generating translation files after updates which may be why your changes are ignored https://github.com/woocommerce/woocommerce/blob/0f0b2d5064079429f30e52335b66c91fcf081d44/plugins/woocommerce/src/Internal/Admin/Translations.php#L41 It may be that only official translation packs from translate.www.ads-software.com are supported”.

    Whether I’m right or not, I don’t know. But I understood it in such a way that the WooCommerce plugin cannot be translated using the Loco Translate plugin? And this worries me a lot. What should I do if I need a custom plugin translation and can’t use the translation from translate.www.ads-software.com?

    Now this is a problem for me. Am I supposed to decode the binary file the woocommerce-XX-wc-admin-app.json file? And who needs *.json files if they are not used to display the translation?

    Excuse me, but that’s all I wrote to you in Slack Making WordPress/Private (@iwpress). I did not know where it would be more convenient.

    Best Regards, Wlodz Mur

    • This reply was modified 2 years, 1 month ago by W?odz Mur.
    Thread Starter W?odz Mur

    (@iwpresss)

    Hello @timwhitlock,

    Here is another interesting answer from the WooCommerce team. lionel.a11n (@lioneldaniel) wrote:

    `Investigating the plugin files on your behalf, the file is built by the build_and_save_translations function in Translations.php, which is ultimately fired every time the upgrader_process_complete action is run for the WooCommerce domain. This is a core WordPress action hook, and it basically is run every time a plugin or theme is updated.

    To look at the code directly, follow this link to view the function on GitHub.
    I found this function by seeking where the filename itself is built and which functions use that name. It turns out the filename is created by the get_combined_translation_filename method called by the above function.
    That shared, these are implementation details you shouldn’t need to update the translations on your site. From all the exhaustive work you’ve done, it could be there is either a bug, an issue where this file isn’t being rebuilt based on how you are updating your translations, or some particularly aggressive caching preventing you from generating this file correctly. Perhaps this information can help the Loco Translate team further diagnose why your translations aren’t being captured.

    If you or the Loco Translate team find there is a bug regarding how this translation file is built or with WooCommerce’s use of WordPress’ translation features, I encourage you to provide steps which replicate the error and file it on the official WooCommerce GitHub Repository. If your process involves Loco Translate, you can include that information so the WooCommerce development community can weigh in on whether there are any improvements possible that would enable the workflow you’re attempting.

    Regards.

    Thread Starter W?odz Mur

    (@iwpresss)

    Thank you very much for your help, sorry for my insistence.

    Best Regards.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to create file woocommerce-uk-wc-admin-app.json?’ is closed to new replies.