mardi 22 décembre 2015

Refinery CMS on Ruby Rails: Translating / Localising the Strings in the Blog Module

In the blog module for refinery CMS there are some strings in the source code that I would like to translate. When I override the view for _post.html.erb of the blog module there is code like this inside:

 <%= content_tag(:span, 
   "#{t('by', :scope => 'refinery.blog.posts.show')} #{@post.author.username}",
   :class => "blog_author") if @post.author.present? %>

I would like to localize the "by" string, so that in the blog, the default english "By authorname" is replaced by a phrase in another language.

Now, I have modified the en.yml and hr.yml localisation files in the rails config/locales directory and added the translation. However, this makes no effect to the strings displayed on my page.

I have tried setting the config.i18n.default_locale variable in config/application.rb to :en and to my desired language but this also accomplishes nothing.

The furthest I came was that if I change the config.current_locale variable in initializers/refinery/i18n.rb to :de for example, that has the effect of translating the admin interface for refinery and its blog module. And yet, the strings in the blog entries remain the same.

I have also added a yml file with translations for my locale in the gems library of the refinery blog component, but it still does not work.

Any help on how to translate the strings in the refinery blog module would be appreciated. I have searched the internet on how to translate refinery, but haven't managed to find any specific information for the translation of the the blog component, only general guides for rails, which don't seem to help with the refinery blog.

I am using the following gems versions:

  • rails (4.2.4)
  • rails-i18n (4.0.7)
  • railties (4.2.4)
  • refinerycms (3.0.0 1d13007)
  • refinerycms-acts-as-indexed (2.0.1)
  • refinerycms-authentication-devise (1.0.4)
  • refinerycms-blog (3.0.0 5ee8336)
  • refinerycms-core (3.0.0 1d13007)
  • refinerycms-i18n (3.0.1 ff93ad9)
  • refinerycms-images (3.0.0 1d13007)
  • refinerycms-pages (3.0.0 1d13007)
  • refinerycms-resources (3.0.0 1d13007)
  • refinerycms-search (3.0.0 aa8098c)
  • refinerycms-settings (3.0.0)
  • refinerycms-wymeditor (1.0.6) ...

Thank you in advance!

-- M. Jakov

Aucun commentaire:

Enregistrer un commentaire