[Jalview-discuss] Jalview and i18n
Andreas Prlic
ap3 at sanger.ac.uk
Fri Jul 11 11:13:43 BST 2008
Hi Jim,
A strategy for adding internationalization could be:
In Eclipse you can do "Externalize Strings" which can move String
declarations into external properties files. These properties files
can easily get translated into different languages (they are text
only) and they then carry different file names depending on the
language support they provide. This can then be used by Java
automatically to switch to the correct translation based on the Locale.
http://java.sun.com/docs/books/tutorial/i18n/index.html
An example in terms of source code, see below.
Hope that helps,
Cheers
Andreas
rather than doing
JButton button = new JButton("press here");
you would say
JButton button = new JButton (ResourceManager.getString
("org.jalview.button"));
where the resourcemanager looks like below:
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import java.util.logging.Logger;
public class ResourceManager {
private static final String BUNDLE_NAME = "jalview";
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle(BUNDLE_NAME);
public static Logger logger = Logger.getLogger
(JalviewDefaults.LOGGER);
private ResourceManager() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
logger.config(e.getMessage());
return '!' + key + '!';
}
}
}
and the jalview.properties file contains
org.jalview.button = press here
and since I am a german speaker here goes the german translation:
jalview_de_DE.properties has the content
org.jalview.button = hier drücken
(eventually the ResourceManager needs a few more lines of code to
check if the default locale is available as a translation and if not,
fall back to en_GB, I could help out with that, if needed...)
Cheers,
Andreas
On 9 Jul 2008, at 09:37, James Procter wrote:
> Hello Paul.
>
> Paul Pillot wrote:
>> I am a biology teacher for secondary education in France and would
>> like
>> to use Jalview with my students. I was wondering if there is any plan
>> for internationalization or if I should look into creating another
>> Jalview version through a translation of the code ?
> It would be best if the Jalview source did not fork into
> internationalized and 'en-only' versions. However, we have not
> explicitly planned for internationalization but it has been requested
> quite frequently, and would obviously be of great benefit!
>
> Now that Jalview development is slow, it may be a good time to think
> about doing this, but the transformation of the user interface code
> will
> have to be done by someone in their spare time. Are you familiar with
> any automated tools for creating and maintaining internationalization
> bundles ?
>
> Jim.
>
> --
> -------------------------------------------------------------------
> J. B. Procter (ENFIN/VAMSAS) Barton Bioinformatics Research Group
> Phone/Fax:+44(0)1382 388734/345764 http://www.compbio.dundee.ac.uk
> The University of Dundee is a Scottish Registered Charity, No.
> SC015096.
> _______________________________________________
> Jalview-discuss mailing list
> Jalview-discuss at jalview.org
> http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-discuss
-----------------------------------------------------------------------
Andreas Prlic Wellcome Trust Sanger Institute
Hinxton, Cambridge CB10 1SA, UK
+44 (0) 1223 49 6891
-----------------------------------------------------------------------
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
More information about the Jalview-discuss
mailing list