Skip to content

fix: localize dates for all shipped languages (import moment locales) - #147

Open
everysingletear wants to merge 1 commit into
donetick:developfrom
everysingletear:fix/moment-locales
Open

fix: localize dates for all shipped languages (import moment locales)#147
everysingletear wants to merge 1 commit into
donetick:developfrom
everysingletear:fix/moment-locales

Conversation

@everysingletear

Copy link
Copy Markdown
Contributor

Fixes #142.

LocalizationContext calls moment.locale(language) for the active language, but only moment/locale/ja was imported — so moment silently fell back to English date formatting for de, es, fr, nl, pt, zh-CN, ar (only en and ja were localized).

Change

Import each shipped locale statically in src/i18n/config.js, matching the existing moment/locale/ja line.

Why static (not dynamic)

The issue raised static vs dynamic import. I went static because it matches the existing pattern, is trivially reviewable, and moment locale bundles are tiny (a few KB each). If you'd rather keep the main bundle leaner, I'm happy to switch to a dynamic import() of just the active language's locale — just say the word.

Testing

  • npm run build passes; all imported locale files resolve.
  • Switching language to e.g. German now renders month/weekday names and relative times ("2 hours ago" → "vor 2 Stunden") in that language.

Note: ru is intentionally not included here — it comes with the Russian locale PR (#143).

Fixes donetick#142.

`LocalizationContext` calls `moment.locale(language)` for the active
language, but only `he` and `ja` are imported — so moment silently falls
back to English date formatting for the other seven shipped languages:
ar, de, es, fr, nl, pt and zh-CN.

Each locale is imported statically, matching the existing `he`/`ja`
lines. Static rather than dynamic because it matches the current pattern,
is trivially reviewable, and a moment locale bundle is a few KB. Happy to
switch to a dynamic import of just the active language if you'd rather
keep the main bundle leaner.

Rebased on current `develop`: this PR predates your `he` import, and the
list now matches AVAILABLE_LANGUAGES exactly — every non-English entry
there has its moment locale loaded.

`ru` is deliberately absent; it belongs with the Russian locale work.
meauxt pushed a commit that referenced this pull request Aug 27, 2026
Adds `public/locales/ru/*` for all eleven namespaces — auth, chores,
common, filters, history, labels, points, projects, settings, things,
timer — covering every key currently in `public/locales/en` on develop.

Two one-line source changes are needed for it to work:

- `LocalizationContext.jsx` — registers `ru` in AVAILABLE_LANGUAGES, so
  the language shows up in the picker.
- `i18n/config.js` — `import 'moment/locale/ru'`. Without it the UI
  translates but every date stays English, which reads worse than no
  translation at all. This is the same one-line-per-language change as
  #147; only the `ru` line is here so this PR stands alone.

Notes for review:

- Plural forms use the full Russian set (`_one/_few/_many/_other`).
  Russian has four plural categories, not two — with only `_one/_other`
  a count of 5 falls through to `_other` and renders ungrammatically.
- Terminology is held consistent across all namespaces. Donetick uses
  "chore" and "task" for the same object; Russian picks one word and
  keeps it everywhere.
- No English strings were changed, and no keys were added or removed.
- `eslint`, `prettier -c`, `npm run lint:i18n` and `npm run build` are
  all green on this branch.

Supersedes #143, which I closed in August because it covered three
namespaces when there were already eleven.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

Non-English locales render dates in English (moment locale never imported)

1 participant