1

我正在开发 Zend Framework、MVC、企业网站项目。我想开发一个友好的翻译系统,能够根据上下文翻译每个单词(有时同一个单词有不同的翻译)。

Zend Framework 使用 Zend_Translate 进行 i18n 和本地化。我们还看到了 Magento(使用 ZF)的内联翻译系统,用户可以直接翻译页面

我们想知道这个内联翻译系统是如何工作的,以便我们可以构建一个类似的系统并进行改进。

  1. 翻译存储在哪里:在数据库中还是在 CSV 文件中?

  2. 当用户在不同页面上进行不同的翻译时,系统如何知道获取相同单词的翻译?

  3. 我们应该如何构建一个页面来支持内联翻译?

  4. 系统如何处理静态文本与动态(数据库驱动)文本?

  5. 内联翻译似乎会使网站变得非常慢。Magento 如何解决这个问题?

如果您有更多需要解释的观点,请写下来。谢谢

4

1 回答 1

3

从这里开始(在未来,这可能不仅仅是一个合乎逻辑的问题):

  1. Magento 将基本翻译(由程序员提供)存储在 CSV 文件中,但内联翻译存储在数据库中。

  2. Magento 的翻译作用于整个字符串,而不是单词。通过为翻译提供整个句子的上下文,可以实现惯用翻译。权衡显然是每个句子都必须翻译,而不是每个单词。

  3. Magento 对此的回答是将所有可本地化的字符串包装在对本地化程序的调用中。Magento 模板通常看起来像这样(双下划线函数映射到“翻译到当前语言环境”函数):

    print $this->__("Please translate this string");

  4. Magento 中的动态文本(如产品描述)通常不翻译,但如果您想这样做,只需将正确的字符串传递给翻译器,如下所示:

    print $this->__($someString);

  5. It's unlikely that translation will make or break your site (look to your DB queries for most performance problems), but this is a legitimate question nonetheless. Magento does a few things to help. First, it stores serialized versions of the CSV files in a cache, so that reading CSVs is made more efficient. Secondly, Magento offers page caching so that an entire page's output can be stored (assuming that it will render identically), as well as block-level caching for smaller bits of a page. Between these you're in good shape for the most part.

Hope that helps!

Thanks, Joe

于 2010-07-19T16:20:52.233 回答