Skip to content

Fix i18n locale-aware formatting and add test suite - #8

Merged
Carl723000 merged 5 commits into
ClaudeCodeUsage:mainfrom
nickearnshaw:fix-i18n-monthly-date-format
Jun 15, 2026
Merged

Carl723000 merged 5 commits into
ClaudeCodeUsage:mainfrom
nickearnshaw:fix-i18n-monthly-date-format

Conversation

@nickearnshaw

@nickearnshaw nickearnshaw commented Feb 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix locale-aware date and number formatting throughout the codebase
  • Ensure all toLocaleString(), toLocaleDateString() calls use explicit locale parameter
  • Add getSupportedLanguages() method to I18n class
  • Add comprehensive i18n test suite with 34 tests covering:
    • Translation completeness across all languages
    • Translation quality (no empty/null values)
    • Locale mapping validation
    • formatNumber and formatCurrency functions
    • Language detection from environment variables
    • Source code validation for locale-aware formatting

Test plan

  • All 34 tests pass with npm test
  • Verified locale-specific formatting works correctly (e.g., German uses period as thousands separator)

🤖 Generated with Claude Code

nickearnshaw and others added 5 commits February 28, 2026 18:39
- Replace hardcoded Chinese date format (YYYY年MM月) with locale-aware formatting
- Add getLocaleString() helper to map i18n language codes to proper locale strings
- Pass translation strings to client-side JavaScript for dynamic content
- Add new translation keys: time, loading, showHourlyDetails, showDailyDetails,
  clickForHourlyDetails, clickForDailyDetails
- Replace all hardcoded Chinese strings in webview templates and JavaScript
- Fix toLocaleDateString() calls to use current locale instead of system default

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add missing translation keys: noChartData, noUsageRecords, unknownError
- Fix incomplete German translations (error, currentSession)
- Fix formatNumber() to respect user's language setting
- Replace hardcoded English strings in extension.ts and webview.ts
- Consolidate getLocaleString() into I18n class to avoid duplication

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add clickForDetails translation key for status bar tooltip
- Fix all JavaScript toLocaleString() calls to use currentLocale
- Fix toLocaleDateString() in chart tooltip to use currentLocale
- Ensure number formatting in dynamic tables respects user's language

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add mocha, ts-node, and @types/mocha for testing
- Create i18n.test.ts with 34 tests covering:
  - Translation completeness across all languages
  - Translation quality (no empty/null values)
  - Locale mapping validation
  - formatNumber and formatCurrency functions
  - Language detection from environment
  - Source code validation for locale-aware formatting
- Add getSupportedLanguages() to I18n class
- Add GitHub Actions workflow to run tests on push/PR

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nickearnshaw nickearnshaw changed the title Add comprehensive i18n test suite with GitHub Actions CI Fix i18n locale-aware formatting and add test suite Feb 28, 2026
@faangbait

Copy link
Copy Markdown

related: #10

@Carl723000

Copy link
Copy Markdown
Collaborator

Hi @nickearnshaw — your point about locale-aware formatting was spot on, and v2.0.0 carries the same direction across every toLocaleString and toLocaleDateString call site.

Closing here in favour of the consolidated PR. The German . vs. English , point in particular was a needed nudge — thanks for raising it.

@Carl723000 Carl723000 closed this May 29, 2026
@Carl723000 Carl723000 reopened this Jun 15, 2026
@Carl723000
Carl723000 merged commit 58f7026 into ClaudeCodeUsage:main Jun 15, 2026
1 check passed
@Carl723000

Copy link
Copy Markdown
Collaborator

Reopened and merged this properly. Thanks again for the contribution.

@Carl723000 Carl723000 added the skip-changelog Exclude from auto-generated release notes label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Exclude from auto-generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants