Creating new languages

New languages can be added to AbanteCart as extensions from the marketplace or downloaded from AbanteCart.com Alternately, new languages can be created in the admin manually. This is done with creating new language in System -> Localization -> Languages. In this case, language can be translated using auto-translation mode in "Load missing language data" section.
We recommend creating new language by creating new extension. Simplest process will be to copy any existing language extension, rename all files, replace flag icons and translate the text. Text can be translated using Google translator and manually verified and corrected.

Using Language translations in the code

AbanteCart using ALanguage class to handle all text translation. There is a global instance of ALanguage class always present in the registry for all controllers. Default language set from selected language [english.xml] is loaded for any run and available in any place. If any additional language sets are loaded they might override translation if same keys are used. Keep this in mind. To avoid overriding language text can be requested from specific section by specifying section at an argument to get() function. In controller, values can be accessed with function $this->language->get(), example:

copy

$this->language->get('heading_title');  // Implicit call and gets last defined key text in the scope

 	

or

copy

$this->language->get('heading_title', 'catalog/product');  //explicit call to gets key text for given controller catalog/product

 	

In the template (corresponding .tpl file) this value will be available in $heading_title
Each controller auto-loads corresponding language translation that is available for it. For instance, for controller catalog/product there will be catalog/product language set loaded automatically once the controller is loaded.
If you need more translation, you can load any other language set that will be used in controller and templates that are processed by given controller. Below are the examples how it is done:

copy

$this->load->language('catalog/category');
    //Get specific translation by key
$this->document->setTitle( $this->language->get('heading_title') );
    //Assign all translations to the template
    $this->view->batchAssign( $this->language->getAll() );

 	

or

copy

$this->loadLanguage('catalog/category');
        //Get specific translation by key
$this->document->setTitle( $this->language->get('heading_title') );

 	

To add a language translation, you need to create an XML file and place it to the corespondent location in admin[storefront]/language/english/.. directory.
Once controller loads this new language translation XML fist time it will load XML details to the database and will cache the result. Once XML files are loaded in the database they are no longer used (possibly only for reset of values in the database). Translations are now used from database or cache. Users can change translations and these will reset the cache automatically after edit.

IMPORTANT NOTE

If you load multiple language sets, keep in mind that same keys will override values for each other and last value will be used bu default (implicit) access. If you need to get key text from specific section use explicit call with specified route.

NOTE

To improve performance AbanteCart, does not load same language files multiple times for the same page load. There is a global stack of all languages loaded for the page kept in global ALanguage class instance. Despite the fact that loaded language are in the class, there is no access to all of them. You need to specify languages that you need to use in the controller, except the main language and language corresponding to current controller. These are available automatically.

You can always create a new local instance of ALanguage class, but this is not desired.