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?
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.