i18next / i18next-parser

Parse your code to extract translation keys/values and manage your catalog files
MIT License
485 stars 197 forks source link

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

Closed nicegamer7 closed 1 year ago

nicegamer7 commented 1 year ago

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

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% :warning:

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

Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/i18next/i18next-parser/pull/871?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=i18next) | Coverage Δ | | |---|---|---| | [src/lexers/jsx-lexer.js](https://app.codecov.io/gh/i18next/i18next-parser/pull/871?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=i18next#diff-c3JjL2xleGVycy9qc3gtbGV4ZXIuanM=) | `98.45% <100.00%> (-0.01%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

karellm commented 1 year ago

Thanks for the PR, this is deployed as 8.4.0

nicegamer7 commented 1 year ago

Thanks karellm.