Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to set the Locale /Language (i18n) RCP application dynamically
How to set the Locale /Language (i18n) RCP application dynamically [message #461364] Wed, 10 January 2007 00:58 Go to next message
Eclipse UserFriend
Originally posted by: jayam.balasubramaniam.gmail.com

I have created an RCP application .To internationalize the application i externalized the strings and created a properties file ,for other language(for example German) i created a fragment project with properties files.When i pass the command line argument as -nl de or -nl fr the application start up in the corresponding language and all working fine.Now i want to set the locale dynamically, so i have created dialog asking the user to select the language when application starts. here all are working fine expect the Help--->About option and Perspective name is not getting changed (i.e.) it remains in English Language.
I tried these code to set the language
System.setProperty("osgi.nl",de); and this also
System.getProperties.put("osgi.nl",de); and
Locale.setDefault(Locale.German):


1.How i can change the language of the application dynamically?

2.We can restart the application and pass the argument,then how?

3.We can create another plugin having Language dialog and start this application plugin,Then how to integrate the plugins?

Please help me to resolve this.

Thanks,
Jai
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461370 is a reply to message #461364] Wed, 10 January 2007 04:01 Go to previous messageGo to next message
Eclipse UserFriend
You'll have to restart the application to get the changes -- the messages are bound in once during startup (at some point) and you won't be able to change them by setting a property in the same instance.

If you're supplying -nl on the command line, I don't know if it will be possible. However, if you set the property, then request the workbench restarted, there's a small chance it would work if it reuses the same VM. Don't know if it does, though.

Your application will need to return the PLATFORM_RESTART e.g. as follows:

http://help.eclipse.org/help32/topic/org.eclipse.platform.do c.isv/guide/rcp_define.htm

	public Object run(Object args) throws Exception {
		Display display = PlatformUI.createDisplay();
		try {
			int code = PlatformUI.createAndRunWorkbench(display,
					new BrowserAdvisor());
			// exit the application with an appropriate return code
			return code == PlatformUI.RETURN_RESTART
					? EXIT_RESTART
					: EXIT_OK;
		} finally {
			if (display != null)
				display.dispose();
		}
	}


Alex.
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461376 is a reply to message #461370] Wed, 10 January 2007 04:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jayam.balasubramaniam.gmail.com

Alex,
As you said the NL is a bootloader constant which is setup the default language English during startup. If we restart the application using EXIT_RESTART againg it is taking the default language.
So how we can pass/set the(desired language)argument and restart the application?

Thanks for your respones
jai
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461382 is a reply to message #461376] Wed, 10 January 2007 04:50 Go to previous messageGo to next message
Eclipse UserFriend
One way would be to re-write the config.ini or app.ini and then do a restart. You could look for a line beginning with -nl.* and replace it with -nl fr (or whatever). I don't know if there's a cleaner way -- the platform args are read only, and I don't know if there's a way of changing them.

The other approach would be to try and stop/start the bundles yourself; however, in 3.2 that can have some side effects that you wouldn't otherwise want. In 3.3, there's a stop/start(TRANSIENT) that you could use, but that's probably of little use.

Alex.
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461512 is a reply to message #461382] Wed, 10 January 2007 23:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jayam.balasubramaniam.gmail.com

Alex,
I couldn't find the -nl.* setting in config.ini .These are the content of the config.ini file

<i>osgi.bundles=reference\:file\:C\:/eclipse/plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar@2file \:C\:/eclipse/plugins/org.eclipse.ui.workbench_3.2.1.M200609 06-0800.jar
osgi.bundles.defaultStartLevel=4
osgi.install.area=file\:C\:\\eclipse
osgi.framework=file\:C\:/eclipse/plugins/org.eclipse.osgi_3. 2.1.R32x_v20060919.jar
osgi.configuration.cascaded=false</i>

Can i modify the config.ini file by adding the line
osgi.nl=fr to it and restart the application

And i also want to set the Perspectives Name through code,if that is possible i will solve my problem to some extend.
1. Could u please tell me how to <b>change the Perspective Name</b> through code and not through MANIFEST.MF(i can change here).
2. How to <b>integrate the plugins</b>?

Thanks a lot for your valuable information,
Jai
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461514 is a reply to message #461512] Thu, 11 January 2007 01:32 Go to previous messageGo to next message
Eclipse UserFriend
You can do either:

a) Set osgi.nl=fr in the config.ini
b) Set -nl fr in the eclipse.ini (before the -vmargs, on a separate line)

The config.ini may be shared between multiple apps in the same installed location, whereas each will have their own eclipse.ini. So it might be nicer to change the config.ini; that way, if the user were to start up a 2nd app in the same location, they'd see the new language too.

I'm not sure that you can change the perspective name through code. However, if you have %name in the Manifest, and a plugin.properties with name=The Perspective, then you can supply a plugin.properties_fr name=La Perspective and the translation is done then. Same goes for any other text item in the manifest/plugin.xml.

Alex.
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461515 is a reply to message #461514] Thu, 11 January 2007 02:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jayam.balasubramaniam.gmail.com

Alex,
I set the values in config.ini and eclipse.ini but i couldn't get the result.Now i give you the summary what we have did till now
<i>Our requirement</i> : <b>To Dynamically change the locale/language of an RCP application</b>
Our application is simple UI and has menus,Perspectives,views, labels,buttons and table.
Steps Tried :
1.Set the System Property "osgi.nl"=fr
<b>Result</b>-the Property has been set but it is not affecting the application.
2.Restarted the application after setting the Locale.setDefault(Locale.French) & Locale.setProperty("osgi.nl","fr")
<b>Result</b>-While restarting the default language English has been set
3.Edit the config.ini file and appended the osgi.nl=fr
<b>Result</b>-It has no effect
4.Edit the eclipse.ini file and added the -nl fr before the -vmargs, on a separate line
<b>Result</b>-It has no effect

If i pass the command line argument(language) all are working fine.(help-> about and Perspective names all are getting changed)

Please suggest me what i can do if user what to select the language when he login to the application?

Thanks,
jai
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461521 is a reply to message #461515] Thu, 11 January 2007 05:25 Go to previous messageGo to next message
Eclipse UserFriend
Maybe the .ini files aren't re-read during platform restart, then. I'm out of ideas...

The other solution is to write your own Java launcher that invokes EclipseStarter.main; that way, you can prompt for the language in your code (and set the osgi.nl property) prior to starting Eclipse.

Alex.

NB starting up a UI, like AWT, is not necessarily a good thing in the same process, because of potential thread issues.
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461526 is a reply to message #461521] Thu, 11 January 2007 06:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jayam.balasubramaniam.gmail.com

Alex,

Really you are making me a good learner, thanks!

I read the article from this link it is very useful
http://www.eclipsezone.com/articles/eclipse-vms/?source=arch ives

If i change the eclipse.ini which is in the eclipse source folder ,it is changing the eclipse.(the Eclipse IDE is getting changed to the corresponding language)

But my application is not having the eclipse.ini where i can make this entry so that it will change my application .

I made my application as a product their also i couldn't find eclipse.ini. Is eclipse.ini and eclipse.inf are same?

I changed the config.ini but it is changing, not completely

Thanks,
jai
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461528 is a reply to message #461526] Thu, 11 January 2007 06:55 Go to previous messageGo to next message
Eclipse UserFriend
If you have a product called 'alex' then the initialisation file will be called 'alex.ini'. Config.ini is always the same name, though.

What other .ini files are there? Have a look for one that contains '-vmargs' -- that will be the file you need to change.

Alex.
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461897 is a reply to message #461528] Thu, 18 January 2007 02:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jayam.balasubramaniam.gmail.com

Alex,

In eclipse product i made an entry "osgi.nl=fr" in Config.ini file and started the eclipse,it starts in French.
Similarly in myproduct i made the same entry "osgi.nl=fr" in Config.ini file and started the my product,it starts in French.The perspective name are getting changed but it is displaying the externalizing string i.e key like %perspective.name ,the corresponding plugin_xx.properties files are in fragement project.

Is their any folder structure to place the plugin_XX.properties files and about.properties files ?
Is this may be the problem?

Thanks,
jai
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #461915 is a reply to message #461897] Thu, 18 January 2007 05:15 Go to previous messageGo to next message
Eclipse UserFriend
The plugin name is internationalised inthe plugin.properties files, so plugin_fr.properties would be what I'd expect it would look for. Is it definitely being included in the fragment? When you export it, open the Jar up -- it might be that (e.g.) your bin.includes doesn't include the *.properties files, and that whilst it's in the source, it's never in the built fragment.

The other thing would be to start with the OSGi console (eclipse.exe -noExit -console) and using 'ss' to show the status of plugins; the fragment may not be being installed.

Alex.
Re: How to set the Locale /Language (i18n) RCP application dynamically [message #463990 is a reply to message #461514] Wed, 21 February 2007 12:30 Go to previous message
Eclipse UserFriend
I couldn't get the following to work
-nl fr_CA all on one line in eclipse.ini

but this DOES work
-nl
fr_CA
with each element on a separate line

"Alex Blewitt" <alex_blewitt@yahoo.com> wrote in message
news:28610097.1168497209642.JavaMail.root@cp1.javalobby.org...
> You can do either:
>
> a) Set osgi.nl=fr in the config.ini
> b) Set -nl fr in the eclipse.ini (before the -vmargs, on a separate line)
>
> The config.ini may be shared between multiple apps in the same installed
> location, whereas each will have their own eclipse.ini. So it might be
> nicer to change the config.ini; that way, if the user were to start up a
> 2nd app in the same location, they'd see the new language too.
>
> I'm not sure that you can change the perspective name through code.
> However, if you have %name in the Manifest, and a plugin.properties with
> name=The Perspective, then you can supply a plugin.properties_fr name=La
> Perspective and the translation is done then. Same goes for any other text
> item in the manifest/plugin.xml.
>
> Alex.
Previous Topic:enhanced MessageConsole ?
Next Topic:IFolderLayout persistance
Goto Forum:
  


Current Time: Thu Mar 27 13:39:27 EDT 2025

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

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

Back to the top