Schema Locale Files
Schema locale files are JSON files with a .schema.json
file extension. They host translation strings for various setting schema attributes so that content in the theme editor can be translated to the store's active language.
Location
Schema locale files are located in the locales directory of the theme:
└── theme
...
├── config
└── locales
├── en.schema.default.json
├── ar.schema.json
...
Schema
Locale files need to follow a specific naming structure. They also follow a basic organizational structure:
Category: The top-level category of your translations.
Group: The second level grouping of translations within a category.
Translation: The third level, which represents the individual translations.
{
"my_category": {
"my_group": {
"my_translation": "translation text",
// ...
},
// ...
},
// ...
}
File Naming
You can use the 2-letter lowercase language representation to name your locale files.
Language | Format |
---|---|
French | fr.schema.json |
English | en.schema.json |
Arabic | ar.schema.json |
Additionally, you must designate a default locale file for each type.
Default Locale File
You must designate a default locale file in the format of *.schema.default.json
, where *
is your selected language. This file contains the translations for the default language of the theme. Only one default file is permitted.
Example |
---|
en.schema.default.json |
Usage
When working with schema locale files, you should familiarize yourself with referencing schema translations.
Reference schema translations
Schema translations can be accessed with code in the the following format:
t:translation_category.translation_group.translation_name
For example, to make the label
attribute of the featured-product.liquid
section translatable, use the following:
{
"sections": {
"featured-product": {
"label": "Product"
}
}
}
{% schema %}
{
"label": "t:sections.featured-product.label",
}
{% endschema %}