config localization suffixes problem
The sequence for me is:
URL would be class://net.sqs2.translator.impl.TranslatorJarURIContext/fop/userconfig_it_IT_.xml
URL would be class://net.sqs2.translator.impl.TranslatorJarURIContext/fop/userconfig_it_IT.xml
URL would be class://net.sqs2.translator.impl.TranslatorJarURIContext/fop/userconfig_it.xml
URL would be class://net.sqs2.translator.impl.TranslatorJarURIContext/fop/userconfig.xml
URL would be class://net.sqs2.translator.impl.TranslatorJarURIContext/fop/userconfig_en__.xml
URL would be class://net.sqs2.translator.impl.TranslatorJarURIContext/fop/userconfig_en_.xml
URL would be class://net.sqs2.translator.impl.TranslatorJarURIContext/fop/userconfig_en.xml
OK, created! userconfig_en.xml
I will fix it soon since I have some code to calculate the suffixes as resource-bundle somewhere..
#1 Updated by Hiroya Kubo about 7 years ago
This is duplication issue of #133.
I thought it was closed, but the code I had developed might be insufficient. I have refactored it and added some test cases to make sure.
How do you think of this?
#2 Updated by Hiroya Kubo about 7 years ago
- Status changed from Assigned to Fixed
- Target version set to SQS2.1
- % Done changed from 0 to 100
The two classes sqs-translator/src/main/java/net/sqs2/translator/impl/BundleNames.java and sqs-util/src/main/java/net/sqs2/util/LocaleUtil.java have same design goals to select localization suffix. Current implementation uses the class BuldeNames. On the other hand, the class LocaleUtil enables to select a locale for given environment according to priority list of locales.
#3 Updated by Michele Vivoda about 7 years ago
I took that BundleNames class from an old localization project of mine because I knew it was tested (I think was "copied" many years ago from ResourceBundle ;-)) In that moment the other one was not working, as reported in the issue, and I was stressed by the merge work ;-) So to tell the truth I didn't look into the LocaleUtil up to now.
Of good in the BundleNames is that calculates the correct list of suffixes, because some locale do not have country and variant, but to tell the truth also if a localized file like xxxxx_it__.xml is searched before searching xxxxx_it.xml for locale "it" (no country, no variant) there is no problem.
If I well understand in the LocalUtil that I see now, is possible to say which are the available locales in the resources and set a priority.
But perhaps I dont' get the use case / exact usage in this fast look.
In my experience I know 2 kind of localization support: either one supports one locale + default locale like the "Resource Bundle" way (this is the most common since the platform defines only one locale)
or may support multiple locales gracefully degrading between those (not done by many, but possible in web environment where browser has many locales), so for example an user with locales [AR_eg, FR, EN] gets the messages if available in arabic, if not in french and last resort english.
Is this last option possible to do with the LocaleUtil claass ?
For me supporting multiple locales is super ok but I am not sure if I got it all ;-)