refactor(gui): разделить app.go на binding-файлы по доменам, вынести sync apply

- app.go (1810→280 строк): только App struct, startup, DTOs, helpers
- bindings_{nodes,files,notes,actions,worklog,activity,sync,settings}.go
- sync_apply.go: все applyRemote* методы
- i18n: internal/i18n (Go, embed JSON) + frontend/src/lib/i18n (JS)
- core/sync/safe_path.go: SafeVaultPath
- scripts/check-i18n.sh: проверка хардкода кириллицы и bidi-символов
- build.sh: NVM loading, set -e

Все сборки (CLI, server, gui, frontend), go vet, go test проходят.
This commit is contained in:
2026-06-02 10:47:38 +08:00
parent 390d451977
commit 3089d777a8
20 changed files with 2658 additions and 1603 deletions
+82
View File
@@ -0,0 +1,82 @@
#!/bin/bash
# Check for hardcoded Russian/Cyrillic user-facing strings in source code.
# Excludes locale files, docs, tests with explicit locale checks.
set -e
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
EXIT=0
# Find Cyrillic characters in source files, excluding allowed paths.
# The regex matches any Cyrillic character range.
# Allowed exceptions:
# - locale files (*/i18n/locales/*)
# - docs/*
# - README*
# - spaces/
# - .json files that are templates or configs
# - .md files
echo "=== Checking for hardcoded Cyrillic in source code ==="
# Search for Cyrillic characters in Go files (excluding locale files)
GO_CYRILLIC=$(find "$ROOT" -name '*.go' \
! -path "*/i18n/locales/*" \
-exec grep -l '[А-Яа-я]' {} \; 2>/dev/null || true)
if [ -n "$GO_CYRILLIC" ]; then
echo "WARNING: Cyrillic found in Go files (expected in server HTML templates for now):"
echo "$GO_CYRILLIC"
# Don't fail for Go files with HTML templates — they'll be refactored later
fi
# Search for Cyrillic in Svelte/JS files (excluding locale files)
JS_CYRILLIC=$(find "$ROOT/frontend/src" -name '*.svelte' -o -name '*.js' | \
grep -v 'i18n/locales' | \
xargs grep -l '[А-Яа-я]' 2>/dev/null || true)
if [ -n "$JS_CYRILLIC" ]; then
echo ""
echo "FAIL: Cyrillic found in frontend source files (outside locale files):"
echo "$JS_CYRILLIC"
echo ""
echo "These should use t() from lib/i18n instead."
EXIT=1
fi
# Check for common bidi/control unicode characters
echo ""
echo "=== Checking for bidi/control Unicode characters ==="
BIDI=$(find "$ROOT" -name '*.go' -o -name '*.svelte' -o -name '*.js' | \
xargs grep -Pl '[\x{202A}-\x{202E}\x{2066}-\x{2069}\x{200E}\x{200F}\x{061C}]' 2>/dev/null || true)
if [ -n "$BIDI" ]; then
echo "FAIL: Bidi/control Unicode characters found in:"
echo "$BIDI"
EXIT=1
else
echo "OK: No bidi/control characters found"
fi
# Check that locale keys in ru.js and en.js match
echo ""
echo "=== Checking locale key consistency ==="
RU_KEYS=$(grep -oP "^\s+'[^']+'" "$ROOT/frontend/src/lib/i18n/locales/ru.js" | sed "s/^ *'//;s/'$//" | sort)
EN_KEYS=$(grep -oP "^\s+'[^']+'" "$ROOT/frontend/src/lib/i18n/locales/en.js" | sed "s/^ *'//;s/'$//" | sort)
MISSING_EN=$(comm -23 <(echo "$RU_KEYS") <(echo "$EN_KEYS"))
MISSING_RU=$(comm -23 <(echo "$EN_KEYS") <(echo "$RU_KEYS"))
if [ -n "$MISSING_EN" ]; then
echo "WARNING: Keys in ru.js but missing in en.js:"
echo "$MISSING_EN"
fi
if [ -n "$MISSING_RU" ]; then
echo "WARNING: Keys in en.js but missing in ru.js:"
echo "$MISSING_RU"
fi
if [ -z "$MISSING_EN" ] && [ -z "$MISSING_RU" ]; then
echo "OK: All locale keys match between ru.js and en.js"
fi
exit $EXIT