views:

124

answers:

1

Hi,

I am working on a Zend Framework, MVC, enterprise website project. I would like to develop a friendly translation system with the ability to translate each word according its context (sometimes same word have different translation).

Zend Framework uses Zend_Translate for i18n and localization. We have also seen Magento's (which uses ZF) inline translation system, where users can translate pages directly.

We want to know how this inline translation system works, so that we can build a similar system with improvements.

  1. Where are translations stored: in the database or in CSV files?

  2. How does the system know to fetch translations for the same word when tranlsated differently by the user on different pages?

  3. How should we build a page to support inline translation?

  4. How does the system handle static text vs. dynamic (database-driven) text?

  5. Inline translation seems like it would make the site very slow. How does Magento solve this problem?

Please if you have more points that should be explained, write them. Thanks

+1  A: 

Starting from the beginning here (in the future, this is probably more than one logical question):

  1. Magento stores basic translations (provided by the programmer) in CSV files, but inline translations are stored in the database.

  2. Magento's translations operate on entire strings, not words. By providing an entire sentence worth of context for translations, idiomatic translations are achievable. The tradeoff is obviously that every sentence must be translated, rather than every word.

  3. Magento's answer to this is to wrap all localizable strings in a call to the localizer. Magento templates usually look something like this (the double-underscore function maps to the "translate into the current locale" function):

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

  4. Dynamic text (as in product descriptions) in Magento is often not translated, but if you want to do so, it's as simple as passing the right string to the translator, like this:

    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

Joseph Mastey
Thank you very much Yosef
Yosef