Skip to content

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

Closed

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

Activity

  1. added
    enhancement
    on Mar 17, 2026
  2. shanselman commented on Mar 17, 2026

    @shanselman
    CollaboratorAuthor

    Implemented in PR #46 (merged). .resw resource files for en-US and zh-CN, x:Uid attributes, LocalizationHelper, all code-behind wired up. Any language can now be added with a single .resw file.

  3. locked as resolved and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions