Skip to main contentSkip to footer

Admin Language file to make hello world - OpenCart Module Development

Rupak Nepali
Share:
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:

$this->load->language('extension/module/helloworld');
$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.

<?php
/**
 * 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!';

Comments

Join the conversation and share your thoughts

Leave a Comment

Your comment will be reviewed before publishing.

Be the first to comment on this post!

Innovation

Let's Make Something Amazing Together

We always provide our best creative ideas at the highest level. Tell us about your project and we will make it work.

InnovateBringing innovative solutions to complex problems
AutomateStreamlining processes through automation
DominateLeading the market with exceptional results
Build Smarter and Launch FasterEfficient development for rapid deployment