問題描述
我正在開發(fā)一個(gè)包含多語(yǔ)言支持的網(wǎng)站.我可以使用 Zend_Translate 翻譯字符串,但是內(nèi)容呢??例如,我是否必須為每種語(yǔ)言為同一產(chǎn)品添加多條記錄?或者還有其他方法嗎?我是多語(yǔ)言新手,請(qǐng)幫忙.提前致謝.
i am working on a site to include Multilingual Support. I can translate strings using Zend_Translate but what about the content?? For example do i have to add multiple records for same product's for each language? Or is there any other way? I am new to multilingual please help. Thanks in advance.
--- 補(bǔ)充 -----------------------------
--- Addition -----------------------------
好的,我決定使用混合解決方案來使用谷歌翻譯api并將其存儲(chǔ)在數(shù)據(jù)庫(kù)中以供進(jìn)一步編輯.那么存儲(chǔ)翻譯的數(shù)據(jù)庫(kù)結(jié)構(gòu)應(yīng)該是什么???
Ok, i decided to use a mixed solution to use google translation api and storing it in database for further editing. So what sould be the structure of database to store translations???
- 我是否應(yīng)該將不同語(yǔ)言的翻譯保存在與父記錄相同的表中.即對(duì)于產(chǎn)品表中的產(chǎn)品,在標(biāo)識(shí)語(yǔ)言中有一個(gè)額外的列.
- 一個(gè)通用的單個(gè)表,用于存儲(chǔ)所有表的所有翻譯.例如翻譯(id bigint、table_name vc(50)、table_id bigint、langugae、column_name vc(50)、translation)
我是否應(yīng)該將記錄保存在相關(guān)表中
should i save records in related tables
推薦答案
幾種可能的方法:
- 使用
gettext
(或 Poedit 之類的軟件)從內(nèi)容.可以使用變量插值. - 創(chuàng)建視圖過濾器,如:Zend 框架和翻譯
- 在數(shù)據(jù)庫(kù)中有單獨(dú)的數(shù)據(jù)內(nèi)容.
如果您以標(biāo)記(例如 Markdown)格式存儲(chǔ)內(nèi)容,則任何人都可以輕松翻譯它.創(chuàng)建不同語(yǔ)言的搜索引擎很容易.
- Using
gettext
(or software like Poedit) to extract the data from the content. Possible with variable interpolation. - Creating view filter like described in: Zend Framework and Translation
- Have separate content of the data in the database.
If you store the content in markup (e.g. Markdown) format, anyone can translate it easily. It's easy to create search engine in different languages.
似乎第三種方法需要的努力最多,但值得.
Seems the third approach requires the most efforts, but it is worth.
我假設(shè)您將產(chǎn)品數(shù)據(jù)存儲(chǔ)在數(shù)據(jù)庫(kù)中,例如:
I assume you store your product data in the database, in fields like:
- product_data
-- id
-- price
-- name
-- description
-- etc…
所以你應(yīng)該修改它,為每種語(yǔ)言的翻譯字符串添加字段:
So you should modify it, to add fields for translated strings in each language:
- product_data
-- id
-- price
- product_data_translations
-- product_id
-- language (e.g. en)
-- name
-- description
-- etc
然后您可以輕松構(gòu)建 SQL 查詢以提取翻譯后的數(shù)據(jù)where product_id=x and language="fr"
.
Then you can easily build SQL queries to extract translated data where product_id=x and language="fr"
.
您也可以使用 Doctrine I18N 自動(dòng)為你做.
You may use also Doctrine I18N to do it for you automatically.
您需要手動(dòng)翻譯內(nèi)容(或使用 Google API 自動(dòng)翻譯),但是,您可以使用例如 Zend_Search_Lucene.
You need to translate the content manually (or automate the translation using Google API), but then, you can easily index it using for example Zend_Search_Lucene.
這篇關(guān)于Zend 框架中的多語(yǔ)言站點(diǎn)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!