{"id":19312132,"url":"https://github.com/bigcommerce/stencil-lang-validator","last_synced_at":"2025-10-23T15:27:30.010Z","repository":{"id":66176672,"uuid":"81763209","full_name":"bigcommerce/stencil-lang-validator","owner":"bigcommerce","description":"Validate language keys used in templates and scripts","archived":false,"fork":false,"pushed_at":"2017-05-01T11:01:38.000Z","size":51,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":81,"default_branch":"master","last_synced_at":"2025-04-02T00:51:19.799Z","etag":null,"topics":["bigcommerce","stencil"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-4-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigcommerce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-12T22:40:51.000Z","updated_at":"2021-07-11T20:51:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"92bf0b30-1727-452d-b0f5-78751183a1b3","html_url":"https://github.com/bigcommerce/stencil-lang-validator","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"819b062eac094526e9e99c74781c2dfd703603f6"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fstencil-lang-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fstencil-lang-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fstencil-lang-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fstencil-lang-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigcommerce","download_url":"https://codeload.github.com/bigcommerce/stencil-lang-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249961510,"owners_count":21352090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigcommerce","stencil"],"created_at":"2024-11-10T00:32:59.867Z","updated_at":"2025-10-23T15:27:24.956Z","avatar_url":"https://github.com/bigcommerce.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stencil-lang-validator\n\n[![Build Status](https://travis-ci.org/bigcommerce/stencil-lang-validator.svg?branch=master)](https://travis-ci.org/bigcommerce/stencil-lang-validator)\n\nThe purpose of this module is to validate language keys used in templates and scripts of a Stencil theme. If you use language keys that are not defined in your language files, you will get a warning when you run the validator. It is a static checker intended to be used as a part of your build process.\n\n## Usage\n\nYou can validate your language files directly in your terminal using the CLI of this module.\n\n### CLI\n\nInstall the module globally.\n\n```sh\n$ npm install -g @bigcommerce/stencil-lang-validator\n```\n\nAnd run\n\n```sh\n$ validate-lang --lang-path './lang/*.json' --template-path './templates/**/*.html'\n```\n\nIf there are invalid language keys, you'll see an error report in your console.\n\n```sh\n/codebases/stencil/templates/components/account/messages-form.html\n  2     forms.inbox.send_message is not defined in en-CA.json\n  24    forms.inbox.message is not defined in zh.json\n  25    common.required is not defined in zh.json\n  31    forms.inbox.submit_value is not defined in zh.json\n  32    forms.inbox.clear_value is not defined in zh.json\n\n/codebases/stencil/templates/components/account/messages-list.html\n  1     account.messages.heading is not defined in en.json\n  16    account.messages.merchant_said is not defined in en.json\n  18    account.messages.customer_said is not defined in zh.json\n\n✗ 8 problems found\n```\n\nAlternatively, you can install the module locally and run it using a npm script.\n\n```json\n{\n    \"scripts\": {\n        \"validate-lang\": \"validate-lang --lang-path './lang/*.json' --template-path './templates/**/*.html'\"\n    },\n    \"devDependencies\": {\n        \"@bigcommerce/stencil-lang-validator\": \"^1.0.0\"\n    }\n}\n```\n\n```sh\n$ npm run validate-lang\n```\n\n### Node\n\nInstall the module locally.\n\n```sh\n$ npm install --save-dev @bigcommerce/stencil-lang-validator\n```\n\nAnd import it in your build script.\n\n```js\nconst { LangValidator } = require('@bigcommerce/stencil-lang-validator');\n\nconst validator = LangValidator.create({\n    langPath: './lang/*.json',\n    templatePath: './templates/**/*.html',\n    scriptPath: './assets/**/*.js',\n});\n\nvalidator.validate()\n    .then((result) =\u003e {\n        console.log(result.errors);\n    })\n    .then((error) =\u003e {\n        console.log(error);\n    });\n```\n\n## Options\n\nBelow is a list of options you can pass to the validator.\n\n#### langPath\n\n**Type:** string  \n**Default:** `'lang/*.json'`  \n**CLI:** `--lang-path`  \n**Description:** Configure the path to a language file. Pass a glob pattern to validate multiple files.  \n\n#### templatePath\n\n**Type:** string  \n**Default:** `'templates/**/*.html'`  \n**CLI:** `--template-path`  \n**Description:** Configure the path to a template file. Pass a glob pattern to validate multiple files.  \n\n#### scriptPath\n\n**Type:** string  \n**Default:** `'assets/**/*.js'`  \n**CLI:** `--script-path`  \n**Description:** Configure the path to a script file. Pass a glob pattern to validate multiple files.  \n\n#### helperName\n\n**Type:** string  \n**Default:** `'lang'`  \n**CLI:** `--helper-name`  \n**Description:** Configure the helper name used to retrieve language strings in HTML templates.  \n\n#### instanceName\n\n**Type:** string  \n**Default:** `'langService'`  \n**CLI:** `--instance-name`  \n**Description:** Configure the name of an instance responsible for retrieving language strings in JS files.  \n\n#### methodName\n\n**Type:** string  \n**Default:** `'translate'`  \n**CLI:** `--method-name`  \n**Description:** Configure the name of a method responsible for retrieving language strings in JS files.  \n\n#### langKeyPrefix\n\n**Type:** string  \n**Default:** `''`  \n**CLI:** `--lang-key-prefix`  \n**Description:** Configure the prefix applied to language keys.\n\n## Contributing\n\nIf you want to contribute, please fork this repository and make a PR with your changes.\n\nTo test\n```sh\n$ npm test\n```\n\nTo build\n```sh\n$ npm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fstencil-lang-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigcommerce%2Fstencil-lang-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fstencil-lang-validator/lists"}