Skip to content

Conversation

@SethDGamre
Copy link
Collaborator

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 15, 2025

Test Results

14 tests  ±0   7 ✅ ±0   10s ⏱️ -1s
 1 suites ±0   7 💤 ±0 
 1 files   ±0   0 ❌ ±0 

Results for commit 489cf33. ± Comparison against base commit c8e20a3.

♻️ This comment has been updated with latest results.

@sprunk
Copy link
Collaborator

sprunk commented Nov 17, 2025

should use i18n if it deals with string translations, but also universal ordinals are just 1., 2. etc

@SethDGamre
Copy link
Collaborator Author

should use i18n if it deals with string translations, but also universal ordinals are just 1., 2. etc

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

@SethDGamre
Copy link
Collaborator Author

Also I'm married to 1st, 2nd etc format ordinals in English due to the design constraints set by Scopa, the UI Lead

@sprunk
Copy link
Collaborator

sprunk commented Nov 18, 2025

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

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

en   = "I am %{name}",
yoda = "%{name}, am I",
jp   = "watashi wa %{name} desu",

I am suggesting to figure out whether ordinals are supported in our lib.

design constraints set by Scopa, the UI Lead

Ask him what the rules are for languages that don't have these shorthand ordinals and only allow the universal 1. 2., and what the rules are for languages have gendered ordinals (e.g. 1st male is 1ster but 1st female is 1stress and such).

@WatchTheFort
Copy link
Member

Does the built-in I18N library pluralization not work for this?
https://github.com/gajop/i18n?tab=readme-ov-file#pluralization
https://www.unicode.org/cldr/charts/48/supplemental/language_plural_rules.html#en

Use entries for one, two, few, and other.

@SethDGamre
Copy link
Collaborator Author

Screenshot_2025-11-18-10-52-05-33_572064f74bd5f9fa804b05334aa4f912
No "1. Place"

@SethDGamre
Copy link
Collaborator Author

SethDGamre commented Nov 18, 2025

Does the built-in I18N library pluralization not work for this? https://github.com/gajop/i18n?tab=readme-ov-file#pluralization https://www.unicode.org/cldr/charts/48/supplemental/language_plural_rules.html#en

Use entries for one, two, few, and other.

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.

@WatchTheFort
Copy link
Member

The entry in the translation file would be something like this:

"ordinal": {
	"one": "st",
	"two": "nd",
	"few": "th",
	"other": "th"
}

@SethDGamre
Copy link
Collaborator Author

SethDGamre commented Nov 18, 2025

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,
English has weird rules. Other languages will have weird rules.
I would need to know those other languages in order to create the framework. If I don't create the framework, then future translators will have to rework the framework and update all of the downstream dependencies

@SethDGamre
Copy link
Collaborator Author

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"

@SethDGamre
Copy link
Collaborator Author

Number keys alone do not inform gender specifics in languages like Spanish.

@WatchTheFort
Copy link
Member

WatchTheFort commented Nov 18, 2025

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 count, and the I18N library automagically handles the rest.

@SethDGamre
Copy link
Collaborator Author

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 count, and the I18N library automagically handles the rest.

What black magic connects the number 1 to the key "one", or in the case of Spanish the female version of 1>"one">"femaleOne"

@sprunk
Copy link
Collaborator

sprunk commented Nov 18, 2025

Does the built-in I18N library pluralization not work for this?

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 %{count}, ordinals could use %{ordinal}? idk).

What black magic connects the number 1 to the key "one", or in the case of Spanish the female version of 1>"one">"femaleOne"

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.

@SethDGamre
Copy link
Collaborator Author

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?

@sprunk
Copy link
Collaborator

sprunk commented Nov 18, 2025

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).

@SethDGamre
Copy link
Collaborator Author

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.

@WatchTheFort
Copy link
Member

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.

@sprunk
Copy link
Collaborator

sprunk commented Nov 19, 2025

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.

@SethDGamre SethDGamre marked this pull request as draft November 20, 2025 00:55
@SethDGamre
Copy link
Collaborator Author

an attempt with vibe coding based on what you guys said and some guidance from myself seems promising. Check the latest commits out.
image

I'll be checking it over more in depth when I've un-bricked quickstart again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants