Re: Using gettext (was Translation updates: errors_ru.properties)
От | Kris Jurka |
---|---|
Тема | Re: Using gettext (was Translation updates: errors_ru.properties) |
Дата | |
Msg-id | Pine.BSO.4.56.0410071957430.4235@leary.csoft.net обсуждение исходный текст |
Ответ на | Re: Using gettext (was Translation updates: errors_ru.properties) ("Serguei A. Mokhov" <mokhov@cs.concordia.ca>) |
Список | pgsql-jdbc |
On Thu, 7 Oct 2004, Serguei A. Mokhov wrote: > They use gettext! :-) > > I googled for java+gettext+gnu and found: That wasn't the quer > > http://www.gnu.org/software/gettext/manual/html_chapter/gettext_13.html#SEC205 > > Citation: > > ------------------------------------8<----------------------------------- > 13.5.10 Java > > RPMs > java, java2 > > File extension > java > > String syntax > "abc" > > gettext shorthand > _("abc") > > gettext/ngettext functions > GettextResource.gettext, GettextResource.ngettext > > textdomain > ---, use ResourceBundle.getResource instead > > bindtextdomain > ---, use CLASSPATH instead > > setlocale > automatic > > Prerequisite > --- > > Use or emulate GNU gettext > ---, uses a Java specific message catalog format > > Extractor > xgettext -k_ > > Formatting with positions > MessageFormat.format "{1,number} {0,number}" > > Portability > fully portable > > po-mode marking > --- > 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. > > > The 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. > > > The 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. > ------------------------------------8<----------------------------------- > > > > Kris Jurka > > > > > > > > -- > Serguei A. Mokhov | /~\ The ASCII > Computer Science Department | \ / Ribbon Campaign > Concordia University | X Against HTML > Montreal, Quebec, Canada | / \ Email! >
В списке pgsql-jdbc по дате отправления: