Hi all, I''m thinking about how to best translate rails applications. As a first step this involves the ActiveRecord error messages. I have created a small patch mainly as a proof of concept. The idea is the following. In a `config'' subdirectory there is one yaml file for each language to be translated. It will contain the original (usually English language string) as a key and the translation to the target language as a value. One file might look like ,----[ de.yaml ] | Title must not be empty: Der Titel muss ausgefüllt werden | is too long (max is %d characters): ist zu lange (maximal %d Zeichen) `---- So the idea is to allow translation of the full_message but also the message without the field name. For the purpose of setting the language I have currently introduced the class attribute `language'' to the ActiveRecord::Base class. I have uploaded the patch to my Web site at <http://www.patrice.ch/tmp/activerecord-language-0.1.patch>. A unit test showing the usage is at <http://www.patrice.ch/tmp/media-unit-test.rb>. This implements: - one central file for each language - basic translation Current weaknesses: - Very badly tested - Should probably be a directory per language, not just one file - Many more What do you think about this approach? Or is there even some existing implementation which I missed? I''m only aware of - http://wiki.rubyonrails.com/rails/show/MultiLingualRails - http://wiki.rubyonrails.com/rails/show/Internationalization Patrice -- the Holy Scriptures, which are able to make you wise for salvation through faith in Christ Jesus. (2 Timothy 3:15)
> I''m thinking about how to best translate rails applications.In my specific case, I prefer to keep my code in english, but I often develop pt-BR UIs, so I just override Inflector.humanize to give the translation. This works ok for most things, specially AR messages. You may also want to override human_attribute_name in specific models, in case you need a different translation for a field name or something. I realize this does not scale when you''re serving more than one different language, but it''s a quick fix for my case.> | Title must not be empty: Der Titel muss ausgefüllt werden > | is too long (max is %d characters): ist zu lange (maximal %d Zeichen)For these messages there''s a setting: ActiveRecord::Errors.default_error_messages