-
Notifications
You must be signed in to change notification settings - Fork 494
Add ordinal support #6215
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
base: master
Are you sure you want to change the base?
Add ordinal support #6215
Conversation
|
should use i18n if it deals with string translations, but also universal ordinals are just |
Other languages have different grammatical rules for handling ordinals. Merely substituting what is appended at the end of the number with a different translation doesn't work in all languages. Unless I misunderstood what you were suggesting |
|
Also I'm married to 1st, 2nd etc format ordinals in English due to the design constraints set by Scopa, the UI Lead |
Yes, but i18n is supposed to be able to handle rules more complex than just gluing stuff in a specific order. For example you can do I am suggesting to figure out whether ordinals are supported in our lib.
Ask him what the rules are for languages that don't have these shorthand ordinals and only allow the universal |
|
Does the built-in I18N library pluralization not work for this? Use entries for |
Are you suggesting that I learne how to use a library and a language I do not understand to create a framework for languages that I do not understand using a methodology that isn't directly related to ordinals along guidelines that are vaguely outlined? Sounds like around a month of research and work. This is going to have to be a team lift or I'm not going to do it. |
|
The entry in the translation file would be something like this: "ordinal": {
"one": "st",
"two": "nd",
"few": "th",
"other": "th"
} |
|
That doesn't seem so hard. Where this gets harder is when there's weird rules that apply to specific numbers like 13th 12th instead of 13rd and 12nd, 103rd, 83rd, 22nd, |
|
Maybe instead make them number keys? Look up the number key provided for a translation and if none is available for a custom concatenation, then return "other" |
|
Number keys alone do not inform gender specifics in languages like Spanish. |
|
Sorry, translation file entry should actually be: "place": {
"one": "%{count}st",
"two": "%{count}nd",
"few": "%{count}th",
"other": "%{count}th"
}Then you just pass in the |
What black magic connects the number 1 to the key "one", or in the case of Spanish the female version of 1>"one">"femaleOne" |
No, rules for ordinals are different from cardinal plurals. See https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html It can reuse the existing one/few/many/other format of specifying multiple variants, but the rules for ordinals will have to be added to the i18n lib in parallel to the rules for cardinals with some other magic specifier (cardinals use
For cardinals it's this file https://github.com/beyond-all-reason/Beyond-All-Reason/blob/master/modules/i18n/i18nlib/i18n/plural.lua For ordinals it can look similar, just with a different ruleset and a different magic var. |
|
In this specific case, where we are only appending at most two characters what is the advantage of using i18n library at all if there still needs to be a Lua wrapper to handle the grammatical rules surrounding the i18n get? |
|
Because you aren't appending at most two characters. You're going to have normal translatable sentences (with all the i18n requirement that comes with that) which just happen to have ordinals embedded with them and the ordinals will need the context of the rest of the sentence to make sense (e.g. in gendered languages). |
|
Okay, I'm convinced. I-18n has to be used somehow. What is the minimum scope of work I can get away with to achieve what I want but not have to invent a whole methodology for every language? Sounds like a slippery slope into a month-long project I don't have time for. |
|
That's the thing about I18N, you don't need to. You only add the English content, and the translators take care of the other languages. |
|
Just support for ordinal rulesets has to be added to library, but it can largely be copypasted from existing framework for cardinals and it can only consist of the rule for English for now. |


Territorial Domination will depend on this. Adds 1st, 2nd, 3rd etc ordinal function. Input a number, get a concatenated string back.
Stored as a table keyed with "en", with the intention that each language can be added as a separate entry for example "fr", "du", or whatever spanish is. You can lookup your language key in the widget and use it to get the appopriate ordinal function.
It's up to the widget to revert to english if the language doesn't exist. That's what territorial domination does.
Each language has its own ordinal rules, so this is the ideal and sane way of doing it IMO