Repository navigation
Label the locales that language and territory cannot tell apart - #1
Conversation
The setup form's prompts are tested against stubs for everything they reach for -- gum, tzupdate, timedatectl -- except the language prompt, which ran the real omarchy-locale-list and so read the host's /usr/share/i18n. That is absent anywhere but Arch, where the list comes back empty and the language assertions fail, and it is a list that moves with glibc everywhere else. Stub it like the rest. The assertions that matter are about the prompt, not about which locales the box building it happens to ship, and pinning the list is what lets them name a locale on purpose: the pair that only an @modifier tells apart is the case worth testing, and asserting it against the host would be asserting that glibc still ships sr_RS@latin. $ROOT/bin was on PATH for that one command and comes back off.
omarchy-locale-list names a locale by its language and territory, and ten of glibc's 327 UTF-8 locales share both with another. The difference is the @modifier the label drops, so the setup form showed "Serbian (Serbia)" on two rows, and matching the chosen label back against a rebuilt one took the first row that matched: all ten modifier-bearing locales were unreachable there, and picking Catalan could not reach Valencian at all. The menu fared better only because it carries the locale name as subtext, which is a name, not an answer. Chinese is ambiguous for a different reason. All four of its locales call their language "Chinese", and nothing on screen said which of Simplified and Traditional a territory implies, so the user had to already know that Taiwan and Hong Kong are Traditional while China and Singapore are not. Both are one shape: the label drops a distinction the locale name keeps. So both go in one qualifier slot -- "Serbian (Serbia, Latin)", "Chinese (Taiwan, Traditional)" -- fed from the two places the distinction can come from. The modifier is read off the name. The script cannot be read off anything: LC_IDENTIFICATION has no script field, so those four are a table, and it stays four entries long because no other language on the list is written two ways. A modifier is appended only where the label is shared, leaving the 313 rows that already name one locale as short as they were. Every modifier-bearing locale glibc ships today does share its label, so today the two rules pick the same rows; the test is the ambiguity rather than the modifier so that a future locale which is the only one of its language and territory keeps the shorter label. The label is a fourth field rather than something each caller builds, because uniqueness is not a property of a row: it depends on the rest of the list, which the caller formatting one row does not have. Both callers were already rebuilding the same label from fields 2 and 3, and the setup form was matching the user's choice against a third rebuild of it. Reading field 4 makes that lookup single-valued and hands the same disambiguation to anything else that lists locales. Measured on glibc 2.44: 327 rows before and after, fields 1 to 3 byte-for-byte unchanged, 14 labels qualified, and now 327 distinct labels where there were 317.
sbelcl
left a comment
There was a problem hiding this comment.
Verified against glibc 2.44: on the base branch 10 of 327 locales were unreachable from the setup form; with this, every label maps back to exactly one locale, and the setup default still resolves to en_US.UTF-8. Both test files pass. Thanks!
|
Thank you, and thank you for the number I did not have. I asserted that the setup form's lookup became single-valued, but I never checked that the default still resolves to Re-ran at your merged head on Arch, glibc 2.44: the tree is identical to the PR head, so the rebase cost nothing. The two things I deliberately left are still yours to take or leave, and both are additive to the slot rather than changes to it: naming the plain row's script ( The shape is yours: the fourth field is where it is because of your "only where it disambiguates" framing, and the invitation on omacom#10949 is why the work exists at all. Thanks for reviewing a patch to your own branch as closely as you reviewed mine. 🤖 Generated with Claude Code |
The
@modifierdisambiguation and the Chinese script hint, againstsystem-languageas you invited in #10949. Two commits: one moves the language prompt's tests off the host, the other does the labelling.The fourth field
You left the side of the line to me, so:
omarchy-locale-listgrows a fourth field carrying the label, and both in-tree callers read it instead of building one.The reason is not convenience, it is that the rule cannot be applied anywhere else. "Append the modifier only where the label is not unique" is not a property of a row: whether
Serbian (Serbia)is ambiguous depends on the other 326 rows, which a caller formatting one row does not have. A caller could only implement it by making a second pass over the whole list, which is the producer's job by then. The script table has the same shape for a different reason: it is knowledge, and three copies of it would be three copies to keep right.It also fixes something I had not spotted when I wrote the review. The setup form matched the user's choice back against a label it rebuilt, and the two rows of each pair rebuilt the same string, so the lookup took the first match. On glibc 2.44 the plain locale won all ten times, which means all ten modifier-bearing locales were unreachable from setup: picking "Serbian (Serbia)" got you
sr_RSwhichever row you clicked, andca_ES@valencia,uz_UZ@cyrillicand the rest could not be chosen at all. Matching on field 4 makes that lookup single-valued, which is the actual fix; the readable label is the visible half of it.Your menu was never wrong, since it carries the locale name as subtext and returns that. It was just asking the user to read
zh_TW.UTF-8and know what it implies.Your plugin keeps working untouched: fields 1 to 3 are byte-for-byte what they were, and opting into the label is a one-line change whenever suits you.
One slot, two sources
You were right that the two fixes share a mechanism. They are one thing: the label drops a distinction the locale name keeps. So there is one qualifier slot, and it is fed from the two places the distinction can come from.
The modifier is read off the name. The script cannot be read off anything, because
LC_IDENTIFICATIONhas no script field, so those four are a table. It stays four entries long becausezhis the only language on the list that is written two ways.What changes on screen
The setup form, for the three ambiguous groups a reader is most likely to recognise:
And typing "Chinese", where the fix is the other source:
14 of 327 rows are qualified, so 313 are the length they were. The longest new label, "Chinese (Hong Kong SAR China, Traditional)" at 42 characters, ties "Lingala (Democratic Republic of the Congo)", which was already there. 327 rows produced 317 distinct labels before and produce 327 now.
The modifier only where it disambiguates
Your framing, kept, with one honest caveat: on glibc 2.44 every modifier-bearing locale does share its label, so today "where the label is shared" and "where there is a modifier" pick exactly the same ten rows, and the guard saves nothing yet. I kept it anyway because it is conditioned on the ambiguity rather than on the spelling, so a future locale that is the only one of its language and territory gets the short label it deserves. There is a test for that case, using
tt_RU@iqtelifwith no plain sibling.Where I stopped
I did not name the plain row's script.
Serbian (Serbia)is still only identifiable by elimination, and a table could say "Cyrillic". I left it because it is not uniformly a script question:@abegedeis an alternative alphabetic order for Ge'ez rather than a second script, sogez_ERhas no other script to be named, and for the rest it would be a claim about ten languages that nothing in the data can check. The slot is where that table would go if you want it, and it is additive.I did not extend the script table past
zh.cmn_TW,hak_TW,lzh_TW,nan_TWandyue_HKare all Traditional, but no row of those languages spans two scripts, so a qualifier would lengthen a label without resolving anything.I did not touch the glibc-complete list, which you said you were leaving alone deliberately, and I agree with the reason.
Tests
The first commit is separable and you may want it either way. The setup form's prompts are tested against stubs for gum, tzupdate and timedatectl, but the language prompt ran the real
omarchy-locale-listand so read the host's/usr/share/i18n, with$ROOT/binonPATHfor that one command. Off Arch that directory does not exist, the list comes back empty and the language assertions fail; on Arch it is a list that moves with glibc. Stubbing it is also what let me pin the pair that only a modifier tells apart, since asserting that against the host would be asserting that glibc still shipssr_RS@latin.bin/omarchy-locale-listtakes anOMARCHY_I18N_PATHoverride so the newtest/shell.d/locale-list-test.shcan point it at a fixture tree, the wayomarchy-windows-keytakesOMARCHY_MSDM_PATH. That test covers each labelling rule by name, asserts every emitted label is unique, and asserts a missing locale tree is still empty rather than fatal.On Arch, glibc 2.44:
The same four failures on both, all environmental: three want an
omarchy-pkgscheckout that is not there, one is an unrelated migration test. The 17 new passes are this branch's assertions../test/clialso fails identically onquattrowhen run on macOS, which is a platform artefact rather than anything either of us did.One thing I could not do: I have no Omarchy box on hand, so none of this was seen in a running session. What I verified instead is the exact strings the two pickers receive, generated from real glibc data, which is what the tables above are.
🤖 Generated with Claude Code