Skip to content

🐛 fix(task-card): localize task card date independent of dayjs global locale#14730

Merged
arvinxx merged 2 commits into
canaryfrom
fix/task-card-date-locale
May 12, 2026
Merged

🐛 fix(task-card): localize task card date independent of dayjs global locale#14730
arvinxx merged 2 commits into
canaryfrom
fix/task-card-date-locale

Conversation

@arvinxx

@arvinxx arvinxx commented May 12, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • 🐛 fix

🔗 Related Issue

N/A

🔀 Description of Change

Task kanban cards rendered dates like 5月 12 even when the UI language was English.

Root cause: t('time.formatThisYear') correctly returned the English format string MMM D, but dayjs's global locale was still zh-cn, so the MMM token 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 in SPAGlobalProvider/Locale.tsx) or because of a stale stray dayjs.locale(i18n.language) call elsewhere.

This PR threads the i18n language into formatTaskItemDate so the date is rendered with the same locale as the format string, fully decoupled from dayjs's global state.

  • New src/utils/dayjsLocale.ts — single source of truth for the en-us → en / zh → zh-cn alias map.
  • formatTaskItemDate accepts an explicit locale option and applies it via dayjs(time).locale(...).
  • AgentTaskItem passes i18n.language in.
  • SPAGlobalProvider/Locale.tsx reuses the same alias util (no behavior change).

🧪 How to Test

Regression covered by formatTaskItemDate.test.ts: with dayjs's global locale forced to zh-cn, passing locale: 'en-US' still produces May 12, and a Chinese format string with locale: 'zh-CN' produces 5月12日.

  • Tested locally
  • Added/updated tests
  • No tests needed

📸 Screenshots / Videos

Before After
`5月 12` (en UI) `May 12`

🤖 Generated with Claude Code

…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>
@vercel

vercel Bot commented May 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment May 12, 2026 3:29pm

Request Review

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 12, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @arvinxx, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@dosubot dosubot Bot added the i18n label May 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/utils/dayjsLocale.ts

export const normalizeDayjsLocale = (lang: string): string => {
const lower = lang.toLowerCase();
return DAYJS_LOCALE_ALIASES[lower] ?? lower;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.16%. Comparing base (dfb5e01) to head (1df23b7).
⚠️ Report is 2 commits behind head on canary.

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              
Flag Coverage Δ
app 60.57% <94.73%> (+<0.01%) ⬆️
database 91.83% <ø> (?)
packages/agent-runtime 80.48% <ø> (ø)
packages/builtin-tool-lobe-agent 83.41% <ø> (ø)
packages/context-engine 83.99% <ø> (ø)
packages/conversation-flow 92.43% <ø> (ø)
packages/file-loaders 87.60% <ø> (ø)
packages/memory-user-memory 74.74% <ø> (ø)
packages/model-bank 99.94% <ø> (ø)
packages/model-runtime 83.72% <ø> (ø)
packages/prompts 70.39% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/types 5.44% <ø> (ø)
packages/utils 88.02% <ø> (ø)
packages/web-crawler 88.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 66.95% <ø> (ø)
Services 54.16% <ø> (ø)
Server 71.37% <ø> (ø)
Libs 56.16% <ø> (ø)
Utils 82.65% <100.00%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>
@arvinxx arvinxx merged commit b9fb684 into canary May 12, 2026
34 of 35 checks passed
@arvinxx arvinxx deleted the fix/task-card-date-locale branch May 12, 2026 15:31
emaxlele pushed a commit to emaxlele/lobehub that referenced this pull request May 12, 2026
… 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>
arvinxx added a commit that referenced this pull request May 12, 2026
… 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>
lezi-fun pushed a commit to lezi-fun/lobehub that referenced this pull request May 13, 2026
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant