From c6e51b38883155640ab89da98c2637e1edd00787 Mon Sep 17 00:00:00 2001 From: James Peilow Date: Fri, 2 May 2025 15:29:01 +0100 Subject: [PATCH 1/2] Add tests --- .../matching-translations/index.spec.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/theme-check-common/src/checks/matching-translations/index.spec.ts b/packages/theme-check-common/src/checks/matching-translations/index.spec.ts index 06f04313b..070df312f 100644 --- a/packages/theme-check-common/src/checks/matching-translations/index.spec.ts +++ b/packages/theme-check-common/src/checks/matching-translations/index.spec.ts @@ -267,6 +267,36 @@ describe('Module: MatchingTranslations', async () => { } }); + it('should not report offenses and ignore Shopify keys for Accounts (New)', async () => { + for (const prefix of ['', '.schema']) { + const theme = { + [`locales/en.default${prefix}.json`]: JSON.stringify({ + hello: 'Hello', + customer_accounts: { + account_information: { + title: 'Account', + } + } + }), + [`locales/pt-BR${prefix}.json`]: JSON.stringify({ + hello: 'Olá', + customer_accounts: { + navigation_and_structure: { + account_menu: { + label: 'Compte', + } + } + } + }), + }; + + const offenses = await check(theme, [MatchingTranslations]); + console.log(offenses); + + expect(offenses).to.be.of.length(0); + } + }); + it('should not report offenses and ignore "*.schema.json" files', async () => { const theme = { 'locales/en.default.json': JSON.stringify({ hello: 'Hello' }), From 8665241be141ea8760a1a09c4c63c84ed589267b Mon Sep 17 00:00:00 2001 From: James Peilow Date: Fri, 2 May 2025 15:30:34 +0100 Subject: [PATCH 2/2] Updated Theme Check MissingTranslations to ignore customer_accounts. translations --- .../src/checks/matching-translations/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/theme-check-common/src/checks/matching-translations/index.ts b/packages/theme-check-common/src/checks/matching-translations/index.ts index b43054fe1..707bfbf31 100644 --- a/packages/theme-check-common/src/checks/matching-translations/index.ts +++ b/packages/theme-check-common/src/checks/matching-translations/index.ts @@ -48,7 +48,7 @@ export const MatchingTranslations: JSONCheckDefinition = { const hasDefaultTranslations = () => defaultTranslations.size > 0; const isTerminalNode = ({ type }: JSONNode) => type === 'Literal'; const isPluralizationNode = (node: PropertyNode) => PLURALIZATION_KEYS.has(node.key.value); - const isShopifyPath = (path: string) => path.startsWith('shopify.'); + const isShopifyPath = (path: string) => path.startsWith('shopify.') || path.startsWith('customer_accounts.'); const hasDefaultTranslation = (translationPath: string) => defaultTranslations.has(translationPath) ?? false;