The best approach for rails 3 I18n

I have a page with brands, tags, comments and products. It's time to go international and I have a question about how to configure I18n.

I read some about internalization and even tried to globalize the gem 1 year ago, but these are still a lot of things that I don’t know how to handle. I translated static text to my web page using the beautiful I18n.translate () method of storing each static and semi-static text in another .yml file. The problem comes when trying to track relationships based on language.

Before I get into the problem, I will show you my database / model schema. Note that none of the models has a locale variable.


Models and schemes


Product

belongs
 to_to : category has_many: taggings
 has_many: tags ,: through =>: taggings
 has_many: comments

  • name: string
  • Description: text
  • comments_count: integer

Comment

belongs to_to: product ,: counter_cache => true

  • author: string
  • Comment: text

Mark

has_many: products

  • name: string

Mark

belongs_to: tag belongs_from
 : product

Tag

has_many: taggings
 has_many: products ,: through =>: taggings

  • name: string

Problems


  • translate fields
    To translate individual fields, such as a tag name or description of a product, you can use the pearl globalize2 with a separate translation table or any other stone with the same feature.

  • comments_count
    Comment_count , .

  • /
    product.first.tags . , , ?

  • .

-, I18n, : ?. .

+3
1

puret http://github.com/jo/puret . , .

, Rails 3 .

+1

Source: https://habr.com/ru/post/1744964/


All Articles