Skip to content

Ordinals do not work #192

Closed
Closed
@Cimbali

Description

@Cimbali

The docs give the following example:

your-rank = { NUMBER($pos, type: "ordinal") ->
   [1] You finished first!
   [one] You finished {$pos}st
   [two] You finished {$pos}nd
   [few] You finished {$pos}rd
  *[other] You finished {$pos}th
}

Checking via the online editor I see we get the following strings:

1: You finished first!
2: You finished 2nd
3: You finished 3rd
4: You finished 4th
5: You finished 5th
…
20: You finished 20th
21: You finished 21st
22: You finished 22nd
23: You finished 23rd
24: You finished 24rd
25: You finished 25rd

But the python implementation seems to not recognise the type: "ordinal" on the selector and we always get the “other” case:

>>> from fluent.runtime import FluentLocalization, FluentResourceLoader
>>> l10n = FluentLocalization(['en'], ['test.ftl'], FluentResourceLoader('{locale}'))
>>> l10n.format_value('your-rank', {'pos': 1})
'You finished 1th'
>>> l10n.format_value('your-rank', {'pos': 2})
'You finished 2th'
>>> l10n.format_value('your-rank', {'pos': 3})
'You finished 3th'
>>> l10n.format_value('your-rank', {'pos': 5})
'You finished 5th'
>>> l10n.format_value('your-rank', {'pos': 21})
'You finished 21th'
>>> l10n.format_value('your-rank', {'pos': 22})
'You finished 22th'
>>> l10n.format_value('your-rank', {'pos': 23})
'You finished 23th'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions