View Issue Details

IDProjectCategoryView StatusLast Update
0004205Talerwallet (WebExtensions)public2016-10-11 17:28
ReporterFlorian DoldAssigned Totg 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.0 
Target Version0.1Fixed in Version0.1 
Summary0004205: add i18n.pluralize function
DescriptionRight now pluralization is only handled in .po files, but not at the source level.

There should be a i18n.pluralize function that is detected by the pogen.ts extractor.

It should be used like this:

i18n.pluralize(
  `Hello ${name}, you have ${n} apple`,
  `Hello ${name}, you have ${n} apples`,
   1)

where the first argument is the singular form, the second argument is the plural form, and the third, optional argument is the position of the number that selects the plural/singular form in the format string.

The number of placeholders must be the same in both forms.

If the 3rd argument is omitted, the first numeric placeholder will be used for pluralization.
TagsNo tags attached.

Activities

tg

2016-02-25 01:29

developer   ~0010187

Last edited: 2016-02-25 02:40

View 6 revisions

Implemented the pluralize function the following way:

let i = 1, n = 5;
i18n.pluralize(
  i18n`#${i}: you have ${i18n.number(n)} apple.`,
      `#${i}: you have ${i18n.number(n)} apples.`);

The extraction still needs to be done in pogen.js

Florian Dold

2016-03-02 02:26

manager   ~0010210

So the exact syntax recognized for extraction should be

i18n.pluralize(i18n[.SUFFIX]`STRING1`, i18n.[.SUFFIX]`STRING2`)

The extraction must make sure that the suffix for i18n is the same, and the number of template holes in STRING1 and STRING2 is the same.

tg

2016-03-02 14:55

developer   ~0010217

for the second argument i18n is not necessary,
(it is only used for extraction and thus no processing is needed on it)

Florian Dold

2016-03-02 14:58

manager   ~0010218

Yes it is necessary. When there's no i18n resource for English, we need both strings from the source.

Since sometimes the tag does not return a string (but for example a list of chunks, with i18n.parts), we need to have the tag in both strings for it to work.

Florian Dold

2016-09-26 22:59

manager   ~0011181

Tag parsing is implemented now. The JavaScript runtime part for selecting the singular/plural is still missing, tg should work on that.

tg

2016-09-27 13:11

developer   ~0011184

i18.plural() is implemented now as well

Issue History

Date Modified Username Field Change
2016-02-24 17:33 Florian Dold New Issue
2016-02-24 17:33 Florian Dold Status new => assigned
2016-02-24 17:33 Florian Dold Assigned To => Florian Dold
2016-02-25 01:29 tg Note Added: 0010187
2016-02-25 01:32 tg Note Edited: 0010187 View Revisions
2016-02-25 01:32 tg Note Edited: 0010187 View Revisions
2016-02-25 01:32 tg Note Edited: 0010187 View Revisions
2016-02-25 01:33 tg Note Edited: 0010187 View Revisions
2016-02-25 02:40 tg Note Edited: 0010187 View Revisions
2016-02-25 20:46 Christian Grothoff Severity minor => feature
2016-02-25 20:46 Christian Grothoff Product Version => 0.0
2016-02-25 20:46 Christian Grothoff Target Version => 0.1
2016-03-02 02:26 Florian Dold Note Added: 0010210
2016-03-02 14:55 tg Note Added: 0010217
2016-03-02 14:58 Florian Dold Note Added: 0010218
2016-03-20 21:53 Torsten Grothoff Issue cloned: 0004271
2016-05-31 09:59 Christian Grothoff Assigned To Florian Dold => tg
2016-09-26 22:59 Florian Dold Note Added: 0011181
2016-09-27 13:11 tg Note Added: 0011184
2016-09-27 13:11 tg Status assigned => resolved
2016-09-27 13:11 tg Resolution open => fixed
2016-09-27 22:25 Christian Grothoff Fixed in Version => 0.1
2016-10-11 17:28 Christian Grothoff Status resolved => closed