Jalview i18n
The jalview.util.MessageManager class is a wrapper class for the ResourceBundle class. It provides dynamic language/locale support for individual users, and is recommended for all Jalview code.
To use it within your code, you only have to invoke MessageManager with the text key in Messages_xx.properties:
JButton ok = new JButton(MessageManager.getString("button.ok"));
This will set JButton text to the one included at button.ok key. In English JButton text will be OK, while in Spanish will be Aceptar. This is the big thing of i18n. :)
Don't use this type of coding:
threshold.addItem("No Threshold");
threshold.addItem("Above Threshold");
threshold.addItem("Below Threshold");
[...]
if (threshold.getSelectedItem().equals("Above Threshold"))
{
aboveThreshold = AnnotationColourGradient.ABOVE_THRESHOLD;
}
else if (threshold.getSelectedItem().equals("Below Threshold"))
{
aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD;
}
Once text has been translated, these equals will fail as the label won't be the English ones. It should be used getSelectedIndex() instead of getSelectedItem(). If you do the proper way, the code will look like this:
threshold.addItem(MessageManager.getString("label.threshold_feature_no_thereshold"));
threshold.addItem(MessageManager.getString("label.threshold_feature_above_thereshold"));
threshold.addItem(MessageManager.getString("label.threshold_feature_below_thereshold"));
[...]
if (threshold.getSelectedIndex()==1)
{
aboveThreshold = AnnotationColourGradient.ABOVE_THRESHOLD;
}
else if (threshold.getSelectedIndex()==2)
{
aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD;
}
Anyone interested in localizing/translating Jalview is strongly encouraged to join the Jalview Development List list. We would recommend that you read this entire page before proceeding.
If you are planning on working on a Jalview translation, please send us an email (Jalview Development List). There may be someone else already working on translating Jalview to your target language.
Once you have downloaded the source code (available at http://www.jalview.org/download), you must edit {jalview.home}/resources/lang/Messages_xx.properties, where xx refers to your language country code. If it doesn't exits, rename Messages.properties to Messages_xx.properties.
Next step...start transtalation!
Once you have it translated, we would appreciate if you contribute it forwarding the file to Jalview Development List. We will commit it to the code base as soon as possible. Thanks so much for this in advance!