🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@by-association-only/translation-checker

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@by-association-only/translation-checker

Check Shopify theme translations match those used in local liquid files.

latest
Source
npmnpm
Version
1.0.11
Version published
Maintainers
2
Created
Source

Translation Checker

image

What it does

Correctly set up, this script will prevent any files being deployed until all of the translations used in the local theme files are present on the live theme.

It runs in the terminal, and sits in front of any Shopify CLI theme comands.

  • Pulls the current live en.default.json into a temp folder
  • Scans local liquid files to construct an array of translation strings used in the theme
  • Check that all of the strings exist in the temp en.default.json
  • Print out the location of any missing strings in the terminal

Setup

  • npm i @by-association-only/translation-checker --save-dev or yarn install @by-association-only/translation-checker --save-dev

  • Add a config file in the root .bao-translation-checker

List each store name on a separate line (the part before .myshopify.com).

Example: If your stores are:

  • acmestore.myshopify.com
  • acmestore-us.myshopify.com

You would enter:

acmestore
acmestore-us
  • Run the check at the start of of the deploy script:

Replace 'npm' with yarn/pnpm depending on the project

  "scripts": {
    ...
    "deploy": "npm run translations:check && npm run deploy:all",
    "deploy:all": "npm run deploy:uk && npm run deploy:us",
    "deploy:uk": "...",
    "deploy:us": "...",
    "shopify": "shopify",
    "translations:check": "npm run shopify theme info && bao-translation-checker"
  }

Because the script exits with process.exit(1), it will prevent any further commands running if it finds any missing translations.

Issues

Please make sure you are using Shopify CLI v3.71+ and Node v18.20+ before continuing

1) No Shopify CLI

If the theme repo you're installing on does not have Shopify CLI, please run npm i @shopify/cli --save-dev

2) Error: Command failed: shopify theme pull

image

This means you're not logged into the CLI, or the CLI version is too old. It can be in issue on older themes that don't use the Shopify CLI, as this script cannot pass on the CLI's interactive login prompt.

To get around this, edit your package.json to include a 'shopify' command prior to running the translation checker. This will force a login prompt to be sent to your terminal. For example:

  "scripts": {
    ...
    "deploy": "yarn translations:check && unisian-tools deploy --skipPrompts",
    "translations:check": "yarn run shopify theme info && bao-translation-checker",
    "shopify": "shopify"
  },

If you're not authenticated, you'll now see the 'press any key to open in browser' terminal prompt from Shopify.

3) Error: Only file and data URLs are supported by the default ESM loader

image

Use node version 18+ to run the translation checker.

4) SyntaxError: Unexpected token } in JSON

The en.default.json file on the live theme likely contains invalid JSON.

The terminal should give you an idea where the error is:

Image

Go into the code editor and fix the issue shown in the terminal.

If that doesn't resolve it, copy en.default.json out from the code editor and run through a JSON validator like https://jsonlint.com/ to find the issue.

FAQs

Package last updated on 28 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts