Skip to content

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

Open
nickearnshaw wants to merge 5 commits intojack21:mainfrom
nickearnshaw:fix-i18n-monthly-date-format
Open

Fix i18n locale-aware formatting and add test suite#8
nickearnshaw wants to merge 5 commits intojack21:mainfrom
nickearnshaw:fix-i18n-monthly-date-format

Conversation

@nickearnshaw
Copy link
Contributor

@nickearnshaw nickearnshaw commented Feb 28, 2026

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