How to override localization of an extension

450 views
Skip to first unread message

Laurens Nienhaus

unread,
Jul 26, 2012, 12:37:22 PM7/26/12
to spree...@googlegroups.com
Hi,

I want to override the localization of an extension (spree_reviews in this case).

So i put my custom translation file in config/locales/spree_reviews/de.yml
and added the path to I18n.load_path.

However it seems, the extension’s locale files are loaded after the app’s locale files. So my customizations have no effect.

What is the best way to override the translation of an extension?

Thx / Regards,
Laurens

Ryan Bigg

unread,
Jul 26, 2012, 8:53:59 PM7/26/12
to spree...@googlegroups.com
Do you have an example app that we can see this happening in?
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree...@googlegroups.com.
To unsubscribe from this group, send email to spree-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Laurens Nienhaus

unread,
Jul 29, 2012, 6:43:00 AM7/29/12
to spree...@googlegroups.com
Hi,

please see the app code on github https://github.com/laurens/spree_i18n_test.git

I have spree_reviews installed and a config/locales/spree_reviews/en.yml file which overrides the translation key :review_management.

For comparison I have included another extension spree_foofah in lib/spree_foofah who‘s translation key :foobar is overridden in config/locales/spree_fofofah/en.yml

The latter works, but the former has no effect, which you can see when you visit the app’s /some_bar route

Laurens

Ryan Bigg

unread,
Jul 31, 2012, 2:07:47 AM7/31/12
to spree...@googlegroups.com
Which route is that? I see the following content when I use <%= t(:review_management) %>:

:review_management (from config/locales/spree_reviews/en.yml)

That seems to indicate to me that it's working as intended. Am I missing something?

Laurens Nienhaus

unread,
Jul 31, 2012, 7:10:34 AM7/31/12
to spree...@googlegroups.com
Ah, now I see,

if you put the i18n configuration in application.rb it works. I set the load path in order to load locale files from subdirectories.

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*', '*.{rb,yml}').to_s]
config.i18n.default_locale = :de

If you put it in a rails initializer it does not.

I18n.load_path += Dir[Rails.root.join('config', 'locales', '*', '*.{rb,yml}').to_s]
I18n.default_locale = :de

Is this a Spree or a Rails issue?

Thx,
Laurens

Am 31.07.2012 um 08:07 schrieb Ryan Bigg:

> Which route is that? I see the following content when I use <%= t(:review_management) %>:
>
> :review_management (from config/locales/spree_reviews/en.yml)
>
> That seems to indicate to me that it's working as intended. Am I missing something?
>
>
> On Sunday, 29 July 2012 at 8:13 PM, Laurens Nienhaus wrote:
>
>> Hi,
>>
>> please see the app code on github https://github.com/laurens/spree_i18n_test.git
>>
>> I have spree_reviews installed and a config/locales/spree_reviews/en.yml file which overrides the translation key :review_management.
>>
>> For comparison I have included another extension spree_foofah in lib/spree_foofah who‘s translation key :foobar is overridden in config/locales/spree_fofofah/en.yml
>>
>> The latter works, but the former has no effect, which you can see when you visit the app’s /some_bar route
>>
>> Laurens
>>
>>
>> Am 27.07.2012 um 02:53 schrieb Ryan Bigg:
>>> Do you have an example app that we can see this happening in?
>>>
>>> On 27/07/2012, at 2:37 AM, Laurens Nienhaus <l.nie...@gmail.com (mailto:l.nie...@gmail.com)> wrote:
>>>
>>>> Hi,
>>>>
>>>> I want to override the localization of an extension (spree_reviews in this case).
>>>>
>>>> So i put my custom translation file in config/locales/spree_reviews/de.yml
>>>> and added the path to I18n.load_path.
>>>>
>>>> However it seems, the extension’s locale files are loaded after the app’s locale files. So my customizations have no effect.
>>>>
>>>> What is the best way to override the translation of an extension?
>>>>
>>>> Thx / Regards,
>>>> Laurens
>>>> --
>>>> You received this message because you are subscribed to the Google Groups "Spree" group.
>>>> To post to this group, send email to spree...@googlegroups.com (mailto:spree...@googlegroups.com).
>>>> To unsubscribe from this group, send email to spree-user+...@googlegroups.com (mailto:spree-user+...@googlegroups.com).
>>>> For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "Spree" group.
>>> To post to this group, send email to spree...@googlegroups.com (mailto:spree...@googlegroups.com).
>>> To unsubscribe from this group, send email to spree-user+...@googlegroups.com (mailto:spree-user+...@googlegroups.com).
>>> For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Spree" group.
>> To post to this group, send email to spree...@googlegroups.com (mailto:spree...@googlegroups.com).
>> To unsubscribe from this group, send email to spree-user+...@googlegroups.com (mailto:spree-user+...@googlegroups.com).

Ryan Bigg

unread,
Jul 31, 2012, 9:53:13 PM7/31/12
to spree...@googlegroups.com
This could just be an ordering problem. By putting it into config/application.rb it will be loaded before any initializer-based code, therefore will take precedence. I don't think it's either a Spree or Rails issue.
Reply all
Reply to author
Forward
0 new messages