I've continued playing with this stuff and added an experimental  
Gettext backend:

http://github.com/svenfuchs/i18n/commit/fb7fcfff5e94510dbc1cb0b9b12a374c6828fb6f

It extends from the Simple backend, reads PO files using Masao Mutoh's  
poparser [1] and simply loads the translations to the standard Hash  
format. They can then be read both using the gettext'ish helper  
methods I've played with recently as well as the standard I18n gem API.

     I18n.load_path = [File.dirname(__FILE__) + '/../locale/de.po']
     I18n.backend = I18n::Backend::Gettext.new
     I18n.locale = :de
     assert_equal 'Auto', _('car')

Please note that this is really just an experimental proof of concept  
thing. I want to show that it's possible but don't have a real use for  
that myself right now. So, any feedback or help with this is highly  
appreciated!

Also, maybe this is a good time to take this discussion over to the  
rails-i18n mailinglist [2] to work out implementation details? I'll  
just post a follow-up over there.


Lemme also point out that there are efforts from other people to  
improve Gettext integration for or use alongside with Rails I18n.  
Maybe most notably:

- Masao Mutoh's gettext_rails
- Sam Lown's i18n_gettext
- Michael Grosser's fast_gettext


[1] 
http://github.com/mutoh/gettext/blob/d36e97af7dc801af1b1ceb5a47450cab90ed078f/lib/gettext/poparser.rb
[2] http://groups.google.com/group/rails-i18n
[3] http://github.com/mutoh/gettext_rails
[4] http://github.com/ferblape/i18n_gettext
[5] http://github.com/grosser/fast_gettext



On 27.04.2009, at 23:28, Sven Fuchs wrote:

>
>>> For pluralization there could be a similar helper. This should
>>> work  for all messages that do not contain a dot. I wonder if we
>>> can get rid  of this limitation. Approaches that come to my mind:
>>>
>>> 1. Make the scope separator (dot) configurable. That might mean
>>> that  Rails core should not continue using dots as separators (but
>>> instead  just use Arrays for scopes).
>>> 2. Escape/unescape dots in the helper.
>>> 3. ?
>>
>> Sounds complicated...
>
> Btw I've just pushed some experiments with gettext'ish accessors on
> top of Rails I18n:
>
> http://github.com/svenfuchs/i18n/tree/gettext
>
> You might particularly want to look at the helper layer and the tests:
>
> http://github.com/svenfuchs/i18n/blob/49220ce667fe542041c97bd38a0190e27a9581d6/lib/i18n/gettext.rb
> http://github.com/svenfuchs/i18n/blob/49220ce667fe542041c97bd38a0190e27a9581d6/test/gettext_test.rb
>
> For a fullstack gettext support that uses the Rails I18n API there
> seem to be three things missing:
>
> - complete the helpers (trivial)
> - implement a gettext backend (anybody?)
> - figure out a gettext'ish way to announce expected translations for
> computed keys
>
> Any help and/or feedback would be appreciated!
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to