From 60c9dfab183b0f4e58266df935df25a0f891559d Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Tue, 20 Feb 2024 10:09:38 -0500 Subject: [PATCH 1/3] Add translation schema --- schemas/theme/translations_schema.json | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 schemas/theme/translations_schema.json diff --git a/schemas/theme/translations_schema.json b/schemas/theme/translations_schema.json new file mode 100644 index 0000000..2c24198 --- /dev/null +++ b/schemas/theme/translations_schema.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/pluralizedString" + }, + { + "$ref": "#" + } + ] + }, + "definitions": { + "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" + } + }, + "patternProperties": { + ".*_html$": { + "type": "string", + "description": "Translation string that contains HTML. The '_html' suffix prevents the HTML content from being escaped." + } + }, + "description": "A schema for Shopify theme translation files. Supports nested properties, pluralized translations, and translations containing HTML." +} From 85339bf9f951dfc1b3537b9c625750af3c3d5da5 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Tue, 20 Feb 2024 10:30:34 -0500 Subject: [PATCH 2/3] bump to json schema 2020-12 --- schemas/theme/translations_schema.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/schemas/theme/translations_schema.json b/schemas/theme/translations_schema.json index 2c24198..9d87141 100644 --- a/schemas/theme/translations_schema.json +++ b/schemas/theme/translations_schema.json @@ -1,5 +1,6 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$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": { "oneOf": [ @@ -7,14 +8,20 @@ "type": "string" }, { - "$ref": "#/definitions/pluralizedString" + "$ref": "#/$defs/pluralizedString" }, { "$ref": "#" } ] }, - "definitions": { + "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": { @@ -46,12 +53,5 @@ "additionalProperties": false, "description": "An object representing a pluralized translation string" } - }, - "patternProperties": { - ".*_html$": { - "type": "string", - "description": "Translation string that contains HTML. The '_html' suffix prevents the HTML content from being escaped." - } - }, - "description": "A schema for Shopify theme translation files. Supports nested properties, pluralized translations, and translations containing HTML." + } } From be0c4ddebab534b2adb1141ebcf19f19737eb6c3 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Tue, 20 Feb 2024 10:30:41 -0500 Subject: [PATCH 3/3] Bump to node 18/20 --- .github/workflows/ci.yml | 2 +- schemas/theme/translations_schema.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c09471..8293345 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/schemas/theme/translations_schema.json b/schemas/theme/translations_schema.json index 9d87141..d960275 100644 --- a/schemas/theme/translations_schema.json +++ b/schemas/theme/translations_schema.json @@ -3,12 +3,12 @@ "description": "A schema for Shopify theme translation files. Supports nested properties, pluralized translations, and translations containing HTML.", "type": "object", "additionalProperties": { - "oneOf": [ + "anyOf": [ { - "type": "string" + "$ref": "#/$defs/pluralizedString" }, { - "$ref": "#/$defs/pluralizedString" + "type": "string" }, { "$ref": "#"