Files
ui/repair1.py
zeekayGitHubCursor Agentzhanzo-agentHanzo Devhanzo-platform[bot] <201622097+hanzo-platform[bot]@users.noreply.github.com>
fcedaff5b5 Localize built-in UI copy and the docs site (#266)
* @hanzo/ui 8.30.0: every word the package authors is the reader's language

- The consumer installs every peer of the train it pins
- @hanzo/ui 8.30.0: every word the package authors is the reader's language
- i18n: one English fallback, the footer's doors through t, and a typed header cell
- agents: the elements i18n touched draw with gui props, not style
- i18n: @hanzo/ui/product/pure still depends on nothing
- i18n: the framework's collections, records and media say their words in the reader's language
- i18n: one English fallback for the pure modules that build a sentence
- i18n: the builder workspace says its words in the reader's language
- i18n: settings, the catalogue shelf and the backdrop presets
- i18n: the masthead's tree is marked for translation and drawn through t
- i18n: the product layer says its words in the reader's language
- i18n: mockups and market widgets say their words in the reader's language
- i18n: the gui controls say their words in the reader's language
- picker: each choosable option wears the field's own ink
- consent: the bar's fit width is a gui prop
- i18n: onboarding, chat, the model picker, sign-in, consent and the corner speak the reader's language
- i18n: @hanzo/ui peer-depends on @hanzo/i18n

* feat(i18n): localize built-in UI copy and the docs site

English stays the default. A locale on Hanzo or LocaleProvider switches
built-in labels, chat copy, and dates, and Arabic sets dir=rtl. Missing
keys render in English. The docs site adds a language switcher, prefixed
routes, hreflang, and a localized sitemap.

Co-authored-by: z <[email protected]>

* docs: translate every page into the 16 target locales

Each English doc now has a locale file under data/i18n. Code fences,
previews, links, and product names stay as written. A missing file still
falls back to English.

Co-authored-by: z <[email protected]>

* Unfinished: these files still contain <<<<<<< / ======= / >>>>>>> conflict markers on origin/agent/i18n-locales-0366: pk…

Run: sess_498ba60a49b5870a63d042e97f565728

* No conflict markers remain. Now: pull origin agent/i18n-locales-0366 (merge), run pnpm install --frozen-lockfile (if it…

Run: sess_0a7901763139b331895f48f02df95b94

* CI on agent/i18n-locales-0366 head 362214f fails @hanzo/ui tests 1-8, ui browser/vite/webpack. Concrete errors: (a) pkg/…

Run: sess_79bff23928c2986ee61768a243fc6dfa

* fix(ui): Dial RING from look; drop duplicate useI18n in Masthead

Unblocks pkg/ui build on #266: RING lives in ./look (not ./ring); Masthead had a duplicate const { t } = useI18n() after the #254/#287 merge.

* fix(ui): rtl.test ALLOWED counts for Masthead/DiffViewer/SlideOver

Align ALLOWED physical-side budgets with current source after the i18n merge: Masthead 2, DiffViewer 5, SlideOver 1.

* fix(ui): RepoSelect test expects default note + troubleshoot

Co-authored-by: Hanzo Dev <[email protected]>

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: z <[email protected]>
Co-authored-by: hanzo-agent <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: hanzo-platform[bot] <201622097+hanzo-platform[bot]@users.noreply.github.com>
2026-11-05 04:11:17 -08:00

83 lines
4.0 KiB
Python

#!/usr/bin/env python3
"""Repair conflict resolution: union imports, dedupe duplicated blocks."""
import pathlib, re, subprocess
# Files with "Cannot find name" -> restore missing GUI/lucide imports from main
# Files with Duplicate/redeclare -> dedupe
files = subprocess.run(['git','diff','main','--name-only','--','pkg/ui/src/'],
capture_output=True, text=True, cwd='/work').stdout.split()
files = [f for f in files if f.endswith(('.tsx','.ts')) and 'i18n/' not in f and 'index.ts' not in f]
def main_imports(f):
out = subprocess.run(['git','show',f'main:{f}'], capture_output=True, text=True, cwd='/work').stdout
return out
for f in files:
p = pathlib.Path('/work')/f
if not p.exists(): continue
t = p.read_text()
main = main_imports(f)
# 1. Union of import statements: if main has an import line whose text is
# missing in work, reinsert it (except useTranslate / old i18n local imports
# and except imports that conflict with useI18n replacement).
# Collect main import lines
for line in main.splitlines():
s = line.strip()
if not s.startswith('import '): continue
if 'useTranslate' in s or "../i18n" in s or "../../i18n" in s or "./i18n" in s: continue
# only add if that exact import line not present and identifiers used
if s and s not in [l.strip() for l in t.splitlines()]:
# check if any named import in this line is used in t but missing
m = re.search(r'import\s*\{([^}]*)\}\s*from\s*[\'"]([^\'"]+)[\'"]', s)
if m:
names = [n.strip().replace('type ','').split(' as ')[-1] for n in m.group(1).split(',')]
names = [n for n in names if n and n != 'type']
missing = [n for n in names if re.search(rf'\b{n}\b', t)]
if missing:
# insert after first import
t = t.replace('\n', '\n', 1) # noop
lines = t.splitlines(keepends=True)
idx = next((i for i,l in enumerate(lines) if l.strip().startswith('import ')), 0)
lines.insert(idx, line + '\n')
t = ''.join(lines)
elif 'import ' in s and 'from' in s and s not in t:
# side-effect / namespace imports: add if path used? skip unless lucide/gui
if '@hanzo/gui' in s or '@hanzogui/lucide' in s:
lines = t.splitlines(keepends=True)
idx = next((i for i,l in enumerate(lines) if l.strip().startswith('import ')), 0)
lines.insert(idx, line + '\n')
t = ''.join(lines)
# 2. Dedupe exact duplicate import lines (keep first)
seen=set(); out=[]
for ln in t.splitlines(keepends=True):
s=ln.strip()
if s.startswith('import ') and s in seen:
continue
if s.startswith('import '): seen.add(s)
out.append(ln)
t=''.join(out)
# 3. Dedupe consecutive duplicate const { t } = useI18n() (keep first in a run of <=3)
t = re.sub(r'^([ \t]*const\s*\{\s*t\s*\}\s*=\s*useI18n\(\)\n)(\s*const\s*\{\s*t\s*\}\s*=\s*useI18n\(\)\n)+',
r'\1', t, flags=re.M)
# 4. Dedupe duplicate `const { t: tr } = useI18n()` similarly
t = re.sub(r'^([ \t]*const\s*\{\s*t:\s*tr\s*\}\s*=\s*useI18n\(\)\n)(\s*const\s*\{\s*t:\s*tr\s*\}\s*=\s*useI18n\(\)\n)+',
r'\1', t, flags=re.M)
# 5. Remove duplicate `const t = useTranslate()` remnants / duplicate useState etc:
# exact consecutive duplicate lines starting with const and ending properly
lines=t.splitlines(keepends=True)
out=[]
for ln in lines:
if out and out[-1]==ln and 'const ' in ln and ('useI18n()' in ln or 'useTranslate()' in ln):
continue
out.append(ln)
t=''.join(out)
p.write_text(t)
print('repair1 done')
# Report remaining dup t per file
for f in files:
t=(pathlib.Path('/work')/f).read_text()
c=t.count("const { t } = useI18n()")
if c>1:
print(f, c)