1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> 2<!--NewPage--> 3<html> 4<head> 5<!-- Generated by javadoc on Sat Nov 03 18:12:01 CET 2001 --> 6<title> 7 Class gnu.gettext.GettextResource 8</title> 9</head> 10<body> 11<a name="_top_"></a> 12<pre> 13<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> 14<hr> 15<h1> 16 Class gnu.gettext.GettextResource 17</h1> 18<pre> 19java.lang.Object 20 | 21 +----java.util.ResourceBundle 22 | 23 +----gnu.gettext.GettextResource 24</pre> 25<hr> 26<dl> 27 <dt> public abstract class <b>GettextResource</b> 28 <dt> extends ResourceBundle 29</dl> 30This class implements the main GNU libintl functions in Java. 31 <P> 32 Using the GNU gettext approach, compiled message catalogs are normal 33 Java ResourceBundle classes and are thus interoperable with standard 34 ResourceBundle based code. 35 <P> 36 The main differences between the Sun ResourceBundle approach and the 37 GNU gettext approach are: 38 <UL> 39 <LI>In the Sun approach, the keys are abstract textual shortcuts. 40 In the GNU gettext approach, the keys are the English/ASCII version 41 of the messages. 42 <LI>In the Sun approach, the translation files are called 43 "<VAR>Resource</VAR>_<VAR>locale</VAR>.properties" and have non-ASCII 44 characters encoded in the Java 45 <CODE>\</CODE><CODE>u<VAR>nnnn</VAR></CODE> syntax. Very few editors 46 can natively display international characters in this format. In the 47 GNU gettext approach, the translation files are called 48 "<VAR>Resource</VAR>.<VAR>locale</VAR>.po" 49 and are in the encoding the translator has chosen. Many editors 50 can be used. There are at least three GUI translating tools 51 (Emacs PO mode, KDE KBabel, GNOME gtranslator). 52 <LI>In the Sun approach, the function 53 <CODE>ResourceBundle.getString</CODE> throws a 54 <CODE>MissingResourceException</CODE> when no translation is found. 55 In the GNU gettext approach, the <CODE>gettext</CODE> function 56 returns the (English) message key in that case. 57 <LI>In the Sun approach, there is no support for plural handling. 58 Even the most elaborate MessageFormat strings cannot provide decent 59 plural handling. In the GNU gettext approach, we have the 60 <CODE>ngettext</CODE> function. 61 </UL> 62 <P> 63 To compile GNU gettext message catalogs into Java ResourceBundle classes, 64 the <CODE>msgfmt</CODE> program can be used. 65<p> 66<hr> 67<a name="index"></a> 68<h2> 69 <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index"> 70</h2> 71<dl> 72 <dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o "> 73 <a href="#verbose"><b>verbose</b></a> 74 <dd> 75</dl> 76<h2> 77 <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index"> 78</h2> 79<dl> 80 <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> 81 <a href="#GettextResource()"><b>GettextResource</b></a>() 82 <dd> 83</dl> 84<h2> 85 <img src="images/method-index.gif" width=207 height=38 alt="Method Index"> 86</h2> 87<dl> 88 <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o "> 89 <a href="#gettext(java.util.ResourceBundle, java.lang.String)"><b>gettext</b></a>(ResourceBundle, String) 90 <dd> Returns the translation of <VAR>msgid</VAR>. 91 <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o "> 92 <a href="#ngettext(java.util.ResourceBundle, java.lang.String, java.lang.String, long)"><b>ngettext</b></a>(ResourceBundle, String, String, long) 93 <dd> Returns the plural form for <VAR>n</VAR> of the translation of 94 <VAR>msgid</VAR>. 95</dl> 96<a name="variables"></a> 97<h2> 98 <img src="images/variables.gif" width=153 height=38 alt="Variables"> 99</h2> 100<a name="verbose"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a> 101<b>verbose</b> 102<pre> 103 public static boolean verbose 104</pre> 105<a name="constructors"></a> 106<h2> 107 <img src="images/constructors.gif" width=231 height=38 alt="Constructors"> 108</h2> 109<a name="GettextResource"></a> 110<a name="GettextResource()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a> 111<b>GettextResource</b> 112<pre> 113 public GettextResource() 114</pre> 115<a name="methods"></a> 116<h2> 117 <img src="images/methods.gif" width=151 height=38 alt="Methods"> 118</h2> 119<a name="gettext(java.util.ResourceBundle, java.lang.String)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a> 120<a name="gettext"><b>gettext</b></a> 121<pre> 122 public static String gettext(ResourceBundle catalog, 123 String msgid) 124</pre> 125<dl> 126 <dd> Returns the translation of <VAR>msgid</VAR>. 127<p> 128 <dd><dl> 129 <dt> <b>Parameters:</b> 130 <dd> catalog - a ResourceBundle 131 <dd> msgid - the key string to be translated, an ASCII string 132 <dt> <b>Returns:</b> 133 <dd> the translation of <VAR>msgid</VAR>, or <VAR>msgid</VAR> if 134 none is found 135 </dl></dd> 136</dl> 137<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> 138<a name="ngettext"><b>ngettext</b></a> 139<pre> 140 public static String ngettext(ResourceBundle catalog, 141 String msgid, 142 String msgid_plural, 143 long n) 144</pre> 145<dl> 146 <dd> Returns the plural form for <VAR>n</VAR> of the translation of 147 <VAR>msgid</VAR>. 148<p> 149 <dd><dl> 150 <dt> <b>Parameters:</b> 151 <dd> catalog - a ResourceBundle 152 <dd> msgid - the key string to be translated, an ASCII string 153 <dd> msgid_plural - its English plural form 154 <dt> <b>Returns:</b> 155 <dd> the translation of <VAR>msgid</VAR> depending on <VAR>n</VAR>, 156 or <VAR>msgid</VAR> or <VAR>msgid_plural</VAR> if none is found 157 </dl></dd> 158</dl> 159<hr> 160<pre> 161<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> 162</body> 163</html> 164