- Build single-source-of-truth 7-domain locale catalog (`locales/{zh-CN,en-US}/*.json`, 1,100+ keys) and `cmd/i18ngen` generator emitting Go catalogs and eager/lazy-split TypeScript domain modules (`core`/`vm` eager; `wizard`/`settings`/`plugins` lazy)
- Add zero-dependency ICU MessageFormat subset (`{var}`, `{n, number}`, CLDR `plural`, `select`), 8-hop cycle-free regional fallback (`zh-HK/zh-MO -> zh-Hant -> zh-TW -> zh-CN`), `auto` OS display-language preference, and `en-XA` pseudo-localization across Go and TypeScript
- Introduce `CodedError` supportability with `[E_CODE]` badges, collapsible `[detail]` diagnostics, and automatic SMC OSK / SMBIOS serial / MAC / token redaction
- Add Host × Guest macOS dual-terminology annotation (`FormatGuestTerm`) across 6 official Apple guest UI locales and localize Win32 system tray, file pickers, and DPI-adaptive `installguide` overlays with CJK font fallback probing
- Upgrade L1–L4 plugin localization to dual-track v2: Track A full language packs (`files`, WOFF2 `fonts`, cross-plugin `pluginOverrides`), Track B plugin-scoped `l10n` bundles (`HasUIMessages` isolation), live `plugin/localeChanged` notifications, `< 2ms` static CLI pack loading, and `reims-go plugin locale init|check` translator toolchain with `zh-TW` and `ja-JP` reference packs
- Harden security, WCAG 2.1 AA token contrast, `< 768px` responsive drawer & form layouts, and RTL logical properties; add backend security/locale regression tests and frontend `node --test` static/runtime guard suite in CI
# Conflicts:
# frontend/src/i18n.ts
# internal/cli/cli.go
# internal/i18n/i18n.go
57 lines
2.0 KiB
Go
57 lines
2.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/Nwflower/reims-go/internal/i18n"
|
|
"github.com/Nwflower/reims-go/internal/plugin"
|
|
)
|
|
|
|
func TestCLIPluginLocaleInitAndCheck(t *testing.T) {
|
|
outDir := filepath.Join(t.TempDir(), "ko-pack")
|
|
if err := cmdPluginLocale(i18n.EnUS, []string{"init", "ko-KR", "--out", outDir}); err != nil {
|
|
t.Fatalf("plugin locale init failed: %v", err)
|
|
}
|
|
if _, err := os.Stat(filepath.Join(outDir, "plugin.json")); err != nil {
|
|
t.Fatalf("missing scaffolded plugin.json: %v", err)
|
|
}
|
|
if err := cmdPluginLocale(i18n.EnUS, []string{"check", outDir}); err != nil {
|
|
t.Fatalf("plugin locale check failed on scaffolded pack: %v", err)
|
|
}
|
|
|
|
// Also verify official zh-TW and ja-JP reference packs via CLI `plugin locale check`.
|
|
for _, rel := range []string{
|
|
filepath.Join("..", "plugin", "testdata", "official.lang.zh-tw"),
|
|
filepath.Join("..", "plugin", "testdata", "official.lang.ja-jp"),
|
|
} {
|
|
if err := cmdPluginLocale(i18n.EnUS, []string{"check", rel}); err != nil {
|
|
t.Fatalf("CLI check(%s) failed: %v", rel, err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCLILinkEnableActivatesStaticLocalePackWithoutCrashSentinel(t *testing.T) {
|
|
defer i18n.SetPluginCatalogs(nil)
|
|
dataRoot := t.TempDir()
|
|
jaDir, err := filepath.Abs(filepath.Join("..", "plugin", "testdata", "official.lang.ja-jp"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if code := Main([]string{"--data-root", dataRoot, "plugin", "link", jaDir}); code != 0 {
|
|
t.Fatalf("plugin link exit code = %d", code)
|
|
}
|
|
if code := Main([]string{"--data-root", dataRoot, "plugin", "enable", "official.lang.ja-jp"}); code != 0 {
|
|
t.Fatalf("plugin enable exit code = %d", code)
|
|
}
|
|
if plugin.DidLastStartupCrash(plugin.NewPluginsLayout(dataRoot).Root) {
|
|
t.Fatal("CLI plugin manager left .initializing crash sentinel behind")
|
|
}
|
|
loc, err := run([]string{"--data-root", dataRoot, "--lang", "ja-JP", "--help"})
|
|
if err != nil || loc != i18n.Locale("ja-JP") {
|
|
t.Fatalf("run(--lang ja-JP --help) = (%q, %v), want (ja-JP, nil)", loc, err)
|
|
}
|
|
}
|
|
|