Athena — roomy-mobile/features/archive/2025-12-28-fix-runtime-locale-switching/proposal.md

Change: Fix Runtime Locale Switching

Why

Language switching from English to Dutch (or vice versa) causes inconsistent UI updates because of three different localization access patterns:

  1. gStrings (S.current) - Static, NON-reactive - 364 usages across 57 files
  2. context.strings - Reactive via S.maybeOf(context) - used in some views
  3. S.current direct - Same as gStrings, non-reactive

The gStrings global getter returns a static snapshot that does NOT rebuild widgets when locale changes. Only context.strings (which uses S.maybeOf(context)) creates a dependency on the Localizations InheritedWidget and triggers rebuilds.

What Changes

  • BREAKING: Remove gStrings global accessor entirely
  • Migrate all 364 gStrings usages to appropriate reactive patterns:
    • Widgets/Views: context.strings
    • Enums: Add S strings parameter to label methods
    • Forms: Add _strings getter with context fallback
    • Services: Use S.current (acceptable for error responses captured at generation time)
    • DTOs: Add S strings parameter to factory methods
    • RandomService: Add BuildContext context parameter to methods
  • Delete stale duplicate localization files:
    • lib/l10n/l10n.dart (duplicate of lib/generated/l10n.dart)
    • lib/l10n/intl/messages_all.dart (stale)
    • lib/l10n/intl/messages_en.dart (stale)
  • Update localization documentation

Impact

  • Affected specs: None (this is a bug fix restoring intended localization behavior)
  • Affected code:
    • 57 files containing gStrings usages
    • lib/l10n/globals/g_strings.dart (to be deleted)
    • lib/l10n/l10n.dart (stale duplicate to be deleted)
    • lib/l10n/intl/ directory (stale to be deleted)
    • instructions/how-we-handle-localization.md (documentation update)

Reacties

Nog geen reacties