Bug 388468 - Wrong translation due to SWTException InvalidThreadAccess in SessionLocaleProvider
Summary: Wrong translation due to SWTException InvalidThreadAccess in SessionLocalePro...
Status: RESOLVED INVALID
Alias: None
Product: RAP
Classification: RT
Component: Workbench (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2012-08-30 14:33 EDT by Markus Krüger CLA
Modified: 2012-10-07 12:14 EDT (History)
1 user (show)

See Also:


Attachments
The app (10.23 KB, application/x-zip-compressed)
2012-08-30 14:33 EDT, Markus Krüger CLA
no flags Details
Updated test app (against RAP 2.0) (27.81 KB, application/octet-stream)
2012-10-04 04:38 EDT, Ivan Furnadjiev CLA
no flags Details
Screenshot (59.95 KB, image/png)
2012-10-04 06:40 EDT, Ivan Furnadjiev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Krüger CLA 2012-08-30 14:33:36 EDT
Created attachment 220529 [details]
The app

We have some problems with translations in our application, but also in the attached standalone example we have build.

Our target platform contains everthing needed for RAP plus the nl_de fragments from the babel project.

On a our computers we have installed Windows 7 and XP with in German language.

If our browsers (mostly IE 7+8+9, but also FireFox) are set to German language, everthing works fine.

The problem is, that if we switch the browsers to English language all text that should be translated in a plugin.xml file are still displayed in German language.

We tried all combinations of setting "-Declipse.registry.MultiLanguage=true" and "-registryMultiLanguage". No changes.

Debugging the code the class "org.eclipse.rap.ui.internal.SessionLocaleProvider" always throws an SWTException InvalidThreadAccess when calling "RWT.getLocale()". This way it allways falls back to system default, which is German.

There is also no difference in using Application or EntryPoint.
Comment 1 Ivan Furnadjiev CLA 2012-10-01 09:43:31 EDT
Markus, in the attached example the plugin.xml is not localized - all texts are in English, plugin.properties is missing..... Could you check the attached project again? If you want to get a localized message from a background thread, you must wrap your code in UICallBack#runNonUIThreadWithFakeContext
Comment 2 Markus Krüger CLA 2012-10-03 23:51:44 EDT
Sorry, I forgot to mention that even the dialog button of the dialog that pops up in the entry point are not translated. They are still german. That's why I did not include anything to translate in the attached project.
Comment 3 Ivan Furnadjiev CLA 2012-10-04 02:32:53 EDT
Markus, if your OS language is German... the default resource bundle will be German. Without English resource bundle (*_en.properties file) it will always fallback to the default (German in your case). On my English Windows 7 machine I don't see any German texts in your snippet. That's why I was asking about a correct localized project(s) that demonstrate the problem (including the InvalidThreadAccess exception). For me the localization is working fine. As I mentioned in comment#1, getting a localized text from a background thread requires UICallBack#runNonUIThreadWithFakeContext (WorkbenchMessages#get( display ) is a good example about it).
Comment 4 Markus Krüger CLA 2012-10-04 03:43:15 EDT
As stated in the description we use the RAP target platform that includes the english messages for the JFACE dialog PLUS the nl_de fragments from the babel project. Using this combined target platform we have english and german resources in our system. So JFACE dialog buttons should translate correctly, but they do not as the SessionLocaleProvider always uses the system language as fallback in case of exception.
Comment 5 Ivan Furnadjiev CLA 2012-10-04 03:57:07 EDT
Markus, how to provoke the InvalidThreadAccess exception in org.eclipse.rap.ui.internal.SessionLocaleProvider class with the attached project?
Comment 6 Markus Krüger CLA 2012-10-04 04:26:57 EDT
I get these while application is starting investigated with a debug point.
Comment 7 Markus Krüger CLA 2012-10-04 04:27:35 EDT
Although I don't know if this is the cause why the JFACE dialog buttons are not translated correctly. It was just a guess.
Comment 8 Ivan Furnadjiev CLA 2012-10-04 04:38:37 EDT
Created attachment 221879 [details]
Updated test app (against RAP 2.0)

Markus, I did some modifications to your original application in order to properly localize it. The attach project works fine for me - changing browser language changes view part title English <-> German. Please comment?
Comment 9 Markus Krüger CLA 2012-10-04 05:28:07 EDT
Using your App the view Tab is always "German", even when I open the browser on an english VM, probably since my system where the server is running still is german.
Comment 10 Ivan Furnadjiev CLA 2012-10-04 05:42:17 EDT
(In reply to comment #9)
> Using your App the view Tab is always "German", even when I open the browser
> on an english VM, probably since my system where the server is running still
> is german.

Markus, you have to change the browser preferred language - in Firefox it is: Options -> Content -> Languages... Probably you have only German there.
Comment 11 Markus Krüger CLA 2012-10-04 06:06:38 EDT
Sorry, I forgot to add "-Declipse.registry.MultiLanguage=true" to the launchconfig for your project. The view Tab is now translated correctly, but if I click the big button, the dialog buttons are still always german. I now use RAP 2.0M1 with the bable tranlations as target platform.
Comment 12 Ivan Furnadjiev CLA 2012-10-04 06:40:18 EDT
Created attachment 221885 [details]
Screenshot

(In reply to comment #11)
> Sorry, I forgot to add "-Declipse.registry.MultiLanguage=true" to the
> launchconfig for your project. The view Tab is now translated correctly, but if
> I click the big button, the dialog buttons are still always german. I now use
> RAP 2.0M1 with the bable tranlations as target platform.
I've tried again with babel translation bundles (org.eclipse.babel.nls_rt.rap_de_3.7.0.v20120721081147) and buttons are translated too (see the attached image). My setup is the opposite - default language (OS) English, Babel translations - German.
Comment 13 Markus Krüger CLA 2012-10-04 07:57:12 EDT
Your setup was a good hint. I have now installed eclipse and all stuff needed to test it on an english VM. And in this environment everything works as expected, so it must have something to do with the default OS. Copying the same eclipse directory with workspace back to my german OS still causes the wring translations in the dialog.
Comment 14 Ivan Furnadjiev CLA 2012-10-04 08:17:25 EDT
(In reply to comment #13)
> Your setup was a good hint. I have now installed eclipse and all stuff
> needed to test it on an english VM. And in this environment everything works
> as expected, so it must have something to do with the default OS. Copying
> the same eclipse directory with workspace back to my german OS still causes
> the wring translations in the dialog.

I think that's because of missing *_en.properties translations. When your OS is German one, German is used as default locale/fallback (*_de.properties). As resource bundles in RAP has no language abbreviation (*.properties), they are not recognized as English translation and it's considered as missing English translation - fallback to default (*_de.properties from babel). I think in your case you need valid nl_en fragments (*_en.properties files).
Comment 15 Markus Krüger CLA 2012-10-04 08:26:31 EDT
Sounds logical to me. Do you know where to get the *_en.property files? Babel only gives me Canadian and Austrialian bundles.
Comment 16 Ivan Furnadjiev CLA 2012-10-04 08:41:05 EDT
(In reply to comment #15)
> Sounds logical to me. Do you know where to get the *_en.property files? Babel
> only gives me Canadian and Austrialian bundles.
No... But I think it's not so hard to extract the properties files from RAP runtime, rename them to *_en.properties and create the en fragments. More over, you have a list of properties files from Babel German translations. But Markus... all these discussions has nothing to do with the original subject of the bug - SWTException InvalidThreadAccess in SessionLocaleProvider. Do you still think that the bug is valid or we could close it as INVALID?
Comment 17 Markus Krüger CLA 2012-10-04 09:16:15 EDT
Might be invalid since my debugging stopped in the fallback while starting the application, so I thought that might be the problem.
Comment 18 Ivan Furnadjiev CLA 2012-10-04 10:26:57 EDT
(In reply to comment #17)
> Might be invalid since my debugging stopped in the fallback while starting the
> application, so I thought that might be the problem.
Closed as INVALID. Please reopen if you disagree.
Comment 19 Markus Krüger CLA 2012-10-07 12:14:11 EDT
Just an additional information to all that might run into the same problem.

You only need to start RAP with commandline parameter "-nl en_US" and Java System property "-Declipse.registry.MultiLanguage=true". This was you tell the system tu use en_US as default language and since this is not found in the system it will fall back to plugin.properties or messages.properties. So no redundant files plugin_En.properties or messages_en.properties are needed.