// ZPWR-I18N — ENGINEERING REPORT

Shared front-end component · vanilla JS, zero dependencies · JSON catalogs, 27 locales · hosts: Tauri + JUCE WebViews

Docs

>_EXECUTIVE SUMMARY

zpwr-i18n is the shared internationalization runtime of the MenkeTechnologies GUI stack — one portable, host-agnostic vanilla-JS file. The appFmt formatter and the applyUiI18n DOM appliers were lifted verbatim from the Audio-Haxor front end (ipc.js + i18n-ui.js); the only change is the loader, which fetches plain JSON catalogs instead of Audio-Haxor's SQLite-backed Tauri command.

Because the loader is just fetch + Object.assign, the same runtime works in Tauri apps (Audio-Haxor, traderview, ztranslator) and JUCE WebViews (synth, fx, midi-fx, daw). It has no build step and no dependencies — it attaches its API to window and never throws on a missing catalog: appFmt falls back to the key so an untranslated UI still reads.

1
Source file
153
Lines (i18n.js)
12
window API symbols
27
Supported locales
4
data-i18n attributes
2
Host runtimes
0
Dependencies
shared
Tier

~ARCHITECTURE

One file, two layers: a verbatim format/apply layer from Audio-Haxor, plus a portable JSON loader. State lives in window.__appStr (aliased window.__toastStr for legacy call sites). Everything else attaches to window.

LayerImplementation
FormatappFmt(key, vars) reads __appStr[key] and interpolates {name} via a single String.replace; missing/empty returns the key. Exposed as appFmt, toastFmt, and t
ApplyapplyUiI18n() walks [data-i18n] / [data-i18n-title] / [data-i18n-placeholder] (+ -regex) elements; placeholder values decode 
/
 to newlines
LoadloadLocale calls fetchCatalog (fetch, cache: 'no-store') for the app catalog, merges each extraBases fragment on top with Object.assign, replaces __appStr, persists, then applies. fetchCatalog returns {} on any error — never throws
DetectdetectLocale: saved choice → exact navigator.languages match → language-only match → en. normalizeUiLocale validates against the frozen SUPPORTED_UI_LOCALES
PersistpersistLocale / savedLocale use the shared window.prefs store when present, else localStorage, under key uiLocale
BootbootI18n(locale?) = loadLocale(locale || detectLocale()); called once after the DOM exists

&WINDOW API SURFACE

12 public symbols on window (plus internal state __appStr / __toastStr and optional config __i18nBase / __i18nExtraBases). No exports, no modules — a classic <script> that populates globals.

SymbolRole
appFmt / toastFmt / tlook up + interpolate a key; three aliases of the same function
applyUiI18napply the catalog to all data-i18n* elements
applyI18nPlaceholdersapply only the placeholder pass (regex-toggle aware)
loadLocalefetch + merge + apply + persist a locale
bootI18nboot convenience: detect then load
mergeI18nCatalogmerge a shared-component fragment on top of __appStr
detectLocale / savedLocalebest initial locale; the persisted choice
normalizeUiLocalevalidate a code against the supported set (else null)
SUPPORTED_UI_LOCALESfrozen array of the 27 shipped locale codes

/LOCALES & CATALOGS

The runtime ships 27 supported locale codes in the frozen SUPPORTED_UI_LOCALES array: cs da de el en es es-419 fi fr hi hu id it ja ko nb nl pl pt pt-BR ro ru sv tr uk vi zh. Catalogs are flat { "namespace.key": "string with {vars}" }, one JSON per locale at <base><locale>.json (default base i18n/). Hyphenated codes map to underscores in the filename via localeFile (es-419es_419.json, pt-BRpt_BR.json). The locale JSON files are shipped by each host application (and by shared components such as zpwr-file-browser, merged via extraBases) — this repo carries the runtime, not the catalogs.


+MARKUP CONTRACT

AttributeEffect
data-i18nsets textContent
data-i18n-titlesets the title attribute
data-i18n-placeholdersets an input placeholder (decodes &#10;/&#13;)
data-i18n-placeholder-regexalternate placeholder when the enclosing .search-box has an active .btn-regex

$CI GATES

zpwr-i18n is a non-Rust shared component, so it skips the Cargo polish gates. The umbrella MenkeTechnologiesMeta repo pins its docs through the house docs-conformance suite:

GatePins
HTML structure<!DOCTYPE html>, charset, html lang="en", viewport + description meta, at least one <h1>
Link hygieneall external href/src are https://; no placeholder hrefs; target="_blank" carries rel="noopener noreferrer"
No inline JSno inline event handlers; behavior lives in hud-theme.js
Brand consistency<title> mentions zpwr-i18n; breadcrumb GitHub URLs point at the owning repo
Cross-linksindex.html and report.html link each other; referenced CSS/JS exist in docs/

#PROJECT METADATA

ItemValue
Runtimevanilla JS (no build step, no bundler)
Sourcewebui/i18n.js — one file, 153 lines, zero dependencies
API12 public symbols on window
Locales27 (SUPPORTED_UI_LOCALES)
HostsTauri WebViews + JUCE WebViews
Originextracted verbatim from the Audio-Haxor front end; JSON loader swapped in
AuthorMenkeTechnologies
Repositorygithub.com/MenkeTechnologies/zpwr-i18n
Meta umbrellaMenkeTechnologiesMeta