Accessing I18n translations yamls

hello there,
I’m trying to hack a little helper project of mine and I might be
interest
in accessing the yamls loaded by I18n (I mean I could load them by
myself,
but accessing them through I18n is more backend agnostic).

The reason is I want to be able to invert the yaml in such a way that
the
values of the translations link to the “full_i18n_keys” that make them
accessible. An example:

Let’s say I have the locales:
{“en”=>{“hello”=>{“world”=>“Hello world”}}}
{“es”=>{“hello”=>{“world”=>“hola mundo”}}}

I want to invert them like this:
{“en”=>{“Hello world” => “hello.world”}}
{“es”=>{“Hola mundo”=>“hello.world”}}

I know there could arise problems with repeated texts, and such, but
I’ll
cope with them…

so back to my question: is there a way I can access the yamls or is
there
anyone who have then already inverted like that? If not, how would you
recommend I go into it?

TIA and greetings,
joaquin

Hi,

I did similar thing, you’re talking about. I extend the backend to
support flattened YML files, so all my translations files look like:

en:
activerecord.errors.messages.accepted: “must be accepted”
activerecord.errors.messages.blank: “can’t be blank”

The reason of doing it was complications I met with working on huge
piece of data in nested yml files. Having few thousands keys in few
translations files, was making me furious when I needed rename
translation keys, move them to another namespace etc. and had to
scroll a lot, looking and wondering what is namespace of the key.
Also, resolving merge conflicts, checking for missing translations in
other locale files are much easier, when you have and see full key.

Having the Fast backend in latest i18n, implementing it was quite
simple and it’s in my fork of i18n:
http://github.com/knapo/i18n/blob/master/lib/i18n/backend/zuper_fast.rb

Btw, as Fast backend uses flattened hashes, I believe that when you
invert I18n.backend.flattened_translations hash you’ll get what you
need.

Regards,
Krzysztof K.

2010/1/22 Joaquin Rivera P. [email protected]:

hei knapo thanks, I’ll check your fork and see what I can come up with
:slight_smile:

greeetings,
joaquin

2010/1/22 Krzysztof K. [email protected]

piece of data in nested yml files. Having few thousands keys in few
Btw, as Fast backend uses flattened hashes, I believe that when you

in accessing the yamls loaded by I18n (I mean I could load them by

To unsubscribe from this group, send email to
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en.