Zend框架中的多语言站点

编程入门 行业动态 更新时间:2024-10-09 16:28:54
本文介绍了Zend框架中的多语言站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在一个网站上提供多语言支持. 我可以使用Zend_Translate翻译字符串,但是内容呢? 例如,是否必须为每种语言的同一产品添加多个记录?还是有其他方法吗? 我是多语言新手,请帮忙. 预先感谢.

---加法-----------------------------

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

  • 我应将不同语言的译文保存在与父记录相同的表中.即针对产品表中的产品,并在身份验证语言中添加了额外的列.
  • 一个通用的单个表,用于存储所有表的所有翻译.例如翻译(id bigint,table_name vc(50),table_id bigint,langugae,column_name vc(50),翻译)
  • 我应该将记录保存在相关表中

    解决方案

    几种可行的方法:

  • 使用gettext(或 Poedit 之类的软件)从内容中提取数据.通过变量插值可以实现.
  • 创建视图过滤器,如下所述: Zend框架和翻译
  • 在数据库中具有单独的数据内容. 如果您以标记(例如 Markdown )格式存储内容,那么任何人都可以轻松地对其进行翻译.创建不同语言的搜索引擎很容易.
  • 似乎第三种方法需要最多的努力,但这是值得的.

    评论后更新

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

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

    因此,您应该对其进行修改,以为每种语言的翻译字符串添加字段:

    - product_data -- id -- price - product_data_translations -- product_id -- language (e.g. en) -- name -- description -- etc

    然后,您可以轻松地构建SQL查询以提取翻译后的数据where product_id=x and language="fr".

    您也可以使用教义I18N 为您自动完成.

    您需要手动翻译内容(或使用Google API自动翻译内容),但是您可以使用例如 Zend_Search_Lucene .

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

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

    解决方案

    Few possible approaches:

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

    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.

    更多推荐

    Zend框架中的多语言站点

    本文发布于:2023-11-02 07:12:05,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1551713.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:多语言   框架   站点   Zend

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!