Here is an example plugin that shows how internationalization can be done: myhelloi18nplugin.jar
It does also contain the source code (rename the ending to zip to get the source files).
One may also help to have a look on the corresponding Eclipse project (eclipsehelloi18.zip – to have a look on it use \file\import\.. existing project into workspace).
Showing changes from revision #1 to #2:
Added | Removed
Here is an additional class I18NPlug.java is needed.
if(I18NPlug.jumpi18n == true){
//do something
}
else{
//do something else
}
It does also contain the source code (rename the ending to zip to get the source files). It files).
One may also help to have a look on the corresponding Eclipse project (eclipsehelloi18.zip – to have a look on it use \file\import\.. existing project into workspace).
Don’t use I18NPlug-class. I think it is better to use the ResourceBundle- Class (Java Standard). This works with all versions of JUMP. Here the is the Hello World Example:
package example;
import com.vividsolutions.jump.workbench.plugin.*;
import java.util.*;
public class MyInternational
extends AbstractPlugIn
{
// this is the path to the propertie- files
// myinternational.properties = language not suported
// myinternational_de.properties = german
// myinternational_en.properties = english
// etc.
String basename = "example.resources.myinternational";
ResourceBundle res;
public MyInternational()
{
}
public void initialize(PlugInContext context) throws Exception
{
res = ResourceBundle.getBundle(basename);
// example
System.out.println(getString("Text1"));
context.getFeatureInstaller().addMainMenuItem(this,
new String[]
{getString("Tools"),
getString("MyPlugins")},
getName(), false, null, null);
}
public boolean execute(PlugInContext context) throws Exception
{
context.getWorkbenchFrame().getOutputFrame().createNewDocument();
context.getWorkbenchFrame().getOutputFrame().addText(getString("Hallo"));
context.getWorkbenchFrame().getOutputFrame().surface();
return true;
}
public String getName()
{
return getString("Name");
}
private String getString(String s)
{
try
{
return res.getString(s);
}
catch (MissingResourceException ex)
{ // no entry
ex.printStackTrace();
return "";
}
catch (Exception ex)
{ // no resource file
ex.printStackTrace();
return "";
}
}
}