Complete multi language website in php
I need an idea on how to make a complete multilanguage website. I came across many ways some are having an xml file to have template bits translated. This works if I only want the main template. But even the content will be translated.
For example I have a new entry in english, it should be translated to 4 other languages. Most attributes are common.
What i reached so far is by creating a table for the main website template with attributes: lang, tag, value In my template it will do a match on lang and tag.
What is the best way to translate the rest of the website (dynamic php pages using mysql)
You need a table for languages as below:
CREATE TABLE `language` (
`langid` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`language` varchar(35) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`langid`)
) ENGINE=InnoDB
Then for example you have a table for posts as below:
CREATE TABLE `post` (
`postid` int unsigned NOT NULL AUTO_INCREMENT,
`langid` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`content` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`title` varchar(35) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`postid`)
) ENGINE=InnoDB
In the post table you need a key like langid
, which refers to the specific language in the language table. In you dashboard you will have something as below:
Each textbox refers to that specific language.
You should have another table for site's menus, and put langid foreign key in there. You should be well on your way.
Look into gettext extension - http://php.net/manual/en/book.gettext.php
Then use a program like POEdit or simplepo to do the actual editing of the language files
IMO, this is the best way I have found for a multilingual site
You can also look into the Zend_Translate module
链接地址: http://www.djcxy.com/p/37488.html上一篇: 拥有多种语言网站的最佳方式是什么?
下一篇: 在php中完成多语言网站