Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 1.85 KB

12.-how-to-add-language-constants-1.md

File metadata and controls

39 lines (27 loc) · 1.85 KB

12. How to add language constants

1. How to add language constants

  1. Constants can be defined with define(), for example: define("_MI_MOD_TITLE","title:");
  2. Constants usually start with "_" and use "uppercase English" for identification.
  3. PHP constants need to be inserted into the string. You cannot put the constants directly into the string (otherwise the program will not be able to figure out whether it is a string or a constant). The method is as follows:
  4. Original string→$aa="<div>title</div>";
  5. Set constant →$aa="<div>". _MI_MOD_TITLE. "</div>";

2. The language file of XOOPS and its purpose

File name use Constant start Use range
modinfo.php Set language _MI Xoops_version.php and admin/menu.php only
admin.php Background language _MA or _AM All files except menu.php under admin
main.php Front desk language _MD All files in the front desk (except xoops_version.php)
blocks.php Block language _MB All files under blocks

Third, the method of combining constants and variables

  1. You can use sprintf() to combine constants and variables. The name of a constant can use "%s" to represent a variable. There can be multiple "%s" in a constant, which corresponds to the variable by position, for example:

    define("_MD_MOD_INFO","本模組由 %s 於 %s 做最後更新");
    $info=sprintf(_MD_MOD_INFO , $name , $update);
    

4. Language family used in the model

<{$smarty.const._語系常數}>

5. Built-in common language family

  1. The language in language/tchinese_utf8/global.php of XOOPS can be directly applied to each module.
  2. For the language of TadTools module tadtools/language/tchinese_utf8/main.php, only import tad_function.php, which can also be directly applied.