both are described below
if(I18NPlug.jumpi18n == true){
//do something
}
else{
//do something else
}
The updates done in November 2007 for the I18N class supports different resource files for plug-ins.
To use it in your plug-ins you will need to do the following, assuming
your plug-in is in the package com.foo.jump.bar
The new code uses the plug-in classloader so it should be able to find the resource bundle as long as you don’t use your own classloader.
Holger suggests 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 "";
}
}
}