Magento – Using magento 1.9 to translate between two custom (not website) languages

localisationmagento-1.9

I'm looking for solution to use magento underlying translation system to translate a default text from English to any custom language (not being store default language). Is it even possible?

In my scenario i would like to use translation module to set certain properties (store dependent) in product while creating it in code. Product can be created in two stores, and will be available for both, but default values must be always in one language, and store-specific values must be obviously in other language.

I want to use translation system because its convenient for editing. Unless its of course not possible.

Best Answer

You can use the locale emulation for this:

$storeId would be the ID of another store with the specified language that you want to use.

$locale = Mage::app()->getLocale();

$locale->emulate($storeId); //push current locale to stack and replace with locale from specified store

//your magic here

$locale->revert(); //use last locale before last emulation
Related Topic