0

I'm in planing process of my e-commerce solution and now the final question is how to implement language system.

In past i worked with e-commerce solutions such as Magento, eCommerce and OpenCart however i would like to avoid their approach as it was horrible and in the end it slowed down the entire application.

Take Magento for instance, it keeps language files in seperate folders and then code loads languages from files in that folder. The language files have over 10k lines and a lot of words and sentances repeat it selves for diffirent modules and the file has to be read on each load.

I have a HMVC arhitecture and was thinking to expand that where each module that is part of the solution would have it's own language file however this is Magentos approach and it's not the best of solutions.

I want my language file system to be as simple as possible and short keeping button names and label names in it and allowing anyone that wants to translate it to have easy time doing so. As i have a HMVC arhitecture i wanted to expand it and make it so that each module has it's own language file/class this way you only need to translate those modules that you are actually using instead of the appliaction to load all translations at once even for modules that are not being displayed.

But i feel that keeping translations like this could prove problematic for performance and simplicity. I did look in to GoogleTranslate plugin option and while it's pretty decent i fell it's not ready yet nor a proper solution.

What would be the best approach here.

Sterling Duchess
  • 1,970
  • 16
  • 51
  • 91

1 Answers1

1

If your HMVC architecture uses some kind of PHP framework, it may have APIs for dealing with translation issues. For example, in CodeIgniter you can use the Language Class, and in CakePHP you can use the i18n class.

Note that CodeIgniter currently uses plain PHP files to load the languages, so it's probably not as efficient as CakePHP (that can load the files from .po/.mo files or databases).

If you are not currently using one, you can try the Zend Framework's translation module. Note that you don't need to use all the Zend Framework (as it is highly modular too). If you still don't want that to clutter your project's space, you can use plain gettext().

ssice
  • 3,564
  • 1
  • 26
  • 44
  • I'm actually using CI2 as core for the solution. Thats interesting ill look in to it. – Sterling Duchess Jan 25 '13 at 22:45
  • You can then use CodeIgniter's Language Class, that is documented in its Manual. If you prefer to use a system that is translator-friendly (most translators are more familiar with .po files) you can import Zend Framework (or anything else) and build a module in CodeIgniter to glue both nicely. – ssice Jan 25 '13 at 22:47
  • How do .po/.mo files or database improve overall performance of the solution. I find the CI LC neat but performance is of key importance to me would you suggest to refrain from LC for another libary ? – Sterling Duchess Jan 25 '13 at 23:06
  • Actually, [it's not _that_ slower](http://mel.melaxis.com/devblog/2006/04/10/benchmarking-php-localization-is-gettext-fast-enough/). However, it can be slow enough for you to [notice](http://al.quimia.net/en/blog/improving-drupal-performance-using-native-gettext-for-translations). This SO question is [related](http://stackoverflow.com/a/1415692/488191). – ssice Jan 26 '13 at 02:49