Re: Using gettext (was Translation updates: errors_ru.properties)

Поиск
Список
Период
Сортировка
От Serguei A. Mokhov
Тема Re: Using gettext (was Translation updates: errors_ru.properties)
Дата
Msg-id Pine.LNX.4.58.0410072050110.26362@haida.cs.concordia.ca
обсуждение исходный текст
Ответ на Translation updates: errors_ru.properties  ("Serguei Mokhov" <mokhov@cs.concordia.ca>)
Ответы Re: Using gettext (was Translation updates: errors_ru.properties)  (Kris Jurka <books@ejurka.com>)
Re: Using gettext (was Translation updates: errors_ru.properties)  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
On Thu, 7 Oct 2004, Kris Jurka wrote:

> Date: Thu, 7 Oct 2004 17:27:15 -0500 (EST)
>
> Unfortunately no one seems to be using gettext and Java together.
> Searching google for "java gettext translation" unfortunately comes back
> with the first result of my message to the list in January noting the
> pros/cons of using gettext for our jdbc driver.  How do other large Java
> projects handle this?  130 messages isn't really all that many, how
> can a big project cope?

They use gettext! :-)

I googled for java+gettext+gnu and found:

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 по дате отправления:

Предыдущее
От: "Serguei A. Mokhov"
Дата:
Сообщение: Re: Translation updates: errors_ru.properties
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: Using gettext (was Translation updates: errors_ru.properties)