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

build(t9n): generate json file containing t9n values #7214

Merged
merged 7 commits into from
Jun 25, 2023

Conversation

benelan
Copy link
Member

@benelan benelan commented Jun 23, 2023

Related Issue: #6143

Summary

Generates dist/extras/translations-json.json which contains the t9n values per component in the following format:

{
    "components": {
        "calcite-action": {
            "loading": {
                "en": "Close",
                "es": "Cerrar"
                // ...
            },
            "disabled": {
                "en": "Close",
                "es": "Cerrar"
                // ...
            }
        },
        "calcite-alert": {
            "loading": {
                "en": "Close",
                "es": "Cerrar"
               // ...
            },
            "disabled": {
                "en": "Close",
                "es": "Cerrar"
                // ...
            }
        }
    }
}

@benelan benelan requested a review from a team as a code owner June 23, 2023 05:14
@github-actions github-actions bot added the chore Issues with changes that don't modify src or test files. label Jun 23, 2023
@benelan benelan added skip visual snapshots Pull requests that do not need visual regression testing. chore Issues with changes that don't modify src or test files. tooling Issues relating to build system fixes or improvements. and removed chore Issues with changes that don't modify src or test files. labels Jun 23, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

Looking good! 😎

const t9nPath = resolve(assetsPaths, component, "t9n");
if (existsSync(t9nPath)) {
data[component] = {};
// the english file is the only one without the lang in the filename
Copy link
Member

Choose a reason for hiding this comment

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

English does have a corresponding bundle (see https://github.com/Esri/calcite-components/blob/master/packages/calcite-components/src/components/action/assets/action/t9n/messages_en.json). The one without a language code is the main one.

Could you update the regex pattern to match bundles with or without a language code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh gotcha. What should I be doing with the main one then, does it need to be included? And if so what should I call the key, "main"? cc @macandcheese

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems like messages.json and messages_en.json are always the same, but I created a separate field called main for messages.json anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, in most cases they will be the same. WDYT about omitting main for now until we have a strong reason to include it? Sorry, this would mean reverting the regex update I suggested earlier. 😅

@@ -19,7 +19,7 @@
],
"scripts": {
"build": "npm run util:prep-build-reqs && stencil build",
"postbuild": "npm run util:patch && git restore src/components/*/readme.md",
"postbuild": "npm run util:patch && npm run util:generate-t9n-docs-json && git restore src/components/*/readme.md || true",
Copy link
Member

Choose a reason for hiding this comment

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

Is util:generate-t9n-docs-json throwing unnecessarily or is there another reason for the fallback true?

Copy link
Member Author

Choose a reason for hiding this comment

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

Woops that was left over from my local testing. The docker container I use isn't a git repo so git restore fails. This is my workaround but I forgot to change it back, fixing!

@benelan benelan requested a review from jcfranco June 24, 2023 00:28
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

✨🔧🧰✨ Awesome stuff!

@benelan benelan merged commit 11d93b2 into master Jun 25, 2023
@benelan benelan deleted the benelan/6143-t9n-docs-json branch June 25, 2023 21:52
@github-actions github-actions bot added this to the 2023 June patch priorities milestone Jun 25, 2023
benelan added a commit that referenced this pull request Jun 26, 2023
…nches--master

* origin/master:
  build(t9n): generate json file containing t9n values (#7214)
  chore: release next
  fix(combobox, dropdown, input-date-picker, input-time-picker, popover, tooltip): Prevent repositioning from affecting other floating components (#7178)
  build: update browserslist db (#7192)
  build: ignore node_modules and build outputs when watching for changes during stencil tests (#7209)
benelan added a commit that referenced this pull request Jun 27, 2023
…issue-template-checkbox

* origin/master: (32 commits)
  ci: double build cc when publishing to workaround stencil types bug (#7227)
  build: bump package versions back to 1.5.0-next.5 (#7228)
  chore: release latest (#7144)
  ci: hardcode release version due to reverting feat (#7225)
  fix(tree-item): ensure expanded tree-item is displayed when expanded and made visible (#7216)
  ci(release-please): pin action version and allow manually running action (#7222)
  fix(input, input-number): allows numeric characters. (#7213)
  build(t9n): generate json file containing t9n values (#7214)
  chore: release next
  fix(combobox, dropdown, input-date-picker, input-time-picker, popover, tooltip): Prevent repositioning from affecting other floating components (#7178)
  build: update browserslist db (#7192)
  build: ignore node_modules and build outputs when watching for changes during stencil tests (#7209)
  test: set up `disabled` helper to run a test per use case (#7089)
  ci: set design complete label conditionals (#7206)
  chore: release next
  fix(list): update selectedItems property on all item selection changes (#7204)
  chore: fix sorting logic for t9nmanifest entries (#7203)
  fix(radio-button):  focuses first focusable radio-button element in group. (#7152)
  chore: release next
  fix(alert): update alert queue when an alert is removed from the DOM (#7189)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Issues with changes that don't modify src or test files. skip visual snapshots Pull requests that do not need visual regression testing. tooling Issues relating to build system fixes or improvements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants