Skip to content

[Repo Assist] test: validate localization key parity and format placeholdersΒ #70

@github-actions

Description

@github-actions

πŸ€– This is an automated contribution from Repo Assist.

Summary

Adds LocalizationValidationTests to the OpenClaw.Tray.Tests project. These tests guard against regressions in translation PRs β€” especially timely given the active community translation effort driven by issue #61 and PR #69.

What's new

AllLocales_HaveExactlySameKeysAsEnUs
Walks every locale directory under src/OpenClaw.Tray.WinUI/Strings/ and asserts that its Resources.resw file has exactly the same resource keys as en-us. Fails with a clear message listing the first 10 missing or extra keys.

AllLocales_PreserveFormatPlaceholders
For every en-us value that contains {0}, {1}, etc., asserts that the translated value contains the same set of format placeholders. Prevents runtime FormatException from a translator accidentally dropping or duplicating a placeholder.

Both tests auto-discover all locale directories, so no maintenance is needed as new languages are added.

Test Status

Passed! - Failed: 0, Passed: 95, Skipped: 0, Total: 95

2 new tests, all 93 existing tests still pass.

Trade-offs

  • Tests require file system access to the repo tree (same pattern as ReadmeValidationTests). They use OPENCLAW_REPO_ROOT env var or walk up from the binary directory to locate the repo root β€” identical to the existing approach.
  • No new dependencies.

Generated by Repo Assist Β· β—·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch repo-assist/test-localization-validation-e66f5112107f7da5.

Click here to create the pull request

To fix the permissions issue, go to Settings β†’ Actions β†’ General and enable Allow GitHub Actions to create and approve pull requests.

Show patch preview (155 of 155 lines)
From 6449f3bec8f765a397eebb35ada9b1f081f07f14 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 19 Mar 2026 01:00:52 +0000
Subject: [PATCH] test: validate localization key parity and format
 placeholders
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add LocalizationValidationTests to catch regressions in translation PRs:

- AllLocales_HaveExactlySameKeysAsEnUs: asserts every locale under
  Strings/ has exactly the same resource key set as en-us β€” no missing
  or extra entries. Runs against all present locales (zh-cn, and any
  future ones like fr-fr from PR #69).

- AllLocales_PreserveFormatPlaceholders: asserts that {0}/{1}/...
  format placeholders in translated values match the en-us source,
  preventing runtime FormatException from mistranslated strings.

95 Tray tests pass (93 existing + 2 new).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../LocalizationValidationTests.cs            | 117 ++++++++++++++++++
 1 file changed, 117 insertions(+)
 create mode 100644 tests/OpenClaw.Tray.Tests/LocalizationValidationTests.cs

diff --git a/tests/OpenClaw.Tray.Tests/LocalizationValidationTests.cs b/tests/OpenClaw.Tray.Tests/LocalizationValidationTests.cs
new file mode 100644
index 0000000..e758388
--- /dev/null
+++ b/tests/OpenClaw.Tray.Tests/LocalizationValidationTests.cs
@@ -0,0 +1,117 @@
+using System.Text.RegularExpressions;
+using System.Xml.Linq;
+
+namespace OpenClaw.Tray.Tests;
+
+/// <summary>
+/// Validates that all localization resource files are consistent with en-us.
+/// Catches missing/extra keys and broken format placeholders early β€” before translation PRs land.
+/// </summary>
+public class LocalizationValidationTests
+{
+    private static string GetRepositoryRoot()
+    {
+        var envRepoRoot = Environment.GetEnvironmentVariable("OPENCLAW_REPO_ROOT");
+        if (!string.IsNullOrWhiteSpace(envRepoRoot) && Direct
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions