View Issue Details

IDProjectCategoryView StatusLast Update
0004205Talerwallet (WebExtension)public2016-10-11 15:28
ReporterFlorian Dold Assigned Totg Resolution deadline
ImplementerReviewer 
Release signed byDeployed by 
VerifierCommunicator 
Data protection authority notification requiredNo  
CSIRT notification requiredNo  
Estimated effort (hours)Actual effort (hours)0 
Fast-trackNo
Work packagenone
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.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

tg

2016-02-25 00:29

reporter   ~0010187

Last edited: 2016-02-25 01:40

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 01: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 13:55

reporter   ~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 13: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 20: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 11:11

reporter   ~0011184

i18.plural() is implemented now as well

Issue History

Date ModifiedUsernameFieldChange
2016-02-24 16:33Florian DoldNew Issue
2016-02-24 16:33Florian DoldStatusnew => assigned
2016-02-24 16:33Florian DoldAssigned To => Florian Dold
2016-02-25 00:29tgNote Added: 0010187
2016-02-25 00:32tgNote Edited: 0010187
2016-02-25 00:32tgNote Edited: 0010187
2016-02-25 00:32tgNote Edited: 0010187
2016-02-25 00:33tgNote Edited: 0010187
2016-02-25 01:40tgNote Edited: 0010187
2016-02-25 19:46Christian GrothoffSeverityminor => feature
2016-02-25 19:46Christian GrothoffProduct Version => 0.0
2016-02-25 19:46Christian GrothoffTarget Version => 0.1
2016-03-02 01:26Florian DoldNote Added: 0010210
2016-03-02 13:55tgNote Added: 0010217
2016-03-02 13:58Florian DoldNote Added: 0010218
2016-03-20 20:53Torsten GrothoffIssue cloned: 0004271
2016-05-31 07:59Christian GrothoffAssigned ToFlorian Dold => tg
2016-09-26 20:59Florian DoldNote Added: 0011181
2016-09-27 11:11tgNote Added: 0011184
2016-09-27 11:11tgStatusassigned => informing
2016-09-27 11:11tgResolutionopen => fixed
2016-09-27 20:25Christian GrothoffFixed in Version => 0.1
2016-10-11 15:28Christian GrothoffStatusinforming => closed
2023-04-13 18:37Florian DoldCategorywallet (WebExtensions) => wallet (WebExtension)