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: wrong detect whether a translation is plural #1119

Merged
merged 1 commit into from
Aug 30, 2021
Merged

Conversation

truong-hua
Copy link
Contributor

The previous logic is wrong because a language like Vietnamese, Indonesian, Malaysian... does not support plural form, so gettext tools does not allow these kind of to have multiple msgstr. Therefore detecting a plural translation through number of msgstr is not true. As consequence, that causes plural macro can not be replaced with proper translation.

Ex:

#. js-lingui:icu=%7BmonthNumber%2C+plural%2C+one+%7B%2F+%23+th%C3%A1ng%7D+other+%7B%2F+%23+th%C3%A1ng%7D%7D&pluralize_on=monthNumber
msgid "/ # tháng"
msgid_plural "/ # tháng"
msgstr[0] "/ # bulan"

The previous logic is wrong because a language like Vietnamese, Indonesian, Malaysian... does not support plural form, so gettext tools does not allow these kind of to have multiple msgstr. Therefore detecting a plural translation through number of msgstr is not true. As consequence, that causes plural macro can not be replaced with proper translation.

Ex:
```
#. js-lingui:icu=%7BmonthNumber%2C+plural%2C+one+%7B%2F+%23+th%C3%A1ng%7D+other+%7B%2F+%23+th%C3%A1ng%7D%7D&pluralize_on=monthNumber
msgid "/ # tháng"
msgid_plural "/ # tháng"
msgstr[0] "/ # bulan"
```
@vercel
Copy link

vercel bot commented Aug 18, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/lingui-js/js-lingui/9KuNPRVdS1iRt2Hbx2UpL8DhNSC3
✅ Preview: https://js-lingui-git-fork-doopage-main-lingui-js.vercel.app

@codecov
Copy link

codecov bot commented Aug 18, 2021

Codecov Report

Merging #1119 (4559eac) into main (ea00f55) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1119   +/-   ##
=======================================
  Coverage   82.28%   82.28%           
=======================================
  Files          56       56           
  Lines        1677     1677           
  Branches      458      458           
=======================================
  Hits         1380     1380           
  Misses        173      173           
  Partials      124      124           
Impacted Files Coverage Δ
packages/cli/src/api/formats/po-gettext.ts 83.60% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea00f55...4559eac. Read the comment docs.

@truong-hua truong-hua changed the title Fix wrong detect whether a translation is plural fix: wrong detect whether a translation is plural Aug 18, 2021
@semoal
Copy link
Contributor

semoal commented Aug 30, 2021

LGTM, thanks mate

@semoal semoal merged commit 48b6644 into lingui:main Aug 30, 2021
@semoal semoal mentioned this pull request Sep 2, 2021
15 tasks
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