Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
863 views
in Technique[技术] by (71.8m points)

php - Multilingual Site in Zend Framework

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.

--- Addition -----------------------------

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???

  1. Should i save translations of different language in same table as parent record. i.e. for product in product table with an extra column to identity language.
  2. A generalized single table to store all translations of all tables. e.g. translations (id bigint,table_name vc(50),table_id bigint, langugae, column_name vc(50), translation )

should i save records in related tables

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Few possible approaches:

  1. Using gettext (or software like Poedit) to extract the data from the content. Possible with variable interpolation.
  2. Creating view filter like described in: Zend Framework and Translation
  3. 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.

Update after comment

I assume you store your product data in the database, in fields like:

- product_data
-- id
-- price
-- name
-- description
-- etc…

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

Then you can easily build SQL queries to extract translated data where product_id=x and language="fr".

You may use also Doctrine I18N to do it for you automatically.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...