| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
java
GettextResource.gettext, GettextResource.ngettext
ResourceBundle.getResource instead
xgettext -k_
MessageFormat.format "{1,number} {0,number}"
Before marking strings as internationalizable, uses of the string
concatenation operator need to be converted to MessageFormat
applications. For example, "file "+filename+" not found" becomes
MessageFormat.format("file {0} not found", new Object[] { filename }).
Only after this is done, can the strings be marked and extracted.
GNU gettext uses the native Java internationalization mechanism, namely
ResourceBundles. To convert a PO file to a ResourceBundle, the
msgfmt program can be used with the option --java or
--java2. To convert a ResourceBundle back to a PO file, the
msgunfmt program can be used with the option --java.
Two different programmatic APIs can be used to access ResourceBundles.
Note that both APIs work with all kinds of ResourceBundles, whether
GNU gettext generated classes, or other .class or .properties
files.
java.util.ResourceBundle API.
In particular, its getString function returns a string translation.
Note that a missing translation yields a MissingResourceException.
This has the advantage of being the standard API. And it does not require
any additional libraries, only the msgfmt generated .class
files. But it cannot do plural handling, even if the resource was generated
from a PO file with plural handling.
gnu.gettext.GettextResource API.
Reference documentation in Javadoc 1.1 style format is in the javadoc1 directory and in Javadoc 2 style format in the javadoc2 directory.
Its gettext function returns a string translation. Note that when
a translation is missing, the msgid argument is returned unchanged.
This has the advantage of having the ngettext function for plural
handling.
To use this API, one needs the libintl.jar file which is part of
the GNU gettext package and distributed under the LGPL.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |