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

refactor(macro): use message descriptor for Trans #1909

Merged
merged 4 commits into from May 21, 2024

Conversation

thekip
Copy link
Collaborator

@thekip thekip commented Apr 8, 2024

Description

Use the same message descriptor with /* i18n */ extraction mark in <Trans> component so extractor will support TransNoContext or runtimeConfigModule without explicit knowledge about them.

Take the input:

<Trans>Hello World</Trans>

Before

<Trans id={"mY42CM"} message={"Hello World"} />;

After

<Trans
  {
    /*i18n*/
    ...{
      id: "mY42CM",
      message: "Hello World",
    }
  }
/>

Where

 /*i18n*/
    ...{
      id: "mY42CM",
      message: "Hello World",
    }

Is standard message descriptor used in t transformation.

A side effect of this change is reduced code duplication between js and jsx macro.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Fixes # (issue)

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

Copy link

vercel bot commented Apr 8, 2024

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

Name Status Preview Comments Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2024 10:41am

Copy link

github-actions bot commented Apr 8, 2024

size-limit report 📦

Path Size
./packages/core/dist/index.mjs 2.86 KB (0%)
./packages/detect-locale/dist/index.mjs 723 B (0%)
./packages/react/dist/index.mjs 1.65 KB (0%)
./packages/remote-loader/dist/index.mjs 7.26 KB (0%)

@thekip thekip mentioned this pull request Apr 10, 2024
8 tasks
Comment on lines +3 to +4
describe.skip("", () => {})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this added intentionally to help IDE to understand that this file is executable jest test, otherwise it doesnt have an option to run tests in this file:

image

@andrii-bodnar andrii-bodnar merged commit 4821317 into lingui:next May 21, 2024
14 checks passed
@thekip thekip deleted the refactor/trans-message-descriptor branch May 21, 2024 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants