开发者

Best way to save localized static content

开发者 https://www.devze.com 2023-03-30 12:43 出处:网络
I am creating an application to have administrators enter the a localized static content of a page. For ex. nowadays the \"About Us\" content is English, I would like an admin to be able to enter the

I am creating an application to have administrators enter the a localized static content of a page. For ex. nowadays the "About Us" content is English, I would like an admin to be able to enter the same "About Us" content in Russian. How should I store the localized content? I'm thinking that the admin won't be able to edit the YAML files for each language. i thought storing all the data in a table and have a reference language id to it stored in a cookie. Having a call to the locale cookie each time a view loads checking out which language I am using, comparing it to the database and then calling the specific row where language = en/ru/wha开发者_开发技巧tever.

any better way?


Nowadays, you can simply put index.fr.html.erb and index.en.html.erb in the same folder and rails will do the rest.


odin is right, I do mean storing multiple versions of pages in different languages, I thought I could just leave it in YAML and in-place edit it and I stumbled across this -

http://asciicasts.com/episodes/256-i18n-backends

We change the i18n backend to Key-Value backend (Hash) but then it would mean that each restart of the webserver the hash will be lost and thus the article suggests using Redis another key-value storage which calls itself

Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

It seems fairly clever saving it like this, because I still use the Rails l18n, meaning I can route everything fairly easily, but I am enabling the user to edit the content for each locale.

0

精彩评论

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

关注公众号