Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Language selection for user session
Language selection for user session [message #734379] Fri, 07 October 2011 14:58 Go to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 34
Registered: July 2009
Member
Hello,

according to documentation RAP is supposed to select one of the request languages of the browser in the prefered order

Web browsers allow users to set their preferred languages and they pass those preferences in an Accept-Language HTTP header with every request. RAP tries to select one of the requested languages in the preferred order and if this is not possible, it uses the default locale as fallback. The default locale can be set by adding the system property user.language to the launch configuration. If no matching properties file can be found, the default one (messages.properties) takes precedence.

It seems that it does not work like this, RAP tries only the first defined language.

In order to be compliant to documentation RWT.getLocale should use ServletRequest.getLocales instead of ServletRequest.getLocale
There should be some configuration to give to RAP to define supported locales (similar to <locale-config/> in JSF), and RWT.getLocale should iterates through the enumeration of locales, to find the first locale also define in the configured list and take this one.

Does it make sense ? or am I missing something ?

Regards,
Arnaud
Re: Language selection for user session [message #735358 is a reply to message #734379] Tue, 11 October 2011 15:03 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
Arnaud,

I could imagine that managing a list of available languages
(translations) in a pluggable environment like OSGi can become tricky.
I.e if plug-ins contribute messages but lack the translations that are
specified as available elsewhere. Or the other way round, translations
are provided from elsewhere but the list of available translations does
not list them.

Please feel free to open an enhancement request to discuss this with the
rest of the RAP team.

As far as I understand, you could also solve the problem in application
code. Say you have translations for es, fr and en and the browser tells
that it understands fr and en (via ServletRequest#getLocales()). As you
suggested, you could then match the browsers locales against the
available ones and use RWT#setlocale() to set the closest match for the
current session.
If you want to allow to change the language while the session runs, you
would have to execute this code with each request (i.e. in a phase
listener).

What do you think?

Regards,
Rüdiger


On 07.10.2011 16:58, Arnaud MERGEY wrote:
> Hello,
>
> according to documentation RAP is supposed to select one of the request
> languages of the browser in the prefered order
> Web browsers allow users to set their preferred languages and they pass
> those preferences in an Accept-Language HTTP header with every request.
> RAP tries to select one of the requested languages in the preferred
> order and if this is not possible, it uses the default locale as
> fallback. The default locale can be set by adding the system property
> user.language to the launch configuration. If no matching properties
> file can be found, the default one (messages.properties) takes precedence.
>
> It seems that it does not work like this, RAP tries only the first
> defined language.
>
> In order to be compliant to documentation RWT.getLocale should use
> ServletRequest.getLocales instead of ServletRequest.getLocale
> There should be some configuration to give to RAP to define supported
> locales (similar to <locale-config/> in JSF), and RWT.getLocale should
> iterates through the enumeration of locales, to find the first locale
> also define in the configured list and take this one.
>
> Does it make sense ? or am I missing something ?
>
> Regards,
> Arnaud
--
Rüdiger Herrmann

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Language selection for user session [message #735367 is a reply to message #735358] Tue, 11 October 2011 15:42 Go to previous messageGo to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 243
Registered: March 2010
Location: France
Senior Member
Hello Rüdiger

Thanks for the reply, I start the post here, because of the RAP documentation

RAP tries to select one of the requested languages in the preferred order

I just wanted to know how it is supposed to work, either the documentation is wrong, RAP is supposed to work as today, and in this case choosing requested languages in the prefered order can be done by the application like you say, either RAP itself is supposed to choose one of the browser languages, so in this case there is a bug.
So my proposal to solve this bug could be to do something similar than JSF (as I tried to explain in my initial post)

If you think it is a bug I can open one (and I could probably find some time to propose a patch to fix it).
If you think it is not a bug, it perfectly makes sense for me to solve this according to your suggestion (but the documentation should probably be fixed)

Regards,
Arnaud

[Updated on: Tue, 11 October 2011 15:43]

Report message to a moderator

Re: Language selection for user session [message #735378 is a reply to message #735358] Tue, 11 October 2011 15:42 Go to previous messageGo to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 34
Registered: July 2009
Member
Hello Rüdiger

Thanks for the reply, I start the post here, because of the RAP documentation

RAP tries to select one of the requested languages in the preferred order

I just wanted to know how it is supposed to work, either the documentation is wrong, RAP is supposed to work as today, and in this case choosing requested languages in the prefered order can be done by the application like you say, either RAP itself is supposed to choose one of the browser languages, so in this case there is a bug.
So my proposal to solve this bug could be to do something similar than JSF, as I propose in my first post.

If you think it is a bug I can open one (and I could probably find some time to propose a patch to fix it).
If you think it is not a bug, it perfectly makes sense for me to solve this according to your suggestion (but the documentation should probably be fixed)

Regards,
Arnaud
Re: Language selection for user session [message #735772 is a reply to message #735367] Wed, 12 October 2011 17:13 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
Hi Arnaud,

I would prefer to fix the documentation. Only, I am afraid I cannot find
what documentation is misleading. Could you give me a pointer and
propose what should be changed?

TIA
Rüdiger


On 11.10.2011 17:42, Arnaud MERGEY wrote:
> Hello Rüdiger
>
> Thanks for the reply, I start the post here, because of the RAP
> documentation
>
> RAP tries to select one of the requested languages in the preferred order
>
> I just wanted to know how it is supposed to work, either the
> documentation is wrong, RAP is supposed to work as today, and in this
> case choosing requested languages in the prefered order can be done by
> the application like you say, either RAP itself is supposed to choose
> one of the browser languages, so in this case there is a bug.
> So my proposal to solve this bug could be to do something similar than
> JSF, as I propose in my first post.
>
> If you think it is a bug I can open one (and I could probably find some
> time to propose a patch to fix it).
> If you think it is not a bug, it perfectly makes sense for me to solve
> this according to your suggestion (but the documentation should probably
> be fixed)
>
> Regards,
> Arnaud
>
>
--
Rüdiger Herrmann

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Language selection for user session [message #735779 is a reply to message #735772] Wed, 12 October 2011 17:23 Go to previous messageGo to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 243
Registered: March 2010
Location: France
Senior Member
You can find it here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Fadvanced%2Finternationalization.html

At the end How does RAP select the language for a user session?
Re: Language selection for user session [message #739271 is a reply to message #735779] Mon, 17 October 2011 09:31 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
361113: [Documentation] Revise documentation for internationalization
https://bugs.eclipse.org/bugs/show_bug.cgi?id=361113

On 12.10.2011 19:23, Arnaud MERGEY wrote:
> You can find it here:
> http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Fadvanced%2Finternationalization.html
>
>
> At the end How does RAP select the language for a user session?

--
Rüdiger Herrmann

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Language selection for user session
Next Topic:Problem selecting by moue in Combo
Goto Forum:
  


Current Time: Thu Apr 25 16:54:38 GMT 2024

Powered by FUDForum. Page generated in 0.03503 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top