[wp-meta] [Making WordPress.org] #3876: Update wporg-gp-customizations to generate translation files for each JS file. (was: Update wporg-gp-customizations to generate language files for each JS file.)

Making WordPress.org noreply at wordpress.org
Thu Oct 18 11:18:34 UTC 2018


#3876: Update wporg-gp-customizations to generate translation files for each JS
file.
--------------------------------------+---------------------
 Reporter:  herregroen                |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:
Component:  Translate Site & Plugins  |  Resolution:
 Keywords:  has-patch                 |
--------------------------------------+---------------------
Description changed by herregroen:

Old description:

> In order to support javascript language packs and allow these to be
> selectively loaded as described in #3875 wordpress.org will need to be
> able to generate language packs for each JS file.
>
> Currently a single language pack is generated in the `Language_Pack`
> class during the `build_language_packs` function.
>
> Translation entries are retrieved from GlotPress and all of these are
> always added to the PO file.
>
> This should be changed so these translation entries are split according
> to their references.
>
> Before building PO files all translation entries should be looped over
> and a mapping should be created of filenames to an array of translation
> entries. In this mapping there should be a single entry for all
> translations that occur in PHP files and an entry for every single JS
> file present in the translation references containing the appropriate
> translations.
>
> For each entry in this mapping a different PO and MO file should be
> created. These should all be added to the same ZIP the current PO and MO
> files are added to.
>
> The filenames of the generated files for each JS file should be in the
> format of `{$domain}-{$path}-{$locale}`. Where `$path` is the full path
> to the JS file with path separators replaced by dashes. For example, the
> file `js/src/script.js` containing translations in the `example` domain
> would resolve to the filename `example-js-src-script-nl_NL` for
> translations of the `nl_NL` locale.
>
> Doing this will ensure all language packs are ready to be included
> selectively in WordPress and only translations that are needed will be
> loaded.

New description:

 In order to support seperate javascript translation files and allow these
 to be selectively loaded as described in #3875 wordpress.org will need to
 be able to generate translation files for each JS file.

 Currently a single translation file is generated ( in both po and mo
 format ) in the `Language_Pack` class during the `build_language_packs`
 function.

 Translation entries are retrieved from GlotPress and all of these are
 always added to the PO file.

 This should be changed so these translation entries are split according to
 their references.

 Before building PO files all translation entries should be looped over and
 a mapping should be created of filenames to an array of translation
 entries. In this mapping there should be a single entry for all
 translations that occur in PHP files and an entry for every single JS file
 present in the translation references containing the appropriate
 translations.

 For each entry in this mapping a different translation file should be
 created. These should all be added to the same ZIP the current PO and MO
 files are added to.

 ~~The filenames of the generated files for each JS file should be in the
 format of `{$domain}-{$path}-{$locale}`. Where `$path` is the full path to
 the JS file with path separators replaced by dashes. For example, the file
 `js/src/script.js` containing translations in the `example` domain would
 resolve to the filename `example-js-src-script-nl_NL` for translations of
 the `nl_NL` locale.~~

 The filenames of the generated files for each JS file should be in the
 format of `{$domain}-{$locale}-{$md5_of_path}`. Where `$md5_of_path` is
 based on the full path to the JS file. For example, the file
 `js/src/script.js` containing translations in the `example` domain would
 resolve to the filename `example-nl_NL-c3d772dafc117eeef45013ceb21629ed`
 for translations of the `nl_NL` locale.

 Doing this will ensure all translation files are ready to be included
 selectively in WordPress and only translations that are needed will be
 loaded.

--

-- 
Ticket URL: <https://meta.trac.wordpress.org/ticket/3876#comment:9>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org


More information about the wp-meta mailing list