Skip to content

Localize due-date and repeat chips - #386

Open
hoge6b01 wants to merge 1 commit into
donetick:developfrom
hoge6b01:fix/localize-dates-and-recurrence
Open

hoge6b01 wants to merge 1 commit into
donetick:developfrom
hoge6b01:fix/localize-dates-and-recurrence

Conversation

@hoge6b01

@hoge6b01 hoge6b01 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Due-date and repeat chips on task cards (Home, task list, project rows and board cards) were always English, whatever language was selected: "15 hours ago", "Tomorrow 07:30", "Weekly", "Daily except Sat, Sun". This PR localizes them and fixes three bugs I found along the way.

Root causes

  1. moment locales were never registered. src/i18n/config.js imported moment/locale/<lang>. Under Vite, import moment from 'moment' resolves to the ESM build (moment/dist/moment.js), but the UMD files in moment/locale/ require('../moment'), which is a second CommonJS copy. The locales were registered on that copy and moment.locale('de') quietly fell back to English. The existing imports (cs, he, ru, ja, es, pl, it) never worked either. They now come from moment/dist/locale/*, which share the app's instance. The production bundle now holds a single moment copy.
  2. Missing locales. de, ar, fr, nl, pt-br and zh-cn were not imported at all. pt maps to moment's pt-br, because the app offers it as Portuguese (Brazil).
  3. Weekdays and months were parsed in the active locale. getRecurrentChipText passed stored English names to moment().day('monday') / moment().month('march'). These parse with the current locale, so in any other language every day turned into Sunday and every month into the current one. With the locale fix, German would have hit this too. Days and months are now converted to indexes first.
  4. useDateFormatter reset the global locale. moment.updateLocale('en', …) also makes en the global locale, so opening the archive turned every date in the app back to English. The previous locale is now restored.

Changes

  • ChoreCardHelpers: "Today/Tomorrow/Yesterday", "N days", "No Due Date", the frequency names, "Daily except …", "Monthly … except …" and "Every N …" now go through i18next. Ordinals use moment.localeData().ordinal() instead of the English st/nd/rd/th. Date-only chips no longer cut the calendar label at the first space, which broke multi-word translations.
  • CompactChoreCard no longer passes an unused t as a fourth argument to getDueDateChipText.
  • LocalizationContext.formatCalendar uses the same translated calendar words, including "Last {{day}}".
  • Arabic keeps Western digits (postformat is overridden). This is needed for correctness, not just for looks: with the stock ar locale, moment().format() returns ٢٠٢٦-١١-٠٩T١٨:٠٠:٠٠+٠١:٠٠, and RepeatSection/RepeatPickerField send such strings to the API. It also keeps moment output consistent with the counts and inputs in the rest of the UI.
  • New keys: common.calendar.*, chores.dueChip.* and chores.repeatChip.*. They are translated into all base locales (ar, cs, de, es, fr, he, it, ja, nl, pl, pt, ru, zh) with every plural category each language needs. Exactly one interval unit ("Every week") has its own repeatChip.everyUnit.* key. Reusing the _one plural form for it would be wrong in Russian, which uses that form for 21, 31, … as well.

Testing

  • New tests/chore-card-helpers.test.mjs runs the real helpers against real moment locales and i18next loaded with the shipped locale files. It covers weekday/month names, daily-except, ordinals, plural forms (including the Arabic dual) and calendar words. It also checks that every locale with the new strings has all of its plural categories. 6 of the 8 tests fail against the old helper on develop.
  • node --test tests/*.test.mjs shows no new failures compared to develop.
  • npx eslint and npx prettier -c on the changed files, npm run lint:i18n and scripts/i18n/i18n-pr-safety.mjs all pass. The safety check gives one warning: Dutch "Trigger" equals the English text, which is intended.
  • vite build succeeds.
  • Checked Home in a headless browser in German and Arabic (RTL), light and dark, mobile and desktop. The chips now read "vor 15 Stunden", "Morgen 07:30", "Mo., Do., Sa., So.", "Wöchentlich", or "منذ 15 ساعة", "غدًا 7:30 ص". German survives a visit to the archive.

Claude (Anthropic's AI assistant) helped with the analysis, implementation and translations; I reviewed all changes.

🤖 Generated with Claude Code

@hoge6b01
hoge6b01 force-pushed the fix/localize-dates-and-recurrence branch 2 times, most recently from 8e45663 to d1e61d8 Compare November 25, 2026 07:07
Task cards always showed "15 hours ago", "Tomorrow 07:30" or "Daily
except Sat, Sun" in English, whatever the language:

- moment locales were imported from moment/locale/*, whose UMD files
  register on a second CommonJS copy of moment under Vite, so none of
  them ever applied. Import from moment/dist/locale/* instead and add
  the missing ar, de, fr, nl, pt-br and zh-cn.
- Chip helpers hardcoded English words and parsed stored day and month
  names with the active locale (every day became Sunday outside
  English). They now use i18next and index-based day/month lookups.
- useDateFormatter reset the global moment locale to English via
  updateLocale.
- Arabic keeps Western digits so ISO strings sent to the API stay
  machine-readable.

New keys are translated into all base locales with each language's
plural categories.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hoge6b01
hoge6b01 force-pushed the fix/localize-dates-and-recurrence branch from d1e61d8 to 5edb00d Compare December 1, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant