Add unused translation key check#1213
Draft
jamesmengo wants to merge 1 commit into
Draft
Conversation
9bc501e to
da72b57
Compare
jamesmengo
commented
May 27, 2026
| expect(offenses).to.have.length(0); | ||
| }); | ||
|
|
||
| it('ignores Shopify-provided translation key namespaces by default', async () => { |
da72b57 to
201bcb2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you adding in this PR?
Adds
UnusedTranslationKey, a new Theme Check rule that reports default locale keys that are not statically referenced by the theme.This checks:
locales/*.default.jsonlocales/*.default.schema.jsonI'm only adding this to
allconfig for nowWhat is covered / ignored
{{ 'cart.title' | t }}cart.titleas a literal storefront reference.{{ 'cart.title' | translate }}cart.title;translateis handled the same ast."label": "t:sections.header.settings.title.label"sections.header.settings.title.labelfor schema locale files.{{ 'cart.' | append: 'title' | t }}cart.title.{{ 'title' | prepend: 'cart.' | t }}cart.title.{{ 'products.product.' | append: state | t }}products.product.as a safe prefix and protectsproducts.product.*.{{ 'cart.items' | t: count: cart.item_count }}cart.items.oneandcart.items.other.{{ translation_key | t }}{% assign key = 'actions.' | append: action %}+{{ key | t }}shopify.sentence.words_connectorin a locale filecustomer_accounts.order.titlein a locale fileWhat did you learn?
Resolving dynamic keys can be a much larger problem than I initially thought 😆. Oh, silly me.
Tophatting
Automated checks run:
pnpm --dir packages/theme-check-common buildpnpm --dir packages/theme-check-common type-checkpnpm --dir packages/theme-check-node buildpnpm exec changeset status --since=origin/mainpnpm buildcurrently fails before Theme Check on unrelatedpackages/prettier-plugin-liquidTypeScript errorspnpm test packages/theme-check-common/src/utils/translation-references.spec.ts packages/theme-check-common/src/checks/translation-key-exists/index.spec.ts packages/theme-check-common/src/checks/matching-translations/index.spec.ts packages/theme-check-common/src/checks/valid-schema-translations/index.spec.ts packages/theme-check-common/src/checks/unused-translation-key/index.spec.ts --runBefore you deploy
changesettheme-app-extension.ymlis not applicable here; generated config did not change