Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_set_script_translations usage not possible with wpackio script #15

Open
derweili opened this issue Nov 16, 2021 · 3 comments
Open

wp_set_script_translations usage not possible with wpackio script #15

derweili opened this issue Nov 16, 2021 · 3 comments
Labels
Type: Question Further information is requested

Comments

@derweili
Copy link
Contributor

WordPress 5.0 added the new wp_set_script_translations() for translating strings in JavaScript.

Read more here: https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/

Therefore the translation json files must be named like this (naming convention by WordPress):
${domain}-${locale}-${handle}.json

But because wpackio dynamically generates the handle, this is not possible.

I know there was a identifier config option to specify the handle in the past, but this was removed because of reasons I don't know much about. But I think we need this back.

@derweili derweili changed the title wp_set_script_translations usage not possible with wpack script wp_set_script_translations usage not possible with wpackio script Nov 16, 2021
@swashata
Copy link
Owner

Hello,

We now have this main_js_handle, to set the handle of the main JavaScript file.

https://github.com/swashata/wpackio-enqueue#default-configuration-when-calling-enqueue

@derweili
Copy link
Contributor Author

@swashata oh great totally missed that. Are there any examples?
I don't get the difference between the main_js_handle and runtime_js_handle.

Both settings are not mentioned in the PHP API Docs yet.

@swashata
Copy link
Owner

Hi,

  • main_js_handle The main JS file for your app.
  • runtime_js_handle Is the webpack generated JS file that has code needed by the main JS (for eg, to dynamically import other modules).

@swashata swashata added the Type: Question Further information is requested label Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants