Zend 框架中的多语言站点 [英] Multilingual Site in Zend Framework

查看:18
本文介绍了Zend 框架中的多语言站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含多语言支持的网站.我可以使用 Zend_Translate 翻译字符串,但是内容呢??例如,我是否必须为每种语言为同一产品添加多条记录?或者还有其他方法吗?我是多语言新手,请帮忙.提前致谢.

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

好的,我决定使用混合解决方案来使用谷歌翻译api并将其存储在数据库中以供进一步编辑.那么存储翻译的数据库结构应该是什么???

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. 我是否应该将不同语言的翻译保存在与父记录相同的表中.即对于产品表中的产品,在标识语言中有一个额外的列.
  2. 一个通用的单个表,用于存储所有表的所有翻译.例如翻译(id bigint、table_name vc(50)、table_id bigint、langugae、column_name vc(50)、translation)

我是否应该将记录保存在相关表中

should i save records in related tables

推荐答案

几种可能的方法:

  1. 使用 gettext(或 Poedit 之类的软件)从内容.可以使用变量插值.
  2. 创建视图过滤器,如:Zend 框架和翻译
  3. 在数据库中有单独的数据内容.
    如果您以标记(例如 Markdown)格式存储内容,则任何人都可以轻松翻译它.创建不同语言的搜索引擎很容易.
  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.

我假设您将产品数据存储在数据库中,例如:

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

然后您可以轻松构建 SQL 查询以提取翻译后的数据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 自动为你做.

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

您需要手动翻译内容(或使用 Google API 自动翻译),但是,您可以使用例如 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.

这篇关于Zend 框架中的多语言站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆