Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339211 - [registry] Unable to translate fragment.xml
Summary: [registry] Unable to translate fragment.xml
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Components (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: equinox.components-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-08 07:44 EST by DJ Houghton CLA
Modified: 2011-07-12 08:52 EDT (History)
2 users (show)

See Also:


Attachments
security.nls test bundle (1.04 KB, application/java-archive)
2011-03-08 07:44 EST, DJ Houghton CLA
no flags Details
possible fix (5.44 KB, patch)
2011-03-10 15:04 EST, Thomas Watson CLA
no flags Details | Diff
possible fix (w framework fix) (6.75 KB, text/plain)
2011-03-14 16:30 EDT, Thomas Watson CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description DJ Houghton CLA 2011-03-08 07:44:13 EST
Created attachment 190650 [details]
security.nls test bundle

We have a case where we are unable to translate the fragment.xml file with another fragment. Consider the following scenario:

Eclipse SDK has:
- org.eclipse.equinox.security bundle
- org.eclipse.equinox.security.macosx bundle

org.eclipse.equinox.security.macosx:
- has in its manifest: Bundle-Localization: fragment
- provides a fragment.properties file with the default English translations

We provide another fragment: org.eclipse.equinox.security.nls
- has in its manifest: Bundle-Localization: nl_fragment
- provides a nl_fragment.properties with its translations
- also provides a fragment_fr.properties with translations for the fragment.xml for the macosx fragment

When we start Eclipse (with -nl fr) and look in the Preferences (Preferences -> Security -> Secure Storage) and look in the Master Password Providers table, the contents are in English only. If we trace through the code, this list is being populate by going to the registry and calling #getLabel on the ConfigurationElement that is in the Extension Registry. I believe this should be translated at this point.
Comment 1 DJ Houghton CLA 2011-03-08 10:37:58 EST
From my investigation, this appears related (dup?) to bug 285621.

- put translations in the drop-ins folder
- start Eclipse
- we read the bundles and cache a bunch of values in the registry
- values cached are English because the translations haven't been installed yet
- then we process the dropins and install the translation bundle
- Preference page values are shown in English
- shut down
- start up Eclipse
- we check use the cached values so English is used again

If you start the workspace with -clean (on the second start and beyond; after the nls bundle has been installed) then you will see the correct behaviour.
Comment 2 Thomas Watson CLA 2011-03-08 11:05:08 EST
(In reply to comment #1)
> From my investigation, this appears related (dup?) to bug 285621.
> 
> - put translations in the drop-ins folder
> - start Eclipse
> - we read the bundles and cache a bunch of values in the registry
> - values cached are English because the translations haven't been installed yet
> - then we process the dropins and install the translation bundle
> - Preference page values are shown in English
> - shut down
> - start up Eclipse
> - we check use the cached values so English is used again
> 
> If you start the workspace with -clean (on the second start and beyond; after
> the nls bundle has been installed) then you will see the correct behaviour.

This sounds more like bug230421 which should be fixed in 3.5 or later.  In bug285621 the workaround should have been to restart the platform.
Comment 3 Kit Lo CLA 2011-03-08 13:18:38 EST
I confirmed that restarting the workspace with -clean solved the problem.
Comment 4 Thomas Watson CLA 2011-03-10 11:31:11 EST
This is another flavor of bug230421.  The difference is that the fragment being added from dropins is providing nls files for another fragment attached to the same host.  The fix for bug230421 only checks if the fragment provides nls files for the host, not any of the other attached fragments.

This check is done in org.eclipse.core.internal.registry.osgi.EclipseBundleListener.checkForNLSFiles(Bundle, Bundle)

We can look for a proper fix for M7.
Comment 5 Thomas Watson CLA 2011-03-10 15:04:40 EST
Created attachment 190913 [details]
possible fix

This fixes the bug for me.  DJ can you give this a try and also review the fix?  Thanks.
Comment 6 Thomas Watson CLA 2011-03-14 16:30:14 EDT
Created attachment 191166 [details]
possible fix (w framework fix)

There is a bug in the framework that prevents the previous patch from working when you start with a freshly unzipped (never run) eclipse installation.  When you add the attached nls fragment to dropins and run eclipse for the first time the expected translations are still not present for the security preferences.

This is because the framework keeps a cache of manifest translation ResourceBundle objects for each bundle.  The cache for other attached fragments is not getting flushed when a newly attached fragment is resolved.  So when the registry tries to load the translation files it is reusing the empty translation files it tried to look up before the fragment was attached.  The fix is to flush the manifest localization cache for the other attached fragments.
Comment 7 DJ Houghton CLA 2011-03-15 11:23:46 EDT
Thanks, Tom. The patch looks good. And I've verified that it fixes both my test case as well as Kit's original test case (with the provided data).
Comment 8 Kit Lo CLA 2011-03-15 11:53:13 EDT
Will this be fixed in 4.1 automatically?
Comment 9 Thomas Watson CLA 2011-03-15 14:33:55 EDT
Patch released.

(In reply to comment #8)
> Will this be fixed in 4.1 automatically?

Equinox 3.7 (Indigo) feeds into both the 3.7 and 4.1 Eclipse Platform builds.  This will be fixed in both the 3.7 and 4.1 versions of the Eclipse Platform.
Comment 10 Thomas Watson CLA 2011-07-12 08:52:13 EDT
Note that the fix to this bug introduced bug350946.