문제

Our users put documents into the database and provide e.g. names in different languages.

We store those in different DB fields, say name_en, name_fr, name_de and so on.

My question is:

Does Rails have a mechanism (probably provided by i18n) that selects the right name based on the current language setting?

I imagine a call like:

<%= t(document, :name) %>

도움이 되었습니까?

해결책

This gem may help https://github.com/globalize/globalize

I hope you will find this information useful.

다른 팁

While Anton pointed me in its direction I want it to have a separate answer, so this is what I think is the best solution to my particular problem:

Traco lets me stick with my current scheme of having translations of an attribute distributed of different columns in the same table.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top