Description: Used for specifying text translations in templates.
Usage:{% tr 变量名称 %}
The prerequisite for using the translation field is that the template supports multi-language functionality. The method to enable the multi-language function of the template is as follows:
Create a directory named 'locales' under the template directory, and then create a folder with the name of the current language code, such as 'zh-CN' or 'zh-TW'.Create a yml file in the folder, for example, default.yml.
./locales
├── en-us
│ └── default.yml
├── ja
│ └── default.yml
├── nl
│ └── default.yml
└── zh-cn
└── default.yml
The content of the default.yml file in Chinese is as follows:
"yourLocation": "您的位置"
Call the method:{% tr "yourLocation" %}
After the template is parsed, the content in different languages will be displayed accordingly, such as displaying Chinese as您的位置
, and English asYour location
.