如何制作多语言网站? [英] How can I make multi-language website?
问题描述
可能的重复项:
在PHP中使用多语言创建网页
PHP-如何将网站翻译成多种语言?
Possible Duplicates:
Create a webpage with Multilanguage in PHP
PHP - how to translate a website into multiple languages?
我想制作一个将使用3种语言的网站-例如英文,阿拉伯文和意大利文; 内容肯定会因一种语言而异.
I want to make a site which will have 3 languages - e.g. English, Arabic and Italian; the content sure will be different from one language to another.
我应该为每种语言制作不同的表格,例如:
Should I make different table for each language, e.g.:
en_articles
ar_articles
it_articles
每篇文章都使用不同的语言
each with the same article in different language,
或像这样制作一张桌子articles
:
or make one table articles
like this:
article_id
article_en_title
article_ar_title
article_it_title
请告诉我.
推荐答案
如果您非常确定只使用3种语言,则最佳选择是使用一个表,其中包含三列,其中一列用于语言:
If you are very sure that you are going to work only with 3 languages, the best option is to use one table, with three columns, one for language:
article_id
article_en_title
article_ar_title
article_it_title
如果最终您需要添加其他语言,则只需添加其他列.
If eventually you need to add other language, only add other column.
如果您认为要添加其他语言,或者您想将代码用于具有不同语言的其他网站,那么我认为最好的解决方案是使用3个表,一个表用于语言,一个表用于文章.和其他表格以建立联系
If you think that you are going to add other languages, o you want to use the code for others web with differents languages, I think that the best solution is to use 3 tables, one for the languages, one for the articles and other table for relation them
表格语言"
language_iso
language_name
表格文章"
article_id
article_name (Internal name for the article)
表"articles_x_languages"
table "articles_x_languages"
article_id
language_iso
article_title
article_text
我假设您将用三种语言撰写每篇文章.示例:
I'm assuming that you are going to have each article in the three languages. Example:
Languages
language_iso | language_name
en | English
ar | Arabic
it | Italian
Articles
article_id | article_name
1 | Sample 1
2 | Sample 2
Articles_x_languages
article_id | language_iso | article_title | article_text
1 | en | english title | Lorem ipsum ..
1 | ar | arabic title | Lorem ipsum ..
1 | it | italian title | Lorem ipsum ..
2 | en | english title | Lorem ipsum ..
2 | ar | arabic title | Lorem ipsum ..
2 | it | italian title | Lorem ipsum ..
这篇关于如何制作多语言网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!