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

Introduce plurality handling based on message format for ngx-translate schema #2967

Open
rhofer opened this issue Aug 20, 2019 · 8 comments
Open
Labels
enhancement Adding or requesting a new feature. translate-toolkit Issues which need to be fixed in the translate-toolkit

Comments

@rhofer
Copy link
Contributor

rhofer commented Aug 20, 2019

Situation

Having angular applications where ngx-translate is used as translation handler, the basic JSON output is used as translation resource. This itself does not support pluralization. Therefore, plug-ins are available to properly handle this based on ICU MessageFormat.

Request

In order to use ngx-translate with proper pluralization, the schema needs to follow MessageFormat according ICU. Reference:

Example

English source

{
"TIMECOUNT": {
    "YEAR": "{count, plural, one{year} other{years}}"
    }
}

Czech translation

{
"TIMECOUNT": {
    "YEAR": "{count, plural, one{rok} few{roky} other{let}}"
    }
}

Requires

  • importer / exporter for MessageFormat schema as JSON with Weblate

Follow-up to #2855

@nijel nijel added enhancement Adding or requesting a new feature. translate-toolkit Issues which need to be fixed in the translate-toolkit labels Aug 20, 2019
@nijel nijel added this to TODO in File format support via automation Aug 20, 2019
@Artoria2e5
Copy link
Contributor

Should Weblate consider the case where messageformat keys are used only for part of the string, for example with {count, plural, one{One year} other{# years}} ago? What about strings controlled by more than one plurals?

MessageFormat people seems to think that it is a good idea, at least with the myriad possible plural or gender input combinations required. This would mean a very different UI: instead of giving one input boxes for each plural form, Weblate will need to come up with something that lets the user deal with this complexity, preferably visually. For now we can, of course, just treat these as any other variable format string and check for them as such...

@nijel
Copy link
Member

nijel commented Sep 5, 2019

First step should be syntax validation. That way we ensure that translators get correct feedback in case they mess up something. The similar feature will be needed for Fluent (see #1926), but using different syntax.

The UI might come later, once we switch to some rich editor (what is needed for things like #1930 or #443).

@nijel
Copy link
Member

nijel commented Dec 9, 2019

There is even existing Python parser for the syntax: https://github.com/rolepoint/pyseeyou

@Artoria2e5
Copy link
Contributor

Artoria2e5 commented Dec 10, 2019

The pyseeyou grammar has lagged quite a bit compared to the js messageformat PEG. Among other things, we are likely to bump into problems with escapes and general function formatters. There is also a new ordinal class to take care of (I think.) I was planning to update it.

@nijel
Copy link
Member

nijel commented Dec 10, 2019

Thanks for insight, I just found this library when looking for something else and did not investigate it at all. For the reference the related issue is rolepoint/pyseeyou#11

@nijel
Copy link
Member

nijel commented Mar 27, 2020

See also #2856

@berserkwarwolf
Copy link

Any news regarding #3286 ?

@nijel
Copy link
Member

nijel commented Aug 18, 2021

ICU support is being developed in #2856, that could be baseline for implementing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature. translate-toolkit Issues which need to be fixed in the translate-toolkit
Projects
Development

No branches or pull requests

4 participants