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: keep default values that may have been set #382

Merged
merged 2 commits into from
May 1, 2020

Conversation

jenniferarnesen
Copy link
Contributor

The i18next-scanner parser will set default values for a string if they are provided (including for plurals).

This fix will copy any default values into the json that is used to generate the en.pot file.

Then we can have code in our apps like this:

const likes = i18n.t(
    '{{count}} likes',
    { 
        count: numLikes,
        defaultValue: '{{count}} like',
        defaultValue_plural: '{{count}} likes'
    });

This results in the following in the en.pot file:

msgid "{{count}} likes"
msgid_plural "{{count}} likes"
msgstr[0] "{{count}} like"
msgstr[1] "{{count}} likes"

Ultimately in the app, we end up with these strings: 1 like and 2 likes as default.

Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

Looks good, let’s give this a shot!

@jenniferarnesen jenniferarnesen merged commit 4b6e275 into master May 1, 2020
@jenniferarnesen jenniferarnesen deleted the fix/plural-default-translations branch May 1, 2020 15:35
dhis2-bot added a commit that referenced this pull request May 1, 2020
## [4.0.3](v4.0.2...v4.0.3) (2020-05-01)

### Bug Fixes

* keep default values that may have been set ([#382](#382)) ([4b6e275](4b6e275))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 4.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

jenniferarnesen added a commit that referenced this pull request Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants