Skip to content

Conversation

avinxshKD
Copy link

Fixes

Fixes #245 (implements optional task #6)


Summary of Changes

  • Added scripts/validate-locales.js - Node.js script that validates locale folder naming and detects duplicates
  • Integrated locale validation into npm run check workflow (runs automatically with linting)
  • Added standalone npm run validate:locales command for manual validation
  • Updated CONTRIBUTING.md with canonical locale naming guidelines and best practices
  • Prevents future locale duplication conflicts (zh_CN vs zh_Hans, zh_TW vs zh_Hant, etc.)

Screenshots / Demo (if UI-related)

Validation passing with current locales:

Locale Validation Report:

Found 13 locale folder(s): de, en, es, fr, hi, id, ja, pt, pt_BR, ru, vi, zh_CN, zh_TW

All locale folders are valid. No duplicates detected.

Validation catching duplicate (tested with temporary zh_Hans folder):

Locale Validation Report:

Found 14 locale folder(s): de, en, es, fr, hi, id, ja, pt, pt_BR, ru, vi, zh_CN, zh_Hans, zh_TW

Errors found:

Duplicate locale detected: 'zh_Hans' should use 'zh_CN' instead
Conflict: Both 'zh_CN' and 'zh_Hans' exist. Keep only 'zh_CN'

Tip: Use the canonical locale codes defined in Chrome i18n standards.
See: https://developer.chrome.com/docs/extensions/reference/api/i18n


Checklist

  • I've tested my changes locally
  • I've added tests (if applicable)
  • I've updated documentation (if applicable)
  • My code follows the project's code style guidelines

Reviewer Notes

Context: The zh_Hans folder does not currently exist in the repository (may have been removed previously or exists only in Weblate configuration). However, implementing this lint guard prevents the issue from recurring.

Why this solution provides value:

  • Catches duplicate locale codes during development and CI
  • Enforces canonical locale naming per Chrome extension i18n standards
  • Exits with error code 1 if duplicates detected (fails CI pipeline)
  • Also validates that each locale folder contains messages.json
  • Extensible design - easy to add more locale duplicate rules

How to test:

npm install
npm run validate:locales  # Run standalone validation
npm run check            # Run full linting + validation

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @AvinashKumarDeepak, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@github-actions github-actions bot added dependencies Pull requests that update a dependency file documentation config labels Oct 14, 2025
@avinxshKD
Copy link
Author

@mariobehling kindly review

@avinxshKD
Copy link
Author

@rctay @hongquan pls review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config dependencies Pull requests that update a dependency file documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Deduplicate Simplified Chinese locale (zh_CN vs zh_Hans)

1 participant