Admin Language file to make hello world – OpenCart Module Development

Create a language file helloworld.php at “admin\language\en-gb\extension\module\“, here en-Gb is the English language folder but if your store is multi-language then you have to create helloworld.php in another folder also like at “admin\language\OTHER_LANGUAGE_FOLDER\extension\module\“.

Now in helloworld.php, you will define variable that holds the text for that language. Starting defining a variable with $_[‘YOUR_VARIABLE_NAME’] and assign the text for that language.

$_['language_variable']     = 'Text for this language';

Now in the controller, you can do the following:

$data['view_variable'] = $this->language->get('language_variable');

In the view, you will show the text as:

<?php echo $view_variable; ?>

In this way, In the view, you will be able to access the text from the language that the controller file stored as a PHP variable.

For our HelloWorld module of OpenCart module development, the following are the needed text and I have assigned to those variables.

 * Created by PhpStorm.
 * User: rnepali
 * Date: 10/2/2016
 * Time: 1:45 PM

$_['heading_title']     = 'Hello World Module';

// Text
$_['text_extension']    = 'Extensions';
$_['text_success']      = 'Success: You have modified Hello World module!';
$_['text_edit']         = 'Edit Hello World Module';

// Entry
$_['entry_name'] = 'Enter the Hello World';
$_['entry_title']       = 'Heading Title';
$_['entry_status']      = 'Status';

// Error
$_['error_permission']  = 'Warning: You do not have permission to modify Hello World module!';
$_['error_name']        = 'Module Name must be between 3 and 64 characters!';


Please enter your comment!
Please enter your name here