1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 3.2//EN">
5 <!-- Generated by javadoc on Sat Nov 03 18:12:01 CET 2001 -->
7 Class gnu.gettext.GettextResource
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>
16 Class gnu.gettext.GettextResource
21 +----java.util.ResourceBundle
23 +----gnu.gettext.GettextResource
27 <dt> public abstract class
<b>GettextResource
</b>
28 <dt> extends ResourceBundle
30 This class implements the main GNU libintl functions in Java.
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.
36 The main differences between the Sun ResourceBundle approach and the
37 GNU gettext approach are:
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
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.
63 To compile GNU gettext message catalogs into Java ResourceBundle classes,
64 the
<CODE>msgfmt
</CODE> program can be used.
69 <img src=
"images/variable-index.gif" width=
207 height=
38 alt=
"Variable Index">
72 <dt> <img src=
"images/blue-ball-small.gif" width=
6 height=
6 alt=
" o ">
73 <a href=
"#verbose"><b>verbose
</b></a>
77 <img src=
"images/constructor-index.gif" width=
275 height=
38 alt=
"Constructor Index">
80 <dt> <img src=
"images/yellow-ball-small.gif" width=
6 height=
6 alt=
" o ">
81 <a href=
"#GettextResource()"><b>GettextResource
</b></a>()
85 <img src=
"images/method-index.gif" width=
207 height=
38 alt=
"Method Index">
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
96 <a name=
"variables"></a>
98 <img src=
"images/variables.gif" width=
153 height=
38 alt=
"Variables">
100 <a name=
"verbose"><img src=
"images/blue-ball.gif" width=
12 height=
12 alt=
" o "></a>
103 public static boolean verbose
105 <a name=
"constructors"></a>
107 <img src=
"images/constructors.gif" width=
231 height=
38 alt=
"Constructors">
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>
113 public GettextResource()
115 <a name=
"methods"></a>
117 <img src=
"images/methods.gif" width=
151 height=
38 alt=
"Methods">
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>
122 public static String gettext(ResourceBundle catalog,
126 <dd> Returns the translation of
<VAR>msgid
</VAR>.
129 <dt> <b>Parameters:
</b>
130 <dd> catalog - a ResourceBundle
131 <dd> msgid - the key string to be translated, an ASCII string
133 <dd> the translation of
<VAR>msgid
</VAR>, or
<VAR>msgid
</VAR> if
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>
140 public static String ngettext(ResourceBundle catalog,
146 <dd> Returns the plural form for
<VAR>n
</VAR> of the translation of
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
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
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>