🐛 fix(task-card): localize task card date independent of dayjs global locale#14730
Conversation
…cale
Task card was rendering "5月 12" under English UI because t('time.formatThisYear')
returned the English "MMM D" format, but dayjs's global locale was still zh-cn,
making MMM resolve to the Chinese short month name. Thread the i18n language
into formatTaskItemDate so the date is rendered with the same locale as the
format string, decoupling it from dayjs's global state.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 572c0ddbe7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| export const normalizeDayjsLocale = (lang: string): string => { | ||
| const lower = lang.toLowerCase(); | ||
| return DAYJS_LOCALE_ALIASES[lower] ?? lower; |
There was a problem hiding this comment.
Normalize regional locale codes before formatting
For supported languages such as fr-FR, de-DE, ja-JP, ko-KR, vi-VN, etc., this returns fr-fr/de-de/ja-jp, but SPAGlobalProvider/Locale.tsx only loads Day.js locale modules named fr, de, ja, ko, vi, etc. and Day.js instance .locale() ignores unknown locale keys. In those UI locales the new explicit locale option therefore still formats MMM using the current global locale, so switching from Chinese to French/German can continue to render Chinese month names on task cards instead of the selected language.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #14730 +/- ##
==========================================
+ Coverage 64.56% 66.16% +1.59%
==========================================
Files 2842 2909 +67
Lines 240319 255250 +14931
Branches 23167 25852 +2685
==========================================
+ Hits 155173 168886 +13713
- Misses 84993 86211 +1218
Partials 153 153
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Pre-existing CI regression from #14727 surfacing on every PR: the Run now context menu satisfies-clause references GenericItemType without importing it, and the onClick lacks a MenuInfo annotation, so tsgo widens the divider literal's `type` to `string` and rejects the whole context menu array. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… locale (lobehub#14730) * 🐛 fix(task-card): localize date format independent of dayjs global locale Task card was rendering "5月 12" under English UI because t('time.formatThisYear') returned the English "MMM D" format, but dayjs's global locale was still zh-cn, making MMM resolve to the Chinese short month name. Thread the i18n language into formatTaskItemDate so the date is rendered with the same locale as the format string, decoupling it from dayjs's global state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(task-card): import missing GenericItemType + type Run now onClick Pre-existing CI regression from lobehub#14727 surfacing on every PR: the Run now context menu satisfies-clause references GenericItemType without importing it, and the onClick lacks a MenuInfo annotation, so tsgo widens the divider literal's `type` to `string` and rejects the whole context menu array. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… locale (#14730) * 🐛 fix(task-card): localize date format independent of dayjs global locale Task card was rendering "5月 12" under English UI because t('time.formatThisYear') returned the English "MMM D" format, but dayjs's global locale was still zh-cn, making MMM resolve to the Chinese short month name. Thread the i18n language into formatTaskItemDate so the date is rendered with the same locale as the format string, decoupling it from dayjs's global state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(task-card): import missing GenericItemType + type Run now onClick Pre-existing CI regression from #14727 surfacing on every PR: the Run now context menu satisfies-clause references GenericItemType without importing it, and the onClick lacks a MenuInfo annotation, so tsgo widens the divider literal's `type` to `string` and rejects the whole context menu array. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… locale (lobehub#14730) * 🐛 fix(task-card): localize date format independent of dayjs global locale Task card was rendering "5月 12" under English UI because t('time.formatThisYear') returned the English "MMM D" format, but dayjs's global locale was still zh-cn, making MMM resolve to the Chinese short month name. Thread the i18n language into formatTaskItemDate so the date is rendered with the same locale as the format string, decoupling it from dayjs's global state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(task-card): import missing GenericItemType + type Run now onClick Pre-existing CI regression from lobehub#14727 surfacing on every PR: the Run now context menu satisfies-clause references GenericItemType without importing it, and the onClick lacks a MenuInfo annotation, so tsgo widens the divider literal's `type` to `string` and rejects the whole context menu array. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
💻 Change Type
🔗 Related Issue
N/A
🔀 Description of Change
Task kanban cards rendered dates like
5月 12even when the UI language was English.Root cause:
t('time.formatThisYear')correctly returned the English format stringMMM D, butdayjs's global locale was stillzh-cn, so theMMMtoken rendered as the Chinese short month name (5月). The format-string locale and dayjs's runtime locale could drift apart during a language switch (async dayjs locale loading inSPAGlobalProvider/Locale.tsx) or because of a stale straydayjs.locale(i18n.language)call elsewhere.This PR threads the i18n language into
formatTaskItemDateso the date is rendered with the same locale as the format string, fully decoupled from dayjs's global state.src/utils/dayjsLocale.ts— single source of truth for theen-us → en/zh → zh-cnalias map.formatTaskItemDateaccepts an explicitlocaleoption and applies it viadayjs(time).locale(...).AgentTaskItempassesi18n.languagein.SPAGlobalProvider/Locale.tsxreuses the same alias util (no behavior change).🧪 How to Test
Regression covered by
formatTaskItemDate.test.ts: with dayjs's global locale forced tozh-cn, passinglocale: 'en-US'still producesMay 12, and a Chinese format string withlocale: 'zh-CN'produces5月12日.📸 Screenshots / Videos
🤖 Generated with Claude Code