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

Try loading bundles with locales not specified in the master file #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

prantlf
Copy link

@prantlf prantlf commented May 2, 2014

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 requests i18n: { 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 true or false in the master object; not to repeat the loading attempts later again.

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.
@prantlf prantlf changed the title Try loading bundles unspecified in the master file Try loading bundles with locales not specified in the master file May 2, 2014
@thijstriemstra
Copy link

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({});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants