locale-sh: a Java Locale Service Provider for Bosnian/Croatian/Serbian
2008-12-06
The locale-sh package provides LocaleServiceProvider implementations for locales of the Serbo-Croatian language family. The original intention was to just create locale definitions for Bosnian (“bs”), which are still missing from Sun’s JRE at the time of this writing. However, it now also has ekavian Serbian definitions for the Latin script (Sun only ships a Cyrillic variant) when used as sh_RS (Serbo-Croatian language, country Serbia) and Croatian definitions when used as sh_HR. The package includes mainly number and date formats, as well as some support for collation and localised locale names.
Examples
| bs | bs_BA | sh_RS | sh_HR |
|---|---|---|---|
| bosanski | bosanski – Bosna i Hercegovina | srpskohrvatski – Srbija | srpskohrvatski – Hrvatska |
| 6. juli 2008. | 6. juli 2008. | 6. jul 2008. | 6. srpanj 2008. |
| ¤ 9.999.999,90 | BAM 9.999.999,90 | RSD 9.999.999,90 | HRK 9.999.999,90 |
Download
- Binary JAR: locale-sh-0.0.3.jar
- Source Archive: locale-sh-0.0.3-sources.zip
Note that this is a very early version which hasn’t seen a lot of real-world testing yet. Use at your own risk!
Requirements
This package requires Java 6 (aka Java 1.6) or above. You might be able to use individual format definitions with older Java versions by manually referencing the implementation classes, but that’s not pretty.
Usage
- Drop the locale-sh JAR file into your JRE’s lib/ext directory. For more information, check the Java Tutorial’s trail on extensions – unfortunately, just placing the JAR anywhere in the classpath doesn’t seem to suffice (at least I couldn’t get it to work that way).
- Depending on your needs, use “bs” or “sh” as your locale language, and optionally an applicable country code (“BA”, “RS”, etc.) Note that the locale definition can come from various sources: it can be explicity specified on the command line, programmatically defined by instantiating a Locale object, passed in from the remote browser by your application server, defined as a default as long as no other locale is set, etc. The rest should follow automatically when you use locale-sensitive classes.
Questions and Answers
It doesn’t work at all! What’s wrong?
Make sure you’ve installed the JAR correctly as per the Java extension mechanism policies, and that you’re using one of the supported locales (language sh or bs).
Some of your definitions are wrong! Where did you get this stuff from?
Trustworthy dictionaries, checking the Microsoft Windows localization data, and some web research. If you find an error, please tell me about it in detail and I’ll happily fix it. Note that I’m interested in providing locale definitions that reflect actual usage. My experience is that even some widely respected sources (like the Unicode consortium or IBM’s localization database) have all sorts of errors in them – in the sense of definitions that do not reflect actual usage in the locale at all.
Why “Serbo-Croatian”? Why don’t you just overwrite the Croatian/Serbian locales?
Sun’s Locale Service Provider interface can only be used to add nonexisting locales. It’s unfortunately not a way to fix broken existing locale data. For this reason, it’s a nice thing that the “sh” locale is unused in recent JREs. I don’t care about anyone’s linguistic or political concerns.
Why is there no support for Montenegrin Serbian or the Montenegrin language?
As I’m writing this, there is no ISO 639-1 code for the Montenegrin language. And whether you consider it a variant of Serbian/Serbo-Croatian or a language of its own, I don’t have any authoritative information on Montenegrin usage.
