Translations / Multilanguage

When you develop a extension and this extension should be translatable, then you have following possibilities to do this. Best practice is, that all templates and outputs in your extensions should be translatable.

 

After defining the output as translatable you can translate it yourself in the extension editor or the user can (overwrite) translate in the language window (Butterfly -> Language). In both ways the system crawls all template files (.tpl), javascript files (.js) and php files (.php) and search for the directives.

 

Please note: When you make your templates translatable, then use please the english words in the templates and translate always from english to the target language. English is a very widespread speaking language, so more peoples can translate your templates.

 

The translated values are stored in following file

 

inc/modules/<extensionKey>/lang/<languageKey>.json

 

 

To make your templates translatable use following methods.

 

Templates files

In templates you should surround each phrase with [[ and ]].

Example for a multilanguage templates
<div>
   <h2>\Comments</h2>
   <div>
     \Following you'll find the comments.

     ....
 
     <h2>\New comment</h2>
     <form>
       \Name:
       <input type="text" name="name"/ >
       \Message:
       <textarea name="message"></textarea>
       <input type="submit" value="\Submit" />
     </form>
   </div>
</div>

 

PHP files

In php files you should use the global function _l().

 

Example of a multilanguage php file
<?php

class myExtensionClass extend baseModule {

    public function myPluginOne( $pParameters ){

        kryn::sendMail( _l('Some multilanguage subject'), 'foo@bar',
                        tFetch('some/email/template/file.tpl'); 

        if( false ){
            tAssign( 'errorMsg', _l('Very strange error appears.') );
        }
      
        return tFetch('some/template/file.tpl');  

    }

}

?>

 

Javascript files

In javascript files you should use the global function _().

Example of a multilanguage php file
<script type="text/javascript">
document.addEvent('domrdy', function(){
     
    new Element('div', {
       text: _('My multilanguage content')
    }).inject( document.body );

    if( false ){
        alert( _('New strange error appears!') );
    }
});
</script>

You can manage the translations with the following windows.