Office Hours
Day Hours (GMT)
Bank Holidays Closed
Monday 9:00 - 17:30
Tuesday 9:00 - 17:30
Wednesday 9:00 - 17:30
Thursday 9:00 - 17:30
Friday 9:00 - 17:30
Saturday Closed
Sunday Closed
Knowledgebase: Developer Articles
How do I make a multilingual plugin?
Posted by Al Brookbanks on 28 October 2013 11:37 AM

Creating a miltilingual plugin in CubeCart v5 is simple. As other articles have explained a module.definitions.xml file is required to set the default language strings.

Below is an example of a default module.definitions.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<definitions version="1.0">
  <group name="example_plugin">
    <string name="module_title"><![CDATA[Example Module]]></string>
    <string name="hello"><![CDATA[Hello]]></string>

This file needs to be treated as the default fallback file which is always loaded and then replaced with strings for a different locale. Say you wanted to create a US English translation. To do this duplicate the file and rename it en-US.xml. The content can then be translated. In this case we changed "Hello" to "Howdy!".

<?xml version="1.0" encoding="UTF-8"?>
<definitions version="1.0">
  <group name="example_plugin"> 
    <string name="module_title"><![CDATA[Example Module]]></string>
    <string name="hello"><![CDATA[Howdy!]]></string>

Important: The group name must always be the plugin folder name in lowercase!

The name of the file must always take the language and country ISO code. Below are a few exampes: 

en-GB - British English
en-US - American English
fr-FR - French French
br-PT - Brazillian Portuguese

The admin side of the store will automaticaly load these language difinitions via the module class but you may need to add code such as below to hooks or other custom classes to get the langauge strings to load properly. 

$GLOBALS['language']->loadDefinitions('wishlist', CC_ROOT_DIR.CC_DS.'modules'.CC_DS.'plugins'.CC_DS.'example_plugin'.CC_DS.'language', 'module.definitions.xml'); 
$GLOBALS['language']->loadLanguageXML('wishlist', '', CC_ROOT_DIR.CC_DS.'modules'.CC_DS.'plugins'.CC_DS.'example_plugin'.CC_DS.'language');

Merchants using your plugin will be able to modify the language strings from the "Settings" >> "Languages" >> {Chosen Language} >> Modules - Plugins - example_pugin in the admin conrol panel.