In plugins, multi-language files for both frontend and backend are stored in the src/locale folder
You can add translation entries in the corresponding multi-language file (/src/locale/${lang}.ts). If it's a newly added multi-language file, you need to restart the application for it to take effect. You can check the app:getLang interface to verify if the translation entries have been successfully added.
http://localhost:3000/api/app:getLang?locale=zh-CN
The server has two i18n instances: app.i18n and ctx.i18n
app.i18n is the global i18n instance, generally used in CLI. For example, combined with inquirer to implement command-line interactions.
A cloneInstance of the global app.i18n, each request's ctx is completely independent, responding with multi-language information based on the client's language.
Client request parameters can be placed in the query string
Or in request headers (recommended)
Example
View http://localhost:3000/api/test-i18n?locale=zh-CN
TachybaseBase's i18n is based on i18next. For detailed usage, refer to I18next API Documentation. Below are just a few important examples
Each plugin's locale is distinguished by ns, where ns is the plugin name, such as:
Change the current language