FUEL CMS User Guide : Version 0.9.3


MY Language Helper

Contains functions to be used with language files. Extends CI's language helper and is autoloaded.

This helper is loaded using the following code:

$this->load->helper('language');

The following functions are available:

lang(str, [vars])

Get translated local strings with arguments.

// in lang file
$lang['lang_key'] = "This is a lang file entry for %1s.";
...
echo lang('lang_key', 'my_param'); //This is lang file entry for my_param.

json_lang(array_or_string, [return_json])

Creates an array or JSON object that can be used by your javascript files that need localized text. If the first parameter is an array, then it will include any language keys that are in the array. If the first parameter is a string, it will search for a language file to include. Language files within a module should include the slash (e.g. fuel/fuel_js).

// in lang file
$lang['lang_key'] = "This is a lang file entry for %1s.";
...
echo json_lang($lang, TRUE); //{lang_key:'This is a lang file entry for %1s.'}


// OR in lang file of 'fuel/fuel_js'
$lang['lang_key'] = "This is a lang file entry for %1s.";
...
echo json_lang('fuel/fuel_js', FALSE); //array('lang_key' => 'This is a lang file entry for %1s.'...)