Beruflich Dokumente
Kultur Dokumente
You will need to define a translate file to the adminhtml area. Translate files are also
located in the following path
app/design/frontend/default/{theme}/locale/en_US/translate.csv
You can enable the inline translate feature along the following path System ->
Configuration -> Advanced -> Developer -> Translate Inline
Translate System with Custom Modules and Themes
If you want to enable the translate files for custom modules and themes, you will
need to use the function _(..);
echo __('Having Fun?');
echo __('Having Fun? %s','Ya');
echo __('Having Fun? %s %d','Ya',date('h'));
This function is made available in .phtml files, block files, controllers as well as
helper files.
You can even use translation in configuration files
<checkout translate="label" module="checkout">
<label>Checkout</label>
Getting Deeper
How does Magento work on translations? Here are two files that it uses for
translations
Mage_Core_Model_Translate
Mage_Core_Model_Locale
Heres how function _() can be defined
public function __()
{
$args = func_get_args();
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this>getModuleName());
array_unshift($args, $expr);
return $this->_getApp()->getTranslator()->translate($args);
}
The definition is located within
Mage_Core_Block_Abstract,Mage_Adminhtml_Controller_Action
Mage_Core_Controller_Front_Action
Mage_Core_Helper_Abstract
With this the translate function is called upon within the Mage_Core_Model_Translate
{
foreach ($data as $key => $value) {
if ($key === $value) {
continue;
}
$key = $this->_prepareDataString($key);
$value = $this->_prepareDataString($value);
if ($scope && isset($this->_dataScope[$key]) && !$forceReload ) {
/**
* Checking previos value
*/
$scopeKey = $this->_dataScope[$key] .
self::SCOPE_SEPARATOR . $key;
if (!isset($this->_data[$scopeKey])) {
if (isset($this->_data[$key])) {
$this->_data[$scopeKey] = $this->_data[$key];
/**
* Not allow use translation not related to module
*/
if (Mage::getIsDeveloperMode()) {
unset($this->_data[$key]);
}
}
}
$scopeKey = $scope . self::SCOPE_SEPARATOR . $key;
$this->_data[$scopeKey] = $value;
}
else {
$this->_data[$key]
= $value;
$this->_dataScope[$key]= $scope;
}
}
return $this;
}
Step 5: Translate the String
protected function _getTranslatedString($text, $code)
{
$translated = '';
if (array_key_exists($code, $this->getData())) {
$translated = $this->_data[$code];
}
elseif (array_key_exists($text, $this->getData())) {
$translated = $this->_data[$text];
}
else {
$translated = $text;
}
return $translated;
}
Development
UK.
She
recommends
checking
out
Magento