Changes between Initial Version and Version 3 of Ticket #45103
- Timestamp:
- 10/17/2018 08:33:10 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #45103
- Property Focuses javascript added
-
Property
Summary
changed from
Automatically load JavaScript language packs when scripts are enqueued if these exist.
toAutomatically load JavaScript translations when scripts are enqueued if these exist.
-
Property
Priority
changed from
normal
tohigh
-
Property
Milestone
changed from
Awaiting Review
to5.0
-
Property
Severity
changed from
normal
tocritical
-
Ticket #45103 – Description
initial v3 1 In order to support javascript language packs and allow these to be selectively loaded as described in https://meta.trac.wordpress.org/ticket/3875 WordPress should load language packs for a given JS file when that file is enqueued and the appropriate language pack exists.1 In order to support javascript translations and allow these to be selectively loaded as described in #Meta3875 WordPress should load translations for a given JS file when that file is enqueued and the appropriate language pack exists. 2 2 3 Language packs for JS files should be generated when https://meta.trac.wordpress.org/ticket/3876 is resolved. This will mean that there will be separate language packs for every JS file present.3 Translations for JS files should be generated when #Meta3876 is resolved. This will mean that there will be separate language packs for every JS file present. 4 4 5 When a script is enqueued WordPress should check if a language packfor that specific script exists and, if so, use `wp_localize_script` to load all these translations. An additional script should also be added to then load these translation using `wp.i18n.setLocaleData` ( see [[https://github.com/WordPress/gutenberg/tree/master/packages/i18n|@wordpress/i18n]]. Note that `setLocaleData` will only create a new `Jed` instance if none exist, otherwise the new domain will be merged into any existing domains ).5 When a script is enqueued WordPress should check if a translation file for that specific script exists and, if so, use `wp_localize_script` to load all these translations. An additional script should also be added to then load these translation using `wp.i18n.setLocaleData` ( see [[https://github.com/WordPress/gutenberg/tree/master/packages/i18n|@wordpress/i18n]]. Note that `setLocaleData` will only create a new `Jed` instance if none exist, otherwise the new domain will be merged into any existing domains ). 6 6 7 Because we do not know in advance which domains a script uses we should load all domains for which files exist, likely using `glob` to find all language packs for the given filename and current locale ).7 Because we do not know in advance which domains a script uses we should load all domains for which files exist, likely using `glob` to find all translation files for the given filename and current locale ). 8 8 9 9 Doing this would ensure that all translations a JS file uses are loaded into `wp.i18n` before that script is run and that only the translations that might possibly be used are loaded instead of every single translation.