0%

International i18n support

What is international i18n

i18n, in short, is to release a software to the global market, open it in every place, and display the functions of different languages.
Currently, we can judge and load different language files based on your system. Chinese and English are supported by default. We also hope that more people will join in the translation and submit it to the official.

Function usage

  1. (text,{…})
    There is a function method named “
    “ globally. The first parameter is the key of the text to be displayed in json. The key is preferably a combination of English letters and numbers.
    value is the text to be displayed. Variable placeholders can be used in the text. Each variable is widened with “${“ and “}”. For example: hello ${world}
    The second parameter is a hash table, which is used to map to the variable placeholder part of the first parameter. k is the variable name and v is the text to be displayed by the variable.
    If the variable placeholder does not find a value in the second parameter hash table, the value of the same key will be found in the current language json environment for replacement.
    Finally, according to the current locale, “__” will return the corresponding string result.
    As for environment json, it is json text data with key=value, located in the resources/langs/ directory.
    Generally, the language file of your module is in (resources/langs/module//.json). For example: resources/langs/module/card/zh.json

Precautions

  1. (Language code) Language code, generally consists of the first 2 characters and the code after the minus sign. If the complete encoding cannot find the corresponding language file, the software will try to load the parent language file. For example: Under zh-CN encoding, if there is no zh-CN.json, he will try to load zh.json
  2. If no language files are found, it means that the current software cannot load the language of your platform. You can provide official support and join the translation work. In this case, the software will load the default language (en-US)
  3. Try to provide international support if you want your module to be used by more people.