Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347121

Summary: [Help] Help System is displaying in different locale (when the browser is set to English)
Product: [Eclipse Project] Platform Reporter: Snehasish Paul <snehpaul>
Component: User AssistanceAssignee: platform-ua-inbox <platform-ua-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: cgold, snehpaul
Version: 4.1   
Target Milestone: 3.8 M3   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
WebappResources.java from Vivian none

Description Snehasish Paul CLA 2011-05-25 05:12:08 EDT
Build Identifier: 3.6.2

Observed that when we deploy a help.war in a web server (Tomcat) in Japanese OS machine, ResourceBundle returns resource string properly for all locales, except English.

When browser locale is set to English and OS locale is something else (say Japanese), we try to read strings using ResourceBundle [org.eclipse.help.internal.webapp.WebappResources.getString(String, Locale)], it returns Japanese, not English. It returns all other locale strings correctly.

This works good for Eclipse client, only issue when deployed as help.war in a web server in a non-English OS. I used a Linux box, not sure if problem exists for windows environment.

For English OS, all works well. So I am able to resolve the issue by setting the default locale configuration to English: osgi.nl=en in the help.war.


Reproducible: Always
Comment 1 Snehasish Paul CLA 2011-05-25 05:19:04 EDT
Created attachment 196520 [details]
WebappResources.java from Vivian

>> Comments from Vivian

Hi Chris,

We do observe this problem, ResourceBundle.getBundle(String baseName,  Locale locale) doesn't return exact bundle, so we rewrite the method in WebappResources class.

Please have a try to verify whether it fix the problem.

Notice: If using this method, WebappResource.properties should be moved to org.eclipse.help.webapp/src

Best Regards,
Vivian (Zhang Hao)
Comment 2 Chris Goldthorpe CLA 2011-10-06 13:48:42 EDT
Snehashish, can you give more information on the circumstances under which this occurs:

You said that the default language is English, and the OS language of the server was Japanese and that Japanese strings were displayed

What was the OS and locale of the client and which browser were they using?
Comment 3 Chris Goldthorpe CLA 2011-10-07 19:44:04 EDT
I can reproduce the problem now.

The rules for displaying resources fro an infocenter should work as follows:

1. Determine the clients locale from the HttpRequest
2. Search for a resource bundle corresponding to that locale.
3. If a resource bundle for that locale is found use it, otherwise use the default bundle.

The scenario where the webapp gets this wrong is where

1. The clients locale ( cl ) is one for which no file WebappResources_cl.properties does not exist in any bundle.
2. The webapp is hosted on a server with locale sl and WebappResources_sl.properties is found.

In your example cl is "en" and sl is "ja"

In order to debug the problem on a system running the "en" locale create a fragment for org.eclispe.help.webapp which contains the properties file /org/eclipse/help/internal/webapp/WebappResources_en.properties, this should contain the resources for some language other than English, do not install any other language fragments. Launch the infocenter and open help/index.jsp?lang=fr.
Expected result: the default resources are used.
Actual result: the resources are read from WebappResources_en.properties, and the labels appear in whatever language you used to create that file.
Comment 4 Chris Goldthorpe CLA 2011-10-07 20:08:13 EDT
I have reviewed Vivian's patch and it is good. I will change it slightly so that WebappResources.properties does not have to move and then commit.
Comment 5 Chris Goldthorpe CLA 2011-10-10 16:03:36 EDT
I have committed to master Vivian's patch with the modification to pick up WebappResources.properties from the usual location. The commit message is:

Bug 347121 - [Help] Help System is displaying in different locale (when the browser is set to English)

Snehashish, can you verify that this fixes the problem.
Comment 6 Snehasish Paul CLA 2011-10-12 05:53:09 EDT
(In reply to comment #5)
> Snehashish, can you verify that this fixes the problem.

Chris, I tested with the latest changes in org.eclipse.help.webapp/../WebappResources.java. It's working as expected.
Thanks for the update.
- Snehasish