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 getTranslation method for plurals with context #94

Merged
merged 1 commit into from
Apr 3, 2019
Merged

Fix getTranslation method for plurals with context #94

merged 1 commit into from
Apr 3, 2019

Conversation

lukasgeiter
Copy link
Contributor

In case of plural translations that have multiple contexts (one of them being the default context) getTranslation() returns the wrong result. Instead of the correct string it returns the whole array of plural translations. The cause of this is the this part of the method:

if (!(translated instanceof Array) && translated.hasOwnProperty('')) {
      // As things currently stand, the void key means a void context for easygettext.
      translated = [translated['']]
}

This code assumes that the value of translated[''] is a singular message (i.e. a string) and therefore wraps it in an array. This PR fixes this by removing the array and moving the existing normalization logic after this code.

@kemar kemar merged commit 60753e2 into Polyconseil:master Apr 3, 2019
@kemar
Copy link
Contributor

kemar commented Apr 3, 2019

Thank you @lukasgeiter Kudos for the clean explanation and the tests.

I published a new release with your fix: https://github.com/Polyconseil/vue-gettext/releases/tag/v2.1.3

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.

2 participants