开发者

Best approach for rails 3 I18n

开发者 https://www.devze.com 2022-12-30 02:48 出处:网络
I have a page with brands, tags, comments and products. It\'s time to go international and I have some question about how to setup the I18n.

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

I have read some about Internalization and even tried the globalize gem 1 year ago but it's still lot of things I don't know how do handle. I translate the static text on my webpage using the beautiful I18n.translate() method storing every static and semi-static text in a different .yml file. The problem comes when try to keep track of relations depending on language.

Before getting into the problem I show you my database-schema/models. Notice that none of the models has the locale variable yet.

Models and schema

Product

belongs_to :category

has_many :taggings

has_many :tags, :through => :taggings

has_many :comments

  • name:string
  • description:text
  • comments_count:integer

Comme开发者_开发问答nt

belongs_to :product, :counter_cache => true

  • author:string
  • comment:text

Brand

has_many :products

  • name:string

Tagging

belongs_to :tag

belongs_to :product

Tag

has_many :taggings

has_many :products, :through => :taggings

  • name:string

Problems

  • translate fields

    To translate single fields like tag's name or product's description it's possible to use the globalize2 gem with a separate translation table or any other gem with the same feature.

  • comments_count

    The comments_count for products is going to show the total amount of comments, not for a specific language.

  • tags/taggings

    When doing product.first.tags it's going to show all the taggings regardless of current locale. One solution for this problem could be to put a locale field in the taggings table but I guess there is plugins or gems for doing this?

  • Brand name is international and doesn't change depending on language.

I need advise from someone who know how to handle I18n applications well and the question is simple: how do I solve the problems above? All answers are appreciated.


I use puret http://github.com/jo/puret for translate data. Nice plugin works well, but I have some not yet solved problems when saving nested models with translated fields.

Other alternatives not working with Rails 3 now.

0

精彩评论

暂无评论...
验证码 换一张
取 消