[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

newbie: ruby and i18n (java-like approach

Klaus Eckenfellner

9/12/2007 9:46:00 PM

hi everybody!

i am very new to ruby and tried to I18Ns my applications (ruby-scripts
and rails-applications). for that task i found to approaches:
* GETTEXT
* GLOBALIZE

but in my point of view both tools have contras.

GETTEXT: PO-files must be converted to MO-files. therefore everytime a
translation is edited, i need to create new MO-files. Or am I wrong?

GLOBALIZE: in my opinion there are things that should be stored in a
database and things that shouldn't be stored in a database. translation
information should NOT be stored in a database.

what i am interested in: is there a possibilty / tool to use a more
java-like approach to i18n in ruby?

if you don't know java-i18n:
* file-based
* translations are organized via keys
* keys are stored in files: basename_LOCALE.properties ... for example
basename_EN.properties includes all translations for en.
* dynamic content can be mixed with translations using
"{X}"-placeholders... useful for a text like "you deleted 200 files"
(200 is dynamic *gg*)

for a more detailed overview to java-i18n please consult:
http://java.sun.com/docs/books/tuto...

hope you can help me ... please consider ... i am new to ruby *gg*
--
Posted via http://www.ruby-....

2 Answers

Mariusz Pekala

9/13/2007 5:05:00 PM

0

On 2007-09-13 06:46:08 +0900 (Thu, Sep), Klaus Eckenfellner wrote:
> i am very new to ruby and tried to I18Ns my applications (ruby-scripts
> and rails-applications). for that task i found to approaches:
> * GETTEXT
> * GLOBALIZE
>
> but in my point of view both tools have contras.
>
> GETTEXT: PO-files must be converted to MO-files. therefore everytime a
> translation is edited, i need to create new MO-files. Or am I wrong?
>
> GLOBALIZE: in my opinion there are things that should be stored in a
> database and things that shouldn't be stored in a database. translation
> information should NOT be stored in a database.
>
> what i am interested in: is there a possibilty / tool to use a more
> java-like approach to i18n in ruby?
>
> if you don't know java-i18n:
> * file-based
> * translations are organized via keys
> * keys are stored in files: basename_LOCALE.properties ... for example
> basename_EN.properties includes all translations for en.
> * dynamic content can be mixed with translations using
> "{X}"-placeholders... useful for a text like "you deleted 200 files"
> (200 is dynamic *gg*)

I don't know much about how Java does this (and the tutorial you
provided seems to be a good reading for many cold and sleepless nights)
but it may be that you will like the GLoc library by David Barri:

http://rubyforge.org/proj...

It can everything you pointed, and in addition you can translate single
symbol into 'you deleted 200 files' and 'you deleted one file',
depending on the integer value you pass to translate.



--
No virus found in this outgoing message.
Checked by 'grep -i virus $MESSAGE'
Trust me.

Richard Conroy

9/19/2007 12:36:00 AM

0

On 9/12/07, Klaus Eckenfellner <nfs@eckenfellner.net> wrote:
> hi everybody!
>
> i am very new to ruby and tried to I18Ns my applications (ruby-scripts
> and rails-applications). for that task i found to approaches:
> * GETTEXT
> * GLOBALIZE

There's at least 5 other tools that I am aware of.

> but in my point of view both tools have contras.
>
> GETTEXT: PO-files must be converted to MO-files. therefore everytime a
> translation is edited, i need to create new MO-files. Or am I wrong?

Can't comment specifically - not familiar with Gettext, but a compilation/build
stage is frequently required in most languages.

>
> GLOBALIZE: in my opinion there are things that should be stored in a
> database and things that shouldn't be stored in a database. translation
> information should NOT be stored in a database.

Thats a pretty absolute statement. I would spend some time understanding
the advantages of using a DB for locale-specific content before ruling it out.

>
> what i am interested in: is there a possibilty / tool to use a more
> java-like approach to i18n in ruby?
>
> if you don't know java-i18n:
<snip>
Having wasted too much time with java resource formats (including
compiled class files, text based hashes, write my own, etc.)
I would be loathe to seek out a java equivalent system in another
language. Java has superb encoding support, yet the APIs you depend
on for use of language resource files are exceedingly backward.

Having to escape non-ASCII characters in a UTF-8 file that DIY
java code can read normally is just not on. Sacrificing resource
legibility to avail of the resource lookup algorithm is compromising
too much for too little.

>
> hope you can help me ... please consider ... i am new to ruby *gg*

Look further at i18n options in rails/ruby. There are some that try to
make it really easy.



> --
> Posted via http://www.ruby-....
>
>