<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <!--NewPage--> <html> <head> <!-- Generated by javadoc on Sat Nov 03 18:12:01 CET 2001 --> <title> Class gnu.gettext.GettextResource </title> </head> <body> <a name="_top_"></a> <pre> <a href="packages.html">All Packages</a> <a href="tree.html">Class Hierarchy</a> <a href="Package-gnu.gettext.html">This Package</a> <a href="Package-gnu.gettext.html">Previous</a> <a href="Package-gnu.gettext.html">Next</a> <a href="AllNames.html">Index</a></pre> <hr> <h1> Class gnu.gettext.GettextResource </h1> <pre> java.lang.Object | +----java.util.ResourceBundle | +----gnu.gettext.GettextResource </pre> <hr> <dl> <dt> public abstract class <b>GettextResource</b> <dt> extends ResourceBundle </dl> This class implements the main GNU libintl functions in Java. <P> Using the GNU gettext approach, compiled message catalogs are normal Java ResourceBundle classes and are thus interoperable with standard ResourceBundle based code. <P> The main differences between the Sun ResourceBundle approach and the GNU gettext approach are: <UL> <LI>In the Sun approach, the keys are abstract textual shortcuts. In the GNU gettext approach, the keys are the English/ASCII version of the messages. <LI>In the Sun approach, the translation files are called "<VAR>Resource</VAR>_<VAR>locale</VAR>.properties" and have non-ASCII characters encoded in the Java <CODE>\</CODE><CODE>u<VAR>nnnn</VAR></CODE> syntax. Very few editors can natively display international characters in this format. In the GNU gettext approach, the translation files are called "<VAR>Resource</VAR>.<VAR>locale</VAR>.po" and are in the encoding the translator has chosen. Many editors can be used. There are at least three GUI translating tools (Emacs PO mode, KDE KBabel, GNOME gtranslator). <LI>In the Sun approach, the function <CODE>ResourceBundle.getString</CODE> throws a <CODE>MissingResourceException</CODE> when no translation is found. In the GNU gettext approach, the <CODE>gettext</CODE> function returns the (English) message key in that case. <LI>In the Sun approach, there is no support for plural handling. Even the most elaborate MessageFormat strings cannot provide decent plural handling. In the GNU gettext approach, we have the <CODE>ngettext</CODE> function. </UL> <P> To compile GNU gettext message catalogs into Java ResourceBundle classes, the <CODE>msgfmt</CODE> program can be used. <p> <hr> <a name="index"></a> <h2> <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index"> </h2> <dl> <dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o "> <a href="#verbose"><b>verbose</b></a> <dd> </dl> <h2> <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index"> </h2> <dl> <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#GettextResource()"><b>GettextResource</b></a>() <dd> </dl> <h2> <img src="images/method-index.gif" width=207 height=38 alt="Method Index"> </h2> <dl> <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o "> <a href="#gettext(java.util.ResourceBundle, java.lang.String)"><b>gettext</b></a>(ResourceBundle, String) <dd> Returns the translation of <VAR>msgid</VAR>. <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o "> <a href="#ngettext(java.util.ResourceBundle, java.lang.String, java.lang.String, long)"><b>ngettext</b></a>(ResourceBundle, String, String, long) <dd> Returns the plural form for <VAR>n</VAR> of the translation of <VAR>msgid</VAR>. </dl> <a name="variables"></a> <h2> <img src="images/variables.gif" width=153 height=38 alt="Variables"> </h2> <a name="verbose"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a> <b>verbose</b> <pre> public static boolean verbose </pre> <a name="constructors"></a> <h2> <img src="images/constructors.gif" width=231 height=38 alt="Constructors"> </h2> <a name="GettextResource"></a> <a name="GettextResource()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a> <b>GettextResource</b> <pre> public GettextResource() </pre> <a name="methods"></a> <h2> <img src="images/methods.gif" width=151 height=38 alt="Methods"> </h2> <a name="gettext(java.util.ResourceBundle, java.lang.String)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a> <a name="gettext"><b>gettext</b></a> <pre> public static String gettext(ResourceBundle catalog, String msgid) </pre> <dl> <dd> Returns the translation of <VAR>msgid</VAR>. <p> <dd><dl> <dt> <b>Parameters:</b> <dd> catalog - a ResourceBundle <dd> msgid - the key string to be translated, an ASCII string <dt> <b>Returns:</b> <dd> the translation of <VAR>msgid</VAR>, or <VAR>msgid</VAR> if none is found </dl></dd> </dl> <a name="ngettext(java.util.ResourceBundle, java.lang.String, java.lang.String, long)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a> <a name="ngettext"><b>ngettext</b></a> <pre> public static String ngettext(ResourceBundle catalog, String msgid, String msgid_plural, long n) </pre> <dl> <dd> Returns the plural form for <VAR>n</VAR> of the translation of <VAR>msgid</VAR>. <p> <dd><dl> <dt> <b>Parameters:</b> <dd> catalog - a ResourceBundle <dd> msgid - the key string to be translated, an ASCII string <dd> msgid_plural - its English plural form <dt> <b>Returns:</b> <dd> the translation of <VAR>msgid</VAR> depending on <VAR>n</VAR>, or <VAR>msgid</VAR> or <VAR>msgid_plural</VAR> if none is found </dl></dd> </dl> <hr> <pre> <a href="packages.html">All Packages</a> <a href="tree.html">Class Hierarchy</a> <a href="Package-gnu.gettext.html">This Package</a> <a href="Package-gnu.gettext.html">Previous</a> <a href="Package-gnu.gettext.html">Next</a> <a href="AllNames.html">Index</a></pre> </body> </html>