# Newbie: ruby and i18n (java-like approach)

**URL:** <https://www.ruby-forum.com/t/newbie-ruby-and-i18n-java-like-approach/114465>\
**Category:** Ruby\
**Created:** [September 12, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/newbie-ruby-and-i18n-java-like-approach/114465 "2007-09-12T23:46:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eckobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a3d4f5/32.png) [@eckobar](https://www.ruby-forum.com/u/eckobar)\
**Post date:** [September 12, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/newbie-ruby-and-i18n-java-like-approach/114465/1 "2007-09-12T23:46:04Z")

</div>

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:

> **[Trail: Internationalization (The Java™ Tutorials)](https://docs.oracle.com/javase/tutorial/i18n/)**
>
> This internationalization Java tutorial describes setting locale, isolating locale-specific data, formatting data, internationalized domain name and resource identifier

hope you can help me … please consider … i am new to ruby _gg_

---

<div class="post-metadata">

**Author:** ![eckobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a3d4f5/32.png) [@eckobar](https://www.ruby-forum.com/u/eckobar)\
**Post date:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/newbie-ruby-and-i18n-java-like-approach/114465/2 "2007-09-17T13:24:19Z")

</div>

On 2007-09-13 06:46:08 +0900 (Thu, Sep), Klaus E. wrote:

> GLOBALIZE: in my opinion there are things that should be stored in a  
> 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 B.:

[http://rubyforge.org/projects/gloc/](http://rubyforge.org/projects/gloc/)

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.

---

<div class="post-metadata">

**Author:** ![eckobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a3d4f5/32.png) [@eckobar](https://www.ruby-forum.com/u/eckobar)\
**Post date:** [September 19, 2007, 2:37am UTC](https://www.ruby-forum.com/t/newbie-ruby-and-i18n-java-like-approach/114465/3 "2007-09-19T02:37:19Z")

</div>

On 9/12/07, Klaus E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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:  
>   
> 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.
