Ariver
2026-07-02 2309264ee94daca4b9abe3592d84602c98b77690
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
set -euo pipefail
 
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
 
python3 - "$ROOT_DIR" <<'PY'
import re
import sys
from pathlib import Path
 
root = Path(sys.argv[1])
app_dir = root / "Apptag"
preferences = (app_dir / "PreferencesView.swift").read_text(encoding="utf-8")
app = (app_dir / "ApptagApp.swift").read_text(encoding="utf-8")
 
 
def fail(message: str) -> None:
    raise SystemExit(f"FAIL: {message}")
 
 
def require(source: str, needle: str, message: str) -> None:
    if needle not in source:
        fail(message)
 
 
require(
    app,
    'window.title = tr("menu.preferences").replacingOccurrences(of: "…", with: "")',
    "Settings window must use the localized preferences title at creation",
)
require(
    preferences,
    "private var localizedPreferencesWindowTitle: String",
    "PreferencesView must have a single localized title source",
)
require(
    preferences,
    'tr("menu.preferences").replacingOccurrences(of: "…", with: "")',
    "PreferencesView localized title must use menu.preferences and strip ellipsis",
)
require(
    preferences,
    "private func refreshPreferencesWindowTitle()",
    "PreferencesView must expose a window-title refresh helper",
)
require(
    preferences,
    "preferencesWindow?.title = localizedPreferencesWindowTitle",
    "PreferencesView must write the localized title back to NSWindow.title",
)
require(
    preferences,
    "return window.title == localizedPreferencesWindowTitle",
    "Preferences window fallback detection must reuse the localized title source",
)
 
language_marker = ".onReceive(NotificationCenter.default.publisher(for: .appLanguageDidChange))"
language_start = preferences.find(language_marker)
if language_start == -1:
    fail("PreferencesView must observe appLanguageDidChange")
language_end = preferences.find(".onReceive(NotificationCenter.default.publisher(for: .tagLauncherDataDidChange))", language_start)
if language_end == -1:
    fail("PreferencesView appLanguageDidChange handler must be followed by tagLauncherDataDidChange handler")
language_block = preferences[language_start:language_end]
if "refreshPreferencesWindowTitle()" not in language_block:
    fail("appLanguageDidChange handler must refresh NSWindow.title")
 
root_frame_marker = ".frame(width: settingsWindowWidth, height: settingsWindowHeight)"
root_frame_start = preferences.find(root_frame_marker)
if root_frame_start == -1:
    fail("PreferencesView root frame marker is missing")
appear_marker = ".onAppear {"
appear_start = preferences.find(appear_marker, root_frame_start)
if appear_start == -1:
    fail("PreferencesView must have an onAppear handler")
appear_end = preferences.find(".onDisappear", appear_start)
if appear_end == -1:
    fail("PreferencesView root onAppear must be followed by onDisappear")
appear_block = preferences[appear_start:appear_end]
if "refreshPreferencesWindowTitle()" not in appear_block:
    fail("PreferencesView.onAppear must refresh NSWindow.title for restored windows")
 
if "window.title == tr(\"menu.preferences\")" in preferences:
    fail("PreferencesView must not duplicate raw localized title comparisons")
 
print("PASS Settings language title QA: preferences window title refreshes on appear and language changes")
PY