Fix misaligned Sinhala day abbreviations - #1336
Conversation
The `day_abbreviations` table for the Sinhala locale is shifted from Tuesday onward. Tuesday carries Wednesday's abbreviation, Thursday carries Friday's, Friday carries Saturday's, and Tuesday's own "අ" ends up in the Saturday slot. As a result Tuesday and Wednesday both render as "බදා", and Thursday has no abbreviation of its own at all. Each abbreviation should be a prefix of the day name it labels. That holds for Monday, Wednesday and Sunday, and fails for the other four, where the value is a prefix of a neighbouring day's name instead. Move the existing entries into their correct slots and add the missing Thursday abbreviation. `test_weekday` asserted that Saturday abbreviates to "අ", which is Tuesday's abbreviation. It was written from the table rather than from the language, so it locked the bug in; it now expects "සෙන".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1336 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2315
Branches 358 358
=========================================
Hits 2315 2315 ☔ View full report in Codecov by Harness. |
|
any update? |
Mukller
left a comment
There was a problem hiding this comment.
Verified locally on the PR branch (Python 3.13): pytest tests/test_locales.py -k "SinhalaLocale" — 7/7 green, including the new per-day abbreviation assertions.
The index-shift diagnosis is correct and the new mapping is linguistically consistent with the full day names:
| isoweekday | day_name | old abbr | new abbr |
|---|---|---|---|
| 1 Monday | සෙනසුරාදා-row | සදුද | සදුද |
| 2 Tuesday | (missing) | අ | |
| 3 Wednesday | බදා | බදා | |
| 4 Thursday | බදා (duplicate!) | බ්රහ | |
| 5 Friday | සිකු | සිකු | |
| 6 Saturday | සෙන | සෙන | |
| 7 Sunday | ඉරිදා | ඉරිදා |
Old table had Tuesday and Thursday sharing "බදා" while Tuesday's own "අ" sat in the Sunday slot and Saturday's "සෙන" was duplicated into the weekend — i.e. everything from Tuesday onward was shifted by one. The new table aligns each abbreviation with its full name (අඟහරුවාදා→අ, බදාදා→බදා, බ්රහස්පතින්දා→බ්රහ), and the updated test_weekday assertion (Saturday → "සෙන", not "අ") pins the correction.
Note this intentionally changes output for Tue–Thu; any consumer hard-coding the old (wrong) abbreviations will see different strings — that's the point of the fix, but worth a changelog line as a behavior change.
|
Thanks for looking. The conclusion matches what I found, but a few rows don't match what's actually in master, so I'll correct them for anyone reading later. Before this change: Monday සදුද, Tuesday බදා, Wednesday බදා, Thursday සිකු, Friday සෙන, Saturday අ, Sunday ඉරිදා. Tuesday wasn't missing an abbreviation, it had Wednesday's. Thursday had Friday's rather than a second බදා. And Tuesday's own අ was in the Saturday slot, not the Sunday one — Sunday was correct all along. So the output changes for Tuesday, Thursday, Friday and Saturday, not Tuesday through Thursday. Wednesday keeps බදා. On the changelog, CHANGELOG.rst looks like something the maintainers write when cutting a release, and recent behaviour fixes like #1242 didn't touch it, so I've left it alone. Happy to add a line if a maintainer wants one. |
The weekday abbreviations in the Sinhala locale don't line up with the days they belong to. From Tuesday onwards they're off by a slot: Tuesday holds Wednesday's abbreviation, Thursday holds Friday's, Friday holds Saturday's, and Tuesday's own one has ended up down in the Saturday slot.
Two things go wrong because of it. Tuesday and Wednesday both come out as
බදා, so you can't tell them apart, and Thursday's abbreviation is missing from the table altogether:You don't have to read Sinhala to see that's wrong. Each abbreviation is meant to be the beginning of the day name it stands for, which is true for Monday, Wednesday and Sunday, but for Tuesday, Thursday, Friday and Saturday it's the beginning of a different day's name instead.
The fix is mostly just putting the existing entries back with the right days. Thursday was the one that had nothing to move back, so I've added
බ්රහ, taken from the front ofබ්රහස්පතින්දාthe same way the others are formed from their day names.I don't speak Sinhala, so I'd rather be clear about which bit is which. The reordering is mechanical and you can check it against the day names without knowing the language. The Thursday abbreviation is the one real judgement call, and if that isn't how it's normally shortened, tell me and I'll change it.
I also had to update
test_weekday. It expected Saturday to abbreviate toඅ, which is actually Tuesday's, so it was written to match the table rather than the language. That's presumably how this survived since the locale was added in #1044. The newtest_day_abbreviationspins all seven, checks each one really is the start of its own day name, and checks they're all distinct.Both tests fail before this change and pass after it. Full suite is green at 1902 passed, and black and flake8 are happy with both files.
One last thing while I was in here: Latvian uses
pifor bothpirmdienaandpiektdiena, and Maltese usesĦfor bothIl-ĦamisandIl-Ħadd. Those are ambiguous rather than out of order, and choosing the right short forms needs someone who speaks the language, so I've left them alone. Happy to open an issue for them if it's worth tracking.