1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"> 2<!--NewPage--> 3<HTML> 4<HEAD> 5<!-- Generated by javadoc on Sat Nov 03 18:12:05 CET 2001 --> 6<TITLE> 7: Class GettextResource 8</TITLE> 9<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"> 10</HEAD> 11<BODY BGCOLOR="white"> 12 13<!-- ========== START OF NAVBAR ========== --> 14<A NAME="navbar_top"><!-- --></A> 15<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> 16<TR> 17<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 18<A NAME="navbar_top_firstrow"><!-- --></A> 19<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> 20 <TR ALIGN="center" VALIGN="top"> 21 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 22 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 23 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 24 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 25 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 26 </TR> 27</TABLE> 28</TD> 29<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 30</EM> 31</TD> 32</TR> 33 34<TR> 35<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 36 PREV CLASS 37 NEXT CLASS</FONT></TD> 38<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 39 <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> 40 <A HREF="GettextResource.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> 41</TR> 42<TR> 43<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 44 SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> 45<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 46DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> 47</TR> 48</TABLE> 49<!-- =========== END OF NAVBAR =========== --> 50 51<HR> 52<!-- ======== START OF CLASS DATA ======== --> 53<H2> 54<FONT SIZE="-1"> 55gnu.gettext</FONT> 56<BR> 57Class GettextResource</H2> 58<PRE> 59java.lang.Object 60 | 61 +--java.util.ResourceBundle 62 | 63 +--<B>gnu.gettext.GettextResource</B> 64</PRE> 65<HR> 66<DL> 67<DT>public abstract class <B>GettextResource</B><DT>extends java.util.ResourceBundle</DL> 68 69<P> 70This class implements the main GNU libintl functions in Java. 71 <P> 72 Using the GNU gettext approach, compiled message catalogs are normal 73 Java ResourceBundle classes and are thus interoperable with standard 74 ResourceBundle based code. 75 <P> 76 The main differences between the Sun ResourceBundle approach and the 77 GNU gettext approach are: 78 <UL> 79 <LI>In the Sun approach, the keys are abstract textual shortcuts. 80 In the GNU gettext approach, the keys are the English/ASCII version 81 of the messages. 82 <LI>In the Sun approach, the translation files are called 83 "<VAR>Resource</VAR>_<VAR>locale</VAR>.properties" and have non-ASCII 84 characters encoded in the Java 85 <CODE>\</CODE><CODE>u<VAR>nnnn</VAR></CODE> syntax. Very few editors 86 can natively display international characters in this format. In the 87 GNU gettext approach, the translation files are called 88 "<VAR>Resource</VAR>.<VAR>locale</VAR>.po" 89 and are in the encoding the translator has chosen. Many editors 90 can be used. There are at least three GUI translating tools 91 (Emacs PO mode, KDE KBabel, GNOME gtranslator). 92 <LI>In the Sun approach, the function 93 <CODE>ResourceBundle.getString</CODE> throws a 94 <CODE>MissingResourceException</CODE> when no translation is found. 95 In the GNU gettext approach, the <CODE>gettext</CODE> function 96 returns the (English) message key in that case. 97 <LI>In the Sun approach, there is no support for plural handling. 98 Even the most elaborate MessageFormat strings cannot provide decent 99 plural handling. In the GNU gettext approach, we have the 100 <CODE>ngettext</CODE> function. 101 </UL> 102 <P> 103 To compile GNU gettext message catalogs into Java ResourceBundle classes, 104 the <CODE>msgfmt</CODE> program can be used. 105<P> 106<HR> 107 108<P> 109<!-- ======== INNER CLASS SUMMARY ======== --> 110 111 112<!-- =========== FIELD SUMMARY =========== --> 113 114<A NAME="field_summary"><!-- --></A> 115<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 116<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 117<TD COLSPAN=2><FONT SIZE="+2"> 118<B>Field Summary</B></FONT></TD> 119</TR> 120<TR BGCOLOR="white" CLASS="TableRowColor"> 121<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 122<CODE>static boolean</CODE></FONT></TD> 123<TD><CODE><B><A HREF="../../gnu/gettext/GettextResource.html#verbose">verbose</A></B></CODE> 124 125<BR> 126 </TD> 127</TR> 128</TABLE> 129 <A NAME="fields_inherited_from_class_java.util.ResourceBundle"><!-- --></A> 130<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 131<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 132<TD><B>Fields inherited from class java.util.ResourceBundle</B></TD> 133</TR> 134<TR BGCOLOR="white" CLASS="TableRowColor"> 135<TD><CODE>parent</CODE></TD> 136</TR> 137</TABLE> 138 139<!-- ======== CONSTRUCTOR SUMMARY ======== --> 140 141<A NAME="constructor_summary"><!-- --></A> 142<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 143<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 144<TD COLSPAN=2><FONT SIZE="+2"> 145<B>Constructor Summary</B></FONT></TD> 146</TR> 147<TR BGCOLOR="white" CLASS="TableRowColor"> 148<TD><CODE><B><A HREF="../../gnu/gettext/GettextResource.html#GettextResource()">GettextResource</A></B>()</CODE> 149 150<BR> 151 </TD> 152</TR> 153</TABLE> 154 155<!-- ========== METHOD SUMMARY =========== --> 156 157<A NAME="method_summary"><!-- --></A> 158<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 159<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 160<TD COLSPAN=2><FONT SIZE="+2"> 161<B>Method Summary</B></FONT></TD> 162</TR> 163<TR BGCOLOR="white" CLASS="TableRowColor"> 164<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 165<CODE>static java.lang.String</CODE></FONT></TD> 166<TD><CODE><B><A HREF="../../gnu/gettext/GettextResource.html#gettext(java.util.ResourceBundle, java.lang.String)">gettext</A></B>(java.util.ResourceBundle catalog, 167 java.lang.String msgid)</CODE> 168 169<BR> 170 Returns the translation of <VAR>msgid</VAR>.</TD> 171</TR> 172<TR BGCOLOR="white" CLASS="TableRowColor"> 173<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 174<CODE>static java.lang.String</CODE></FONT></TD> 175<TD><CODE><B><A HREF="../../gnu/gettext/GettextResource.html#ngettext(java.util.ResourceBundle, java.lang.String, java.lang.String, long)">ngettext</A></B>(java.util.ResourceBundle catalog, 176 java.lang.String msgid, 177 java.lang.String msgid_plural, 178 long n)</CODE> 179 180<BR> 181 Returns the plural form for <VAR>n</VAR> of the translation of 182 <VAR>msgid</VAR>.</TD> 183</TR> 184</TABLE> 185 <A NAME="methods_inherited_from_class_java.util.ResourceBundle"><!-- --></A> 186<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 187<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 188<TD><B>Methods inherited from class java.util.ResourceBundle</B></TD> 189</TR> 190<TR BGCOLOR="white" CLASS="TableRowColor"> 191<TD><CODE>getBundle, getBundle, getBundle, getKeys, getLocale, getObject, getString, getStringArray, handleGetObject, setParent</CODE></TD> 192</TR> 193</TABLE> 194 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 195<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 196<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 197<TD><B>Methods inherited from class java.lang.Object</B></TD> 198</TR> 199<TR BGCOLOR="white" CLASS="TableRowColor"> 200<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> 201</TR> 202</TABLE> 203 204<P> 205 206<!-- ============ FIELD DETAIL =========== --> 207 208<A NAME="field_detail"><!-- --></A> 209<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 210<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 211<TD COLSPAN=1><FONT SIZE="+2"> 212<B>Field Detail</B></FONT></TD> 213</TR> 214</TABLE> 215 216<A NAME="verbose"><!-- --></A><H3> 217verbose</H3> 218<PRE> 219public static boolean <B>verbose</B></PRE> 220<DL> 221</DL> 222 223<!-- ========= CONSTRUCTOR DETAIL ======== --> 224 225<A NAME="constructor_detail"><!-- --></A> 226<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 227<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 228<TD COLSPAN=1><FONT SIZE="+2"> 229<B>Constructor Detail</B></FONT></TD> 230</TR> 231</TABLE> 232 233<A NAME="GettextResource()"><!-- --></A><H3> 234GettextResource</H3> 235<PRE> 236public <B>GettextResource</B>()</PRE> 237<DL> 238</DL> 239 240<!-- ============ METHOD DETAIL ========== --> 241 242<A NAME="method_detail"><!-- --></A> 243<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> 244<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 245<TD COLSPAN=1><FONT SIZE="+2"> 246<B>Method Detail</B></FONT></TD> 247</TR> 248</TABLE> 249 250<A NAME="gettext(java.util.ResourceBundle, java.lang.String)"><!-- --></A><H3> 251gettext</H3> 252<PRE> 253public static java.lang.String <B>gettext</B>(java.util.ResourceBundle catalog, 254 java.lang.String msgid)</PRE> 255<DL> 256<DD>Returns the translation of <VAR>msgid</VAR>.<DD><DL> 257<DT><B>Parameters:</B><DD><CODE>catalog</CODE> - a ResourceBundle<DD><CODE>msgid</CODE> - 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 258 none is found</DL> 259</DD> 260</DL> 261<HR> 262 263<A NAME="ngettext(java.util.ResourceBundle, java.lang.String, java.lang.String, long)"><!-- --></A><H3> 264ngettext</H3> 265<PRE> 266public static java.lang.String <B>ngettext</B>(java.util.ResourceBundle catalog, 267 java.lang.String msgid, 268 java.lang.String msgid_plural, 269 long n)</PRE> 270<DL> 271<DD>Returns the plural form for <VAR>n</VAR> of the translation of 272 <VAR>msgid</VAR>.<DD><DL> 273<DT><B>Parameters:</B><DD><CODE>catalog</CODE> - a ResourceBundle<DD><CODE>msgid</CODE> - the key string to be translated, an ASCII string<DD><CODE>msgid_plural</CODE> - its English plural form<DT><B>Returns:</B><DD>the translation of <VAR>msgid</VAR> depending on <VAR>n</VAR>, 274 or <VAR>msgid</VAR> or <VAR>msgid_plural</VAR> if none is found</DL> 275</DD> 276</DL> 277<!-- ========= END OF CLASS DATA ========= --> 278<HR> 279 280<!-- ========== START OF NAVBAR ========== --> 281<A NAME="navbar_bottom"><!-- --></A> 282<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> 283<TR> 284<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 285<A NAME="navbar_bottom_firstrow"><!-- --></A> 286<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> 287 <TR ALIGN="center" VALIGN="top"> 288 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 289 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 290 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 291 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 292 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 293 </TR> 294</TABLE> 295</TD> 296<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 297</EM> 298</TD> 299</TR> 300 301<TR> 302<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 303 PREV CLASS 304 NEXT CLASS</FONT></TD> 305<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 306 <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> 307 <A HREF="GettextResource.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> 308</TR> 309<TR> 310<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 311 SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> 312<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 313DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> 314</TR> 315</TABLE> 316<!-- =========== END OF NAVBAR =========== --> 317 318<HR> 319 320</BODY> 321</HTML> 322