-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Translation improvements: CLDR Plurals + Translatables #19916
Conversation
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Codecov Report
@@ Coverage Diff @@
## main #19916 +/- ##
=======================================
Coverage ? 48.39%
=======================================
Files ? 1038
Lines ? 141321
Branches ? 0
=======================================
Hits ? 68394
Misses ? 64826
Partials ? 8101
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Conflicts resolved. |
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
How that would work with crowdin? When English have two forms but other languages could have 3 or 4? |
example_plural = {{if .Zero}}zero{{else if .One}}one{{else}}other{{end}}form Or add each form individually as example_plural_zero etc. (But I don't think crowdin will let you do that at present.) Locale keys ending in _plural or _ordinal are parsed as go templates once at time of locale reading and the plural forms are extracted as per the forms within that language. |
@lafriks I've updated the description. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Generally L-G-T-M. Could it be better if the |
I think we should try to figure out what works before export things. for example we need to include date and time formatting at some point. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
We need ICU message system #23863, this homemade syntax is impossible to maintain. |
This PR will provide the framework for a few translation improvements.
TranslatableStringer
andTranslatableFormatted
The first thing is the ability to pass in translatable elements - this would allow us (for example) to create an error:
TrPlural
andTrOrdinal
The second part is the creation of
TrPlural
andTrOrdinal
which use the CLDR data to correctly determine plurals for the locales. This is used to replaceTrN
.Plural and ordinal keys can be written as go templates if the key has the suffix
_plural
or_ordinal
:example_plural=common text {{if .One}}Singular{{else}}Other{{end}}
These are interpreted at the time of locale reading and split into the appropriate forms for the language. Alternatively the individual plural forms can be provided separately as
example_plural_one
etc.As the templates are parsed once at locale load time the magic suffix is required - I don't think this is too clunky. It would be possible to make it so we parse the template at time of TrPlural call but that would require the locale storing a text.Template or other locking mechanism, and I think the magic suffix isn't too inconvenient.
(
TrN
has been kept in place to help handle merges and old data.)Fixes #23797