mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-04 10:54:33 +03:00
fix(i18n): correct Persian calendar week day labels (#15948)
## Description
The Persian (`fa`) value of `com.affine.calendar-date-picker.week-days`
was `ش,ی,د,س,چ,ج,ش`. It starts on Saturday (شنبه) and skips Thursday
(پنجشنبه). The date picker renders this string as a Sunday-first
header, so every Persian column was labelled with the wrong day:
| Column | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|---|
| Before | ش (Sat) | ی (Sun) | د (Mon) | س (Tue) | چ (Wed) | ج (Fri) | ش
(Sat) |
| After | ی | د | س | چ | پ | ج | ش |
The new value matches the CLDR narrow weekday names
(`Intl.DateTimeFormat('fa', { weekday: 'narrow' })`).
Tests: added `packages/frontend/i18n/src/__tests__/week-days.spec.ts`.
- Every supported locale has 7 week-day labels.
- Locales with single-character labels (`fa`, `ja`, `ko`) match `Intl`'s
narrow weekday names in Sunday-first order. The `fa` case fails on
current canary and passes with this change.
I checked the other non-Latin locales by hand (ar, kk, tr, ur, zh, ru,
uk, el-GR); they are already Sunday-first.
```
yarn vitest run packages/frontend/i18n/src/__tests__/week-days.spec.ts # 25 passed (fa fails without the fix)
yarn oxlint --deny-warnings packages/frontend/i18n/src/__tests__ # clean
yarn oxfmt --check <changed files> # clean
yarn tsc -b packages/frontend/i18n/tsconfig.json # no errors
```
## Checklist
- [x] I have signed the [AFFiNE Contributor License
Agreement](https://cla-assistant.io/toeverything/AFFiNE) — required
before merge; the `license/cla` check must be green ([how it
works](https://github.com/toeverything/AFFiNE/blob/canary/docs/BUILDING.md#sign-the-cla-first))
- [x] The PR targets the `canary` branch and its title follows
[Conventional Commits](https://www.conventionalcommits.org/)
- [x] Tests are added or updated where it makes sense
- [x] `yarn lint` and `yarn typecheck` pass locally (run on the changed
package)
- [x] If the PR code includes AI-generated edits, I have carefully
reviewed it to ensure that the scope of the PR is consistent with what
is claimed in the title and description, and that there are no redundant
or invalid implementations.
- [x] I agree that maintainers may close the PR without discussion if
they consider the code quality to be too low.
This PR was written with AI assistance and reviewed before submitting.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Corrected the weekday labels shown in the Persian calendar date
picker, providing a consistent sequence of day names.
* The updated labels help users identify weekdays more accurately when
selecting a date.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
1 parent
5444d929c2
commit
bae99fcecd
2 files changed
+49
-1
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import { type Language, SUPPORTED_LANGUAGES } from '../resources';
|
||||
|
||||
// The date picker splits this string and renders it as a Sunday-first header
|
||||
const weekDaysKey = 'com.affine.calendar-date-picker.week-days';
|
||||
|
||||
async function loadWeekDays() {
|
||||
const entries = await Promise.all(
|
||||
Object.entries(SUPPORTED_LANGUAGES).map(async ([locale, { resource }]) => {
|
||||
const loaded =
|
||||
typeof resource === 'function' ? (await resource()).default : resource;
|
||||
return {
|
||||
locale: locale as Language,
|
||||
labels: loaded[weekDaysKey]?.split(/[,،]/).map(label => label.trim()),
|
||||
};
|
||||
})
|
||||
);
|
||||
return entries.filter(
|
||||
(entry): entry is { locale: Language; labels: string[] } => !!entry.labels
|
||||
);
|
||||
}
|
||||
|
||||
const locales = await loadWeekDays();
|
||||
|
||||
describe('calendar week days', () => {
|
||||
test.each(locales)('$locale has seven week days', ({ labels }) => {
|
||||
expect(labels).toHaveLength(7);
|
||||
});
|
||||
|
||||
// Single-character labels can be compared with the platform's narrow
|
||||
// weekday names, which catches labels in the wrong order.
|
||||
test.each(
|
||||
locales.filter(({ labels }) =>
|
||||
labels.every(label => [...label].length === 1)
|
||||
)
|
||||
)('$locale starts on Sunday', ({ locale, labels }) => {
|
||||
const format = new Intl.DateTimeFormat(locale, {
|
||||
weekday: 'narrow',
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
// 2023-01-01 is a Sunday
|
||||
const expected = Array.from({ length: 7 }, (_, day) =>
|
||||
format.format(new Date(Date.UTC(2023, 0, 1 + day)))
|
||||
);
|
||||
expect(labels).toEqual(expected);
|
||||
});
|
||||
});
|
||||
@@ -314,7 +314,7 @@
|
||||
"com.affine.brand.affineCloud": "AFFiNE Cloud",
|
||||
"com.affine.calendar-date-picker.month-names": "ژانویه,فوریه,مارس,آوریل,مه,ژوئن,ژوئیه,اوت,سپتامبر,اکتبر,نوامبر,دسامبر",
|
||||
"com.affine.calendar-date-picker.today": "امروز",
|
||||
"com.affine.calendar-date-picker.week-days": "ش,ی,د,س,چ,ج,ش",
|
||||
"com.affine.calendar-date-picker.week-days": "ی,د,س,چ,پ,ج,ش",
|
||||
"com.affine.cloud-scroll-tip.caption": "میزبان توسط AFFiNE.Pro، ذخیره، همگامسازی و پشتیبانگیری از تمام دادههای شما.",
|
||||
"com.affine.cloud-scroll-tip.title": "AFFiNE Cloud",
|
||||
"com.affine.cmdk.affine.category.affine.collections": "مجموعهها",
|
||||
|
||||
Reference in new issue
Block a user