Skip to content

Commit

Permalink
Merge pull request #462 from Shopify/feature/translation-file-schema
Browse files Browse the repository at this point in the history
Add translations schema
  • Loading branch information
charlespwd authored Feb 21, 2024
2 parents c0d3c43 + be0c4dd commit 2f17022
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [16.x, 17.x]
node-version: [18.x, 20.x]

name: OS ${{ matrix.os }} / NodeJS ${{ matrix.node-version }}

Expand Down
57 changes: 57 additions & 0 deletions schemas/theme/translations_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "A schema for Shopify theme translation files. Supports nested properties, pluralized translations, and translations containing HTML.",
"type": "object",
"additionalProperties": {
"anyOf": [
{
"$ref": "#/$defs/pluralizedString"
},
{
"type": "string"
},
{
"$ref": "#"
}
]
},
"patternProperties": {
".*_html$": {
"type": "string",
"description": "Translation string that contains HTML. The '_html' suffix prevents the HTML content from being escaped."
}
},
"$defs": {
"pluralizedString": {
"type": "object",
"properties": {
"one": {
"type": "string",
"description": "Translation for the singular form"
},
"other": {
"type": "string",
"description": "Translation for the plural form"
},
"few": {
"type": "string",
"description": "Translation for 'few' form, used in some languages"
},
"many": {
"type": "string",
"description": "Translation for 'many' form, used in some languages"
},
"two": {
"type": "string",
"description": "Translation for 'two' form, used in some languages"
},
"zero": {
"type": "string",
"description": "Translation for 'zero' form, used in some languages"
}
},
"additionalProperties": false,
"description": "An object representing a pluralized translation string"
}
}
}

0 comments on commit 2f17022

Please sign in to comment.