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

Fix extracting Trans component without key, but with default value #871

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

nicegamer7
Copy link
Contributor

@nicegamer7 nicegamer7 commented Aug 3, 2023

Hi again! Just wanted to thank you for maintaining this project, and for responding so quick to my other PRs.

Why am I submitting this PR

This PR fixes a bug that causes us to extract the keys of Trans components with default values incorrectly.

Take the following example:

<Trans>
  {{ name }}
</Trans>

The above results in the key {{name}}, which is correct. However, if we add a default value, it causes us to extract the key incorrectly:

<Trans defaults="Steve">
  {{ name }}
</Trans>

The above results in a key of Steve, which isn't correct. The key shouldn't change when we provide a default value.

Does it fix an existing ticket?

Possibly fixes #249, but I'm not sure if this is the same issue that the user was describing.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • tests are included and pass: yarn test (see details here)
  • documentation is changed or added

@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (d64d35a) 93.94% compared to head (cdf7397) 93.94%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #871      +/-   ##
==========================================
- Coverage   93.94%   93.94%   -0.01%     
==========================================
  Files          11       11              
  Lines        1833     1832       -1     
==========================================
- Hits         1722     1721       -1     
  Misses        111      111              
Files Changed Coverage Δ
src/lexers/jsx-lexer.js 98.45% <100.00%> (-0.01%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@karellm karellm merged commit 80c3b40 into i18next:master Aug 7, 2023
4 checks passed
@karellm
Copy link
Member

karellm commented Aug 7, 2023

Thanks for the PR, this is deployed as 8.4.0

@nicegamer7
Copy link
Contributor Author

Thanks karellm.

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.

Trans defaults cause variable names to be treated as keys
3 participants