<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ojwiki.soldin.de/index.php?action=history&amp;feed=atom&amp;title=How_to_use_i18n_Internationalization</id>
	<title>How to use i18n Internationalization - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ojwiki.soldin.de/index.php?action=history&amp;feed=atom&amp;title=How_to_use_i18n_Internationalization"/>
	<link rel="alternate" type="text/html" href="https://ojwiki.soldin.de/index.php?title=How_to_use_i18n_Internationalization&amp;action=history"/>
	<updated>2026-04-19T09:09:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://ojwiki.soldin.de/index.php?title=How_to_use_i18n_Internationalization&amp;diff=330&amp;oldid=prev</id>
		<title>Mentaer: Created page with &#039;== Introduction ==  There exists 2 ways for internationalizing the user interface. * a) using the i18n classes * b) using the resource bundle classes  both are described below  =…&#039;</title>
		<link rel="alternate" type="text/html" href="https://ojwiki.soldin.de/index.php?title=How_to_use_i18n_Internationalization&amp;diff=330&amp;oldid=prev"/>
		<updated>2009-10-18T22:03:40Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;== Introduction ==  There exists 2 ways for internationalizing the user interface. * a) using the i18n classes * b) using the resource bundle classes  both are described below  =…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
There exists 2 ways for internationalizing the user interface.&lt;br /&gt;
* a) using the i18n classes&lt;br /&gt;
* b) using the resource bundle classes&lt;br /&gt;
&lt;br /&gt;
both are described below&lt;br /&gt;
&lt;br /&gt;
== Internationalization with i18n ==&lt;br /&gt;
&lt;br /&gt;
* For internationalization an additional class &amp;lt;b&amp;gt;I18NPlug.java&amp;lt;/b&amp;gt; is needed.&lt;br /&gt;
* Further the name and the path of a language properties file, containing the translation, has to be defined.&lt;br /&gt;
* To allow international plugins to work also with JUMP (not only OpenJump) a case selection should be made in the &amp;lt;b&amp;gt;#initialize()&amp;lt;/b&amp;gt; method. Therefore use the expression: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(I18NPlug.jumpi18n == true){&lt;br /&gt;
  //do something&lt;br /&gt;
}&lt;br /&gt;
else{&lt;br /&gt;
  //do something else&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For more details see [[Example plugin for internationalization]]&lt;br /&gt;
&lt;br /&gt;
== Since OpenJUMP nightly built Nov. 2007 ==&lt;br /&gt;
&lt;br /&gt;
The updates done in November 2007 for the I18N class supports different resource files for plug-ins.&lt;br /&gt;
&lt;br /&gt;
To use it in your plug-ins you will need to do the following, assuming&lt;br /&gt;
your plug-in is in the package com.foo.jump.bar&lt;br /&gt;
&lt;br /&gt;
* 1 - Create a language package in the resource directory of you source for your resource bundles. Using MAVEN the directory would be src/main/resources/com/foo/jump/bar/language&lt;br /&gt;
* 2 - Add the jump.properties file (and other language files) into the directory created in 1&lt;br /&gt;
* 3 - Use the method &amp;#039;&amp;#039;I18N.getText(&amp;quot;com.foo.jump.bar&amp;quot;,&amp;quot;com.foo.jump.bar.MyPlugin.some-text-key&amp;quot;)&amp;#039;&amp;#039; in your plugin to get the I18Nized text&lt;br /&gt;
* 4 - Make sure when you build your jar file the whole directory tree under src/main/resources is copied to the jar file. With MAVEN this is done for you.&lt;br /&gt;
&lt;br /&gt;
The new code uses the plug-in classloader so it should be able to find the resource bundle as long as you don&amp;#039;t use your own classloader.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using Resource Bundle Class ==&lt;br /&gt;
&lt;br /&gt;
Holger suggests to use the ResourceBundle- Class (Java Standard). This works with all versions of JUMP. Here the is the Hello World Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package example;&lt;br /&gt;
&lt;br /&gt;
import com.vividsolutions.jump.workbench.plugin.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
&lt;br /&gt;
public class MyInternational&lt;br /&gt;
    extends AbstractPlugIn&lt;br /&gt;
{&lt;br /&gt;
  // this is the path to the propertie- files&lt;br /&gt;
  //    myinternational.properties       = language not suported&lt;br /&gt;
  //    myinternational_de.properties    = german&lt;br /&gt;
  //    myinternational_en.properties    = english&lt;br /&gt;
  //    etc.&lt;br /&gt;
   &lt;br /&gt;
  String basename = &amp;quot;example.resources.myinternational&amp;quot;;&lt;br /&gt;
  ResourceBundle res;&lt;br /&gt;
&lt;br /&gt;
  public MyInternational()&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void initialize(PlugInContext context) throws Exception&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    res = ResourceBundle.getBundle(basename);&lt;br /&gt;
    &lt;br /&gt;
    // example &lt;br /&gt;
    System.out.println(getString(&amp;quot;Text1&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
    context.getFeatureInstaller().addMainMenuItem(this,&lt;br /&gt;
                                                  new String[]&lt;br /&gt;
                                                  {getString(&amp;quot;Tools&amp;quot;),&lt;br /&gt;
                                                  getString(&amp;quot;MyPlugins&amp;quot;)},&lt;br /&gt;
                                                  getName(), false, null, null);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public boolean execute(PlugInContext context) throws Exception&lt;br /&gt;
  {&lt;br /&gt;
    context.getWorkbenchFrame().getOutputFrame().createNewDocument();&lt;br /&gt;
    context.getWorkbenchFrame().getOutputFrame().addText(getString(&amp;quot;Hallo&amp;quot;));&lt;br /&gt;
    context.getWorkbenchFrame().getOutputFrame().surface();&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public String getName()&lt;br /&gt;
  {&lt;br /&gt;
    return getString(&amp;quot;Name&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  private String getString(String s)&lt;br /&gt;
  {&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      return res.getString(s);&lt;br /&gt;
    }&lt;br /&gt;
    catch (MissingResourceException ex)&lt;br /&gt;
    { // no entry &lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
      return &amp;quot;&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    catch (Exception ex)&lt;br /&gt;
    { // no resource file&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
      return &amp;quot;&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mentaer</name></author>
	</entry>
</feed>