I have a contributed view in an Eclipse RCP application. This view has a localized name %view.name, with the translation on a plugin.properties file to "My View Part".
I am looking into the source code of Eclipse to understand how the internationalization works. So far, I haven't been able to find at what point the value from the properties file is read and assigned as the name of the view.
If I start from the resource reading part, I see that the class ManifestLocalization reads the properties file, but I can't find where it is used.
If I start from the name assignment, I see that the TableReader class gets the name of the view part, but it is already localized. I also saw that Eclipse converts this plugin.xml into some serialized object at some point. Maybe it is done for performance reasons?
So my question is, at what time is this "%view.name" string converted into "My View Part"
There is at least two mechanisms supporting localization in eclipse: the NLS, and the org.eclipse.core.runtime.registry.IConfigurationElement. The part you are interested in occurs in the IConfigurationElement.
When the IConfigurationElement.getAttribute(String key) is called, the ResourceTranslator.getResourceString() method uses the Bundle-Localization header in the OSGi manifest to find the correct properties file (usually this is plugin${locale}.properties) and entry in the properties file.
You can get what is actually in the plugin.xml file by calling the getAttributeAsIs(String key) method instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With