mirror of
https://github.com/hanzoai/ui.git
synced 2026-11-21 00:18:41 +00:00
* @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>
72 lines
2.5 KiB
JavaScript
72 lines
2.5 KiB
JavaScript
/**
|
||
* Localized sitemap for ui.hanzo.ai. English is unprefixed; every other locale
|
||
* is `/<locale><path>`. Each URL carries the whole alternate set.
|
||
*
|
||
* node apps/ui.hanzo.ai/scripts/sitemap.mjs
|
||
*/
|
||
import { existsSync, readdirSync, writeFileSync, mkdirSync } from 'node:fs'
|
||
import { dirname, join } from 'node:path'
|
||
import { fileURLToPath } from 'node:url'
|
||
|
||
const app = join(dirname(fileURLToPath(import.meta.url)), '..')
|
||
const origin = 'https://ui.hanzo.ai'
|
||
const LOCALES = ['es', 'fr', 'de', 'it', 'pt-BR', 'ru', 'tr', 'ar', 'hi', 'id', 'vi', 'th', 'ja', 'ko', 'zh-CN', 'zh-TW']
|
||
|
||
function mdx(dir, prefix = '') {
|
||
const out = []
|
||
for (const name of readdirSync(dir)) {
|
||
if (name.endsWith('.mdx')) out.push(prefix + name.replace(/\.mdx$/, ''))
|
||
else {
|
||
try {
|
||
out.push(...mdx(join(dir, name), `${prefix}${name}/`))
|
||
} catch {
|
||
/* file */
|
||
}
|
||
}
|
||
}
|
||
return out
|
||
}
|
||
|
||
function names(dir) {
|
||
if (!existsSync(dir)) return []
|
||
return readdirSync(dir)
|
||
.filter((name) => name.endsWith('.tsx'))
|
||
.map((name) => name.replace(/\.tsx$/, ''))
|
||
}
|
||
|
||
const paths = new Set(['/'])
|
||
for (const slug of mdx(join(app, 'data/docs'))) {
|
||
paths.add(slug === 'index' ? '/docs' : `/docs/${slug}`)
|
||
}
|
||
const groups = ['ui', 'blocks', 'product', 'chat', 'agents', 'settings', 'catalog']
|
||
for (const group of groups) {
|
||
paths.add(`/${group}`)
|
||
const dir = group === 'ui' ? join(app, 'examples') : join(app, 'examples', group)
|
||
for (const name of names(dir)) paths.add(`/${group}/${name}`)
|
||
}
|
||
|
||
const page = (path) => (path === '/' ? '' : path)
|
||
const href = (locale, path) => `${origin}${locale ? `/${locale}` : ''}${page(path) || '/'}`
|
||
const alternates = (path) =>
|
||
[
|
||
['x-default', href(null, path)],
|
||
['en', href(null, path)],
|
||
...LOCALES.map((locale) => [locale, href(locale, path)]),
|
||
]
|
||
.map(([lang, loc]) => ` <xhtml:link rel="alternate" hreflang="${lang}" href="${loc}"/>`)
|
||
.join('\n')
|
||
|
||
const urls = []
|
||
for (const path of [...paths].sort()) {
|
||
const locals = [null, ...LOCALES]
|
||
for (const locale of locals) {
|
||
urls.push(` <url>\n <loc>${href(locale, path)}</loc>\n${alternates(path)}\n </url>`)
|
||
}
|
||
}
|
||
|
||
const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">\n${urls.join('\n')}\n</urlset>\n`
|
||
const dest = join(app, 'public/sitemap.xml')
|
||
mkdirSync(dirname(dest), { recursive: true })
|
||
writeFileSync(dest, xml)
|
||
console.log(`${paths.size} paths × ${LOCALES.length + 1} locales → ${dest}`)
|