本文档由 Apifox 自动生成,推荐使用 Apifox - API 文档、API 调试、API Mock、API 自动化测试!
/locales/
contains the localization files, which are JSON-based files that define translation strings. Each of these is a collection of key-value pairs found in a JSON string file, such as "Key":"Value."
get()
and set()
.get()
method can be used to retrieve text from the locale file. It needs only one parameter, which is key
of that text. For example, in the previous code, the developer might return the text "Free Shipping" as follows:
set()
method can be used to change the translation of text in the locale file. It needs two parameters, the key
of that text and the value that will be stored for that text. For example, in the previous code, the developer may change the text "Remember my choice" as follows:
add()
method can be used to add a new translation key path to multiple locales. It needs two parameters, which is the key
of the text to be translated, and the object
that contains the translation of the key
in multiple locales. For example, the developer can add the text "New Order" to different locales as follows:
addBulk()
method can be used to add more than one new translation key paths to multiple locales. It needs one parameter, which is the object
containing multiple keys and their corresponding translations in different locales. For example, the developer can add the texts "New Order" and "New Product" to different locales as follows: