use custom language files
Normally module authors add language files using this example.
If you want to enable custom language files in your addon please go this way:
create a file called register_language.php and put it in the root of your module directory.
This file should contain this content:
/** * @module your module * @author LEPTON project * @copyright 2015-2016 LEPTON project * @link http://www.LEPTON-cms.org * @license http://www.gnu.org/licenses/gpl.html * @license_terms please see LICENSE and COPYING files in your package * */ // include class.secure.php to protect this file and the whole CMS! if (defined('LEPTON_PATH')) { include(LEPTON_PATH.'/framework/class.secure.php'); } else { $oneback = "../"; $root = $oneback; $level = 1; while (($level < 10) && (!file_exists($root.'/framework/class.secure.php'))) { $root .= $oneback; $level += 1; } if (file_exists($root.'/framework/class.secure.php')) { include($root.'/framework/class.secure.php'); } else { trigger_error(sprintf("[ %s ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // end include class.secure.php require_once('info.php'); if (isset ($wb)) { /** * load the correct language-file for frontend */ if (file_exists (LEPTON_PATH.'/templates/'.DEFAULT_TEMPLATE.'/frontend/'.$module_directory.'/'.LANGUAGE.'.php')) { require_once (LEPTON_PATH.'/templates/'.DEFAULT_TEMPLATE.'/frontend/'.$module_directory.'/'.LANGUAGE.'.php'); } else { $lang = (dirname(__FILE__))."/languages/". LANGUAGE .".php"; require_once ( !file_exists($lang) ? (dirname(__FILE__))."/languages/EN.php" : $lang ); } } else { /** * load the correct language-file for backend */ if (file_exists (LEPTON_PATH.'/templates/'.DEFAULT_THEME.'/backend/'.$module_directory.'/'.LANGUAGE.'.php')) { require_once (LEPTON_PATH.'/templates/'.DEFAULT_THEME.'/backend/'.$module_directory.'/'.LANGUAGE.'.php'); } else { $lang = (dirname(__FILE__))."/languages/". LANGUAGE .".php"; require_once ( !file_exists($lang) ? (dirname(__FILE__))."/languages/EN.php" : $lang ); } }
Include this file wherever neccessary in your addon with
// load the correct language-file require_once (LEPTON_PATH."/modules/your_module/register_language.php");
All the user has to do is
- for frontend: put the modified module language files in a directory with the same name as the addon placed in /your_template/frontend/addon_name
- for backend: put the modified module language files in a directory with the same name as the addon placed in /your_theme/backend/addon_name
The system will now load first custom language file if they exist.