Overview
Locales are JSON files used for translating text strings throughout the theme and the theme editor.
Locales not only provide a unified location for configuring repeated words and copy across the theme but also allow you to set up international translations for merchants and customers within the theme and theme editor.
Location
Locale files are located in the locales
directory of the theme:
└── theme
...
└── locales
Types
There are two types of Locales files:
Type | Description |
---|---|
Storefront | Storefront locale files have a .json file extension and control the translation of storefront content. Merchants can edit these translations using the SHOPLINE language editor. |
Schema | Schema locale files have a .schema.json file extension and set up multilingual translations for theme editor configuration items. |
Structure
Locale files need to follow a specific naming structure and adhere to a basic organizational format:
- Products: The top-level products of translations.
- Product_list: The second-level grouping within the products.
- Load_more_tip: The third level, representing individual translations.
{
"products": {
"product_list": {
"load_more_tip": "custom text",
...
},
...
},
...
}
When naming translation descriptions, be descriptive enough to provide translation context.
For example: order.order_details.insuranceService_content_email
provides more context than order.order_details.email
.
File Naming
Locale file names must adhere to the standard IETF language tag format. This format uses a lowercase language code followed by .schema.json
. For example:
Language | Schema | Storefront |
---|---|---|
English | en.schema.json | en.json |
Indonesian | id.schema.json | id.json |
Thai | th.schema.json | th.json |
The exceptions are Simplified Chinese and Traditional Chinese, which are:
Language | Schema | Storefront |
---|---|---|
Simplified Chinese | zh-hans-cn.schema.json | zh-hans-cn.json |
Traditional Chinese | zh-hant-tw.schema.json | zh-hant-tw.json |
Usage
The referenced code varies based on the type of locale file. It differs between a storefront locale file and a schema locale file.
Error loading component.