From bae99fcecd83806c3c33a1c7028552fa65c610af Mon Sep 17 00:00:00 2001 From: Mehedi Hasan <43575088+Mahdi-Hasan@users.noreply.github.com> Date: Fri, 27 Nov 2026 18:38:47 +0000 Subject: [PATCH] fix(i18n): correct Persian calendar week day labels (#15948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 # 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. ## 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. --- .../i18n/src/__tests__/week-days.spec.ts | 48 +++++++++++++++++++ packages/frontend/i18n/src/resources/fa.json | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 packages/frontend/i18n/src/__tests__/week-days.spec.ts diff --git a/packages/frontend/i18n/src/__tests__/week-days.spec.ts b/packages/frontend/i18n/src/__tests__/week-days.spec.ts new file mode 100644 index 0000000000..daf2d222b1 --- /dev/null +++ b/packages/frontend/i18n/src/__tests__/week-days.spec.ts @@ -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); + }); +}); diff --git a/packages/frontend/i18n/src/resources/fa.json b/packages/frontend/i18n/src/resources/fa.json index 08c4a0a078..af85765c7d 100644 --- a/packages/frontend/i18n/src/resources/fa.json +++ b/packages/frontend/i18n/src/resources/fa.json @@ -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": "مجموعه‌ها",