Globalize2 enhancements (dynamic writers, blcks, validtions)

Hey everyone,

I am replacing some old Rails model localization with Globalize2. I am
really impressed with the design of the Globalize2 plugin, but we have a
pretty involved i18n setup on my site, so I’m finding a lot of areas to
improve. So far I have a number of significant changes in my github
fork:

http://github.com/dasil003/globalize2

  • translates accepts a block to customize the dynamicly generated
    Translation class (thanks juni0r)
  • some options to allow multiple models to use the same translation
    table (:foreign_key and :not_dependent)
  • add a unique key to enforce translation uniqueness and speed up
    queries collecting all translations for a given language
  • dynamic locale-specific accessors. this allows bypassing fallbacks,
    is easier to code forms against then #set_translations, and is more
    robust then accepts_nested_attributes solutions which are subject to
    race conditions and dups due to the fact that there is no lookup by
    unique key other than an actual translation primary_key.

Now I’m onto some more involved questions such as how to handle
validations on the translation model and pass it back to the base model
without the current exceptions we see when translation saves fail, and
also the issue of deleting translations (eg. auto-clearing translations
when there is no data in them).

As I mentioned my app is quite complex in its localization architecture.
I am writing my enhancements to be general purpose and well-tested, but
could use some input from others using globalize2 to increase the chance
that the stuff I’m working on can make it back into the mainline and be
useful to others.

One example of a big issue I’d like to collaborate on is how to test
I18n.fallbacks in Globalize2 (which currently have tests that don’t run,
and are broken when I explicitly enable fallbacks). Another thing is a
test harness for I18n.available_locales, or supporting per-Globalize
available_locales setting (rather than implicitly defining from the DB).

Anyone down to work on this?

Hey Gabe, thanks for sharing!! I was just adding the foreign_key when i
found your post.

In my case it was needed, because my tables are in spanish and the
inflections are a mess.

Gabe Da silveira wrote:

Hey everyone,

I am replacing some old Rails model localization with Globalize2. I am
really impressed with the design of the Globalize2 plugin, but we have a
pretty involved i18n setup on my site, so I’m finding a lot of areas to
improve. So far I have a number of significant changes in my github
fork:

Thanks for the reply Federico. Development has been quiet on my fork
for the moment, but I have a lot more stuff going on in my app. So far
I haven’t had any outside interest, but my use case is quite
sophisticated and exposes a lot of vectors for improvement in
globalize2. I’m hoping to get more feedback so that my changes can make
it back to the core distribution.