Difference between revisions of "How to translate options in additional fields and text added with customizations"

From aMember Pro Documentation
Jump to: navigation, search
Line 1: Line 1:
 +
It is possible to do in two ways. Both ways is upgrade proof (You do not lost this changes after upgrade to new version).
 +
 +
== Custom Language File ==
 +
 +
You can create language file specific for your installation and put translations to this file.
 +
 +
You need to create file
 +
''amember/application/default/language/user/site/ru.php''
 +
 +
'''ru''' should be replaced with language code of desired language eg.: en, es, it, zn etc.
 +
 +
and add your translation to these file:
 +
<source>
 +
<?php
 +
 +
return array(
 +
    'one' => 'Один',
 +
    'two' => 'Два'
 +
);
 +
</source>
 +
 +
== Code in site.php ==
 +
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>

Revision as of 03:52, 13 September 2016

It is possible to do in two ways. Both ways is upgrade proof (You do not lost this changes after upgrade to new version).

Custom Language File

You can create language file specific for your installation and put translations to this file.

You need to create file amember/application/default/language/user/site/ru.php

ru should be replaced with language code of desired language eg.: en, es, it, zn etc.

and add your translation to these file:

<?php
 
return array(
    'one' => 'Один',
    'two' => 'Два'
);

Code in site.php

Add this code to site.php file:

//set up array of translataions
$translations_ru = array(
    'one' => 'Один',
    'two' => 'Два'
);
 
//retrieve global translate object
$tr = Zend_Registry::get('Zend_Translate');
$locale = $tr->getLocale(); //save current active locale to temporary variable
 
//add your new translations
$tr->addTranslation(array(
    'adapter' => 'array',
    'content' => $translations_ru,
    'locale' => 'ru_RU',
));
 
//restore locale to previous state
$tr->setLocale($locale);