Skip to content

Implement proper localization infrastructure (i18n) with .resw resource files #40

Description

@shanselman

Overview

Implement proper WinUI localization using .resw resource files so any language can be added by contributing a single resource file — no source code changes needed.

Prerequisite: #41 (settings persistence fix) — merged or in progress.

Phase 1: Extract English strings to Resources.resw

XAML strings

  • Create src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw
  • Add x:Uid attributes to all XAML elements with user-visible text in:
    • SettingsWindow.xaml (headers, labels, button text, toggle headers, checkbox content)
    • StatusDetailWindow.xaml (section headers, default text, button text)
    • ActivityStreamWindow.xaml (headers, filter labels, button text)
    • NotificationHistoryWindow.xaml (headers, empty state text)
    • WebChatWindow.xaml (placeholder text)
  • Pattern: <TextBlock x:Uid="StatusHeader" Text="STATUS"/> with StatusHeader.Text = STATUS in .resw

C# runtime strings

  • Create a LocalizationHelper static class with ResourceLoader for C# strings
  • Replace hardcoded strings in:
    • App.xaml.cs: menu items (Settings, Status, Chat, etc.), status labels, channel icons
    • WelcomeDialog.cs: title, body text, button labels
    • UpdateDialog.cs: title, version text, button labels
    • QuickSendDialog.cs: title, placeholder, button text, status messages
    • SettingsWindow.xaml.cs: runtime status strings (Testing..., Connected!, Failed)
    • StatusDetailWindow.xaml.cs: Last check: prefix, Unknown fallback
  • Map ConnectionStatus enum to localized display strings instead of raw .ToString()

Ensure culture-invariant persistence

Phase 2: Add Chinese Simplified translation

  • Create src/OpenClaw.Tray.WinUI/Strings/zh-cn/Resources.resw
  • Populate with translations from @Kobe9312's work in Add Chinese (Simplified) localization #30
  • Windows automatically selects language based on OS locale
  • Verify settings saved on Chinese OS load correctly on English OS

Phase 3: Validation

  • Build and run tests
  • Verify no mixed-language UI on Chinese locale
  • Verify settings round-trip across locales
  • Verify WinForms tray is unaffected (shares settings.json)

Out of scope

  • WinForms tray localization (evaluate separately — may be sunset)
  • Right-to-left layout (future issue)
  • Localizing code comments or README (keep English; translated READMEs as separate files are fine)

References

/cc @Kobe9312

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions