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

Adding optional fallback to root language bundle #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tstibbs
Copy link

@tstibbs tstibbs commented Feb 21, 2014

I understand the fact that CAL10n doesn’t fall back to a ‘root’ language in the same way that java resource bundles do, and I understand that this was done for reasons of ‘least surprise’. However, I’d like to add the option of a fall-back. I’d like to use CAL10n, but without this feature, using CAL10n on my project is tricky. Therefore, I have implemented a change to allow a fall-back. I have tried to ensure it has the least impact on other developers or people currently using the library. So, if it looks a bit hacky (and it probably is) it’s because I’m trying to make the least changes possible.

Projects using CAL10n which wish to set this fall-back have to call Settings.setRootLanguageFallbackEnabled(true); before loading any bundles. Projects who want to use CAL10n in the traditional way need to do nothing.

The reason I would like this change is that the distribution of language packs is done totally separately to the building of my product. Therefore, at compile time there’s only likely to be one set of language files in the product (English). This means that if someone deploys the product on a system with a different locale, they need a new language pack. It would be far easier if the language files I provided were for a ‘root’ language, which could be fallen back to. This means that (for example) if a customer moved our application from a data centre in Germany to a data centre in Thailand, it doesn’t matter what the locale settings for those environments are, the application will still run and will still have logging (currently CAL10n throws an exception if the language files cannot be found, and thus there is no logging). English might be not the ideal language here, but it’s better than the app simply not running or not having any logging.

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