The reason why we invented this in the first place was that we thought
that we'd need to a) use plain Ruby Hashes for translations and b)
could not directly return these from a Ruby file. So we thought we'd
need to give a backend that manages its own state (like a db backend)
the chance to decide whether it wanted the translations to be actually
loaded or not:
# during startup
I18n.populate do
require 'translations.rb'
end
# in translations.rb
I18n.store_translations 'en-US', {:foo => 'foo'}
This way any backend could decide whether or not it wanted to yield
the block passed to I18n.populate and the require statement to happen.
We now can use both
I18n.load_translations "translations.rb"
I18n.load_translations "translations.yml"
with translations.rb then containing just the translations Hash (and
no call to I18n.store_translations).
So if we make sure only the latter would be used during, e.g., Rails
framework loading process I can not see what sense I18n.populate would
make anymore.
Am I missing something?
I'd otherwise suggest to remove the method from the API to make it
simpler.
--
sven fuchs sven...@artweb-design.de
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)
On 26 Aug 2008, at 22:48, Joshua Harvey wrote:
> My problem with Backend#store_translations is that it wouldn't be so
> uniform. SimpleBackend would simply store the translations in the
> current process, so this wouldn't be persistent, and wouldn't even
> update other Rails processes.
Ah. I was mistakenly assuming that #store_translations was supposed to
actually persist translations in backends apart from Simple.
> I didn't quite get the translation template part, could you
> elaborate on that, Christian?
I am hoping for a way to dump/restore translations from/to a backend,
in a well-defined format. The current Hash-format seems fine.
I imagined #store_translations could do the restore job. To extract/
dump stored translations from a backend, another method would have to
be added, e.g. #dump_translations.
The expression "translation template" was chosen to make it explicit
that the dump method returns the "raw", un-interpolated translations,
as opposed to #translate. Sorry for any confusion caused by this
misnomer.
With the above set of methods available on the backends, it would be
possible to e.g. migrate translations from one backend to another.
It would make sense to be able to restrict the methods to a certain
scope – i.e. tell the dump method to "dump everything below en-
US.date", or tell the restore method to "place the given translations
under the scope en-US.date". Could be:
Backend#dump_translations( scope = '' )
Backend#restore_translations( translations = {} , scope = '' )
or
Backend#dump_translations( locale, scope = '' )
Backend#restore_translations( translations = {} , locale, scope = '' )
Makes any sense?
Christian