- 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
142 lines
3.3 KiB
Go
142 lines
3.3 KiB
Go
package installguide
|
|
|
|
import (
|
|
"syscall"
|
|
"unicode/utf16"
|
|
"unsafe"
|
|
|
|
"github.com/Nwflower/reims-go/internal/i18n"
|
|
)
|
|
|
|
const (
|
|
idTitle = 100
|
|
idBody = 101
|
|
idInputHint = 102
|
|
idCode = 103
|
|
idStage = 104
|
|
idFold = 110
|
|
idLeft = 111
|
|
idRight = 112
|
|
idExtra = 113
|
|
idJump = 114
|
|
wmAction = 0x8001
|
|
)
|
|
|
|
// dialogTemplate emits a minimal Win32 DLGTEMPLATE containing real native
|
|
// controls (for Tab navigation, Enter/Esc, and accessibility). Exact DPI-scaled
|
|
// pixel geometry and typography matching tokens.css are applied in layoutPanel
|
|
// during WM_INITDIALOG.
|
|
func dialogTemplate(p page, c content, locale i18n.Locale) []uint16 {
|
|
const (
|
|
button = 0x80
|
|
label = 0x82
|
|
)
|
|
|
|
// WS_POPUP | WS_CLIPCHILDREN | DS_SETFONT, WS_EX_TOOLWINDOW | WS_EX_LAYERED.
|
|
data := []uint16{0x40, 0x8200, 0x80, 8, 0, 0, 0, 180, 40, 0, 0}
|
|
addString := func(s string) {
|
|
data = append(data, utf16.Encode([]rune(s))...)
|
|
data = append(data, 0)
|
|
}
|
|
addString(c.title)
|
|
data = append(data, 9)
|
|
addString(dialogBaseFontFace(locale))
|
|
item := func(class, id uint16, caption string) {
|
|
if len(data)%2 != 0 {
|
|
data = append(data, 0)
|
|
}
|
|
style := uint16(0x5000) // WS_CHILD | WS_VISIBLE
|
|
var controlStyle uint16
|
|
if class == button {
|
|
style |= 1 // WS_TABSTOP
|
|
controlStyle = 0x0b // BS_OWNERDRAW
|
|
} else {
|
|
controlStyle = 0x0d // SS_OWNERDRAW
|
|
}
|
|
data = append(data, controlStyle, style, 0, 0, 0, 0, 10, 10, id, 0xffff, class)
|
|
addString(caption)
|
|
data = append(data, 0)
|
|
data[4]++
|
|
}
|
|
|
|
if p == compact {
|
|
item(button, idFold, c.right)
|
|
return data
|
|
}
|
|
|
|
if c.stage != "" {
|
|
item(label, idStage, c.stage)
|
|
}
|
|
if c.fold != "" {
|
|
item(button, idFold, c.fold)
|
|
}
|
|
item(label, idTitle, c.title)
|
|
if c.body != "" {
|
|
item(label, idBody, c.body)
|
|
}
|
|
if c.code != "" {
|
|
item(label, idCode, c.code)
|
|
}
|
|
if c.inputHint != "" {
|
|
item(label, idInputHint, c.inputHint)
|
|
}
|
|
if c.left != "" {
|
|
item(button, idLeft, c.left)
|
|
}
|
|
if c.extra != "" {
|
|
item(button, idExtra, c.extra)
|
|
}
|
|
if c.right != "" {
|
|
item(button, idRight, c.right)
|
|
}
|
|
if c.jump != "" {
|
|
item(button, idJump, c.jump)
|
|
}
|
|
return data
|
|
}
|
|
|
|
var dialogProc = syscall.NewCallback(func(hwnd, msg, wp, lp uintptr) uintptr {
|
|
switch msg {
|
|
case 0x0110: // WM_INITDIALOG
|
|
stylePanel(hwnd, lp)
|
|
case 0x0005: // WM_SIZE
|
|
roundPanel(hwnd)
|
|
case 0x02e0: // WM_DPICHANGED
|
|
layoutPanel(hwnd)
|
|
roundPanel(hwnd)
|
|
invalidateRect.Call(hwnd, 0, 0)
|
|
return 1
|
|
case 0x000f: // WM_PAINT
|
|
paintDialogFrame(hwnd)
|
|
return 1
|
|
case 0x0014: // WM_ERASEBKGND (WM_PAINT fills the client area)
|
|
return 1
|
|
case 0x0318: // WM_PRINTCLIENT
|
|
if wp != 0 {
|
|
paintDialogDC(hwnd, wp)
|
|
return 1
|
|
}
|
|
case 0x0136, 0x0138: // WM_CTLCOLORDLG, WM_CTLCOLORSTATIC
|
|
return panelBrush(hwnd, wp)
|
|
case 0x002b: // WM_DRAWITEM
|
|
if lp != 0 {
|
|
var it drawItem
|
|
rtlMoveMemory.Call(uintptr(unsafe.Pointer(&it)), lp, unsafe.Sizeof(it))
|
|
paintItem(&it)
|
|
return 1
|
|
}
|
|
case 0x0111: // WM_COMMAND
|
|
id := wp & 0xffff
|
|
if wp>>16 == 0 && (id == idFold || id == idLeft || id == idRight || id == idExtra || id == idJump || id == 2) {
|
|
postMessage.Call(hwnd, wmAction, id, 0)
|
|
return 1
|
|
}
|
|
case 0x0010: // WM_CLOSE: leave a way to reopen the guide.
|
|
postMessage.Call(hwnd, wmAction, 2, 0)
|
|
return 1
|
|
case 0x0082: // WM_NCDESTROY
|
|
cleanupPanelState(hwnd)
|
|
}
|
|
return 0
|
|
})
|