Try loading bundles with locales not specified in the master file#19
Open
prantlf wants to merge 2 commits intorequirejs:masterfrom
Open
Try loading bundles with locales not specified in the master file#19prantlf wants to merge 2 commits intorequirejs:masterfrom
prantlf wants to merge 2 commits intorequirejs:masterfrom
Conversation
This makes possible adding bundles just by populating their locale-specific directies - without modifying the master file, which may not be easy after the product has been deployed and the language packs cannot modify it. Bundles are attempted to load on the first access and the success or failure are remembered by true or false in the master object not to repeat the loading attemot later again.
|
Thanks, this is exactly what I needed, and it seems to work :) @jrburke, is this something you would consider adding? The only thing that seems to be different from the original version is that files that don't have a translation are now throwing a 404 error, whereas the original code would silently ignore these 404s. A workaround for that 404 problem would be using a single .js translation file, or defining enough to make it pass: define({}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Specifying all available bundles in the master file when a product is released may not be convenient. If a localization is provided afterwards, the master module has to be modified, which gets even more difficult when it is compiled to a single output file. This makes possible adding bundles just by populating their locale-specific directories - without modifying the master file, which may not be easy after the product has been deployed and the language packs work just the "unzip" way and cannot include any code performing code modifications.
If the locale is specified in the master module, no additional locale forms are tried. For example, if
{ "fr": true }is there and the configuration requestsi18n: { locale: "fr-fr" }, the "fr-fr" bundle is not attempted to load. This makes the dynamic behaviour not affect the existing master modules with explicitly specified locales, if this change should not affect them.Bundles are attempted to load on the first access and the success or failure are remembered by
trueorfalsein the master object; not to repeat the loading attempts later again.