开发者

Suggested method of Internationalization in MySQL?

I have a website on Kohana and I'm planning to have it multi-language.

Now I know the way with i18n folder and inside each language folder

there's some sort of strings.php file..

But I want a dynamic way (on DB) so I could change the values whenever I want

through the website.

Is there any common table schema that is usually used for mult开发者_如何学Ci-lang content?


Well, you can probably mimic a "resource" file in your database,

You can have a table working as a catalog for your strings, with two columns, like

Lang_Constants
ID, Constant_Name
1, HELLO_STRING

Another table with supported languages:

Languages
ID, Name
1, English
2, Spanish

and the table with the actual data:

ID, Language, Constant, Value
1,   1, 1, "Hello world!"
10,  2, 1, "Hola mundo!"

ANd you could do a query like :

SELECT Value from Lang_Constant_values where 
  Language = (Select ID from Languages where Name = 'English')
and
  Constant = (Select ID from Lang_Constants where Constant_Name = 'HELLO_STRING')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜