Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dashboard): Setup test and script for validating i18n #9799

Merged
merged 10 commits into from
Nov 4, 2024

Conversation

kasperkristensen
Copy link
Contributor

@kasperkristensen kasperkristensen commented Oct 25, 2024

What

  • Adds a test that validates that en.json and $schema.json matches, this will help us catch missing translations, and prevent us from forgetting to update the schema when we delete/add new keys.
  • Adds a script for validating translations against the translation schema. This can be used to validate that community PRs for i18n contain all the required keys. To use the script you can run yarn i18n:validate <file name> e.g. yarn i18n:validate da.json which will look for a da.json file in the translation folder, and validate it against the schema. We handle this with a script as we don't want to do so through a test. Doing it with a test would mean that if we update the schema, we would also have to update all translations files that we don't maintain ourselves. The purpose of the script is just to allow us to easily review community PRs and also as a tool for people opening PR's to check their translations agains the schema, as it will print missing/additional keys.
  • Also adds a script to generate a schema from the en.json file. After adding/deleting keys to en.json you should run yarn i18n:generate.

Copy link

vercel bot commented Oct 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 4, 2024 9:31am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Nov 4, 2024 9:31am
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Nov 4, 2024 9:31am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Nov 4, 2024 9:31am
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Nov 4, 2024 9:31am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Nov 4, 2024 9:31am
resources-docs ⬜️ Ignored (Inspect) Visit Preview Nov 4, 2024 9:31am

Copy link

changeset-bot bot commented Oct 25, 2024

⚠️ No Changeset found

Latest commit: 95086b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kasperkristensen kasperkristensen changed the title chore(dashboard): Setup test for dashboard i18n chore(dashboard): Setup script for validating dashboard i18n Oct 25, 2024
@kasperkristensen kasperkristensen marked this pull request as ready for review October 25, 2024 15:13
@kasperkristensen kasperkristensen changed the title chore(dashboard): Setup script for validating dashboard i18n chore(dashboard): Setup test and script for validating i18n Oct 29, 2024
Copy link
Member

@sradevski sradevski left a comment

Choose a reason for hiding this comment

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

LGTM, just one comment!

@@ -7,6 +7,9 @@
"build": "tsup && node ./scripts/generate-types.js",
"build:preview": "vite build",
"preview": "vite preview",
"test": "vitest --run",
"i18n:validate": "node ./scripts/i18n/validate-translation.js",
"i18n:schema": "node ./scripts/i18n/generate-schema.js",
Copy link
Member

Choose a reason for hiding this comment

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

I feel like it would be very easy to forget to run this. Should we add a test in our CI that after running this command there are no changes (i.e we haven't forgotten to run it after changing en.json)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what the test I added ensures. It checks if $schema.json === en.json. So if we make an update to en.json or the schema without updating the other the test will fail and block your PR.

@kodiakhq kodiakhq bot merged commit e205868 into develop Nov 4, 2024
23 checks passed
@kodiakhq kodiakhq bot deleted the feat/translation-tests branch November 4, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants