Java Reference
In-Depth Information
implementation to have this additional package, and you add the Localize.properties
file to it with the following content:
CIRCLE_NAME=Circle
This is the default mapping for the shape name. If the example was more complicated,
you'd have many more default mappings for other terms. To provide other mappings
to other languages, you need to include them in this same package, but in separate prop-
erty files named after the locales' country codes. For example, the country code for Ger-
many is DE , so for its localization you create a file called Localize_de.properties with the
following content:
CIRCLE_NAME=Kreis
You do this for each locale you want to support. Then, at execution time, when you
create your ResourceBundle , the correct property file is automatically selected based
on the locale of the user's computer.
This all sounds nice; but if you have a lot of information to localize, you need to
include all this information in your bundle, which can greatly increase its size. Fur-
ther, you have no way of adding support for new locales without releasing a new ver-
sion of your bundle. This is where fragments can help, because you can split the
resource package into different fragments. You keep the default localization in your
circle implementation, but all other localizations are put into separate fragments. You
don't need to change the metadata of your circle bundle, because it's unaware of frag-
ments, but the content of your circle bundle becomes
META-INF/MANIFEST.MF
META-INF/
org/
org/foo/
org/foo/shape/
org/foo/shape/circle/
org/foo/shape/circle/Activator.class
org/foo/shape/circle/Circle.class
org/foo/shape/circle/circle.png
org/foo/shape/circle/resource/
org/foo/shape/circle/resource/Localize.properties
For this example, you'll create a German localization fragment bundle for the circle
using the property file shown earlier. The metadata for this fragment bundle is
Bundle-ManifestVersion: 2
Bundle-Name: circle.resource-de
Bundle-SymbolicName: org.foo.shape.circle.resource-de
Bundle-Version: 5.0
Fragment-Host: org.foo.shape.circle; bundle-version="[5.0,6.0)"
The important part of this metadata is the last line, which declares it as a fragment of
the circle bundle. The content of the fragment bundle is simple:
META-INF/MANIFEST.MF
META-INF/
org/
Search WWH ::




Custom Search