createI18n({ bundles, defaultLocale, defaultTone, initialLocale,
initialTone, onMiss }) → { t, locale, tone, setLocale, setTone,
subscribe, getSnapshot }
Resolution order:
<cur-locale>-<cur-tone>
→ <cur-locale>
→ <default-locale>-<default-tone>
→ <default-locale>
→ raw key (onMiss logs first occurrence)
Typed keys via keyof on the caller-supplied Bundle generic. Tone
bundles are Partial<B> so overrides only need the strings that differ
from the locale bundle — the defaultLocale bundle is the only one
expected to be complete.
React bindings isolated in src/i18n-react.ts so the core ships without
a React peer dep. SSR-safe: constructor takes initial locale/tone
rather than reading from window.
Typecheck clean under strict tsc (ES2020/DOM).
Closes fewo-webapp#416
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
1.1 KiB
JSON
34 lines
1.1 KiB
JSON
{
|
|
"name": "@uschuster/webapp-scaffold",
|
|
"version": "0.3.0",
|
|
"description": "Shared build scripts + Vite config factories for webapp-template-derived projects.",
|
|
"type": "module",
|
|
"bin": {
|
|
"webapp-scaffold-fetch-openapi": "bin/fetch-openapi.sh",
|
|
"webapp-scaffold-postprocess-openapi": "bin/postprocess-openapi.py",
|
|
"webapp-scaffold-inject-hashes": "bin/inject-hashed-filenames.py"
|
|
},
|
|
"main": "src/vite-config.ts",
|
|
"exports": {
|
|
".": "./src/vite-config.ts",
|
|
"./core-fetch": "./src/core-fetch.ts",
|
|
"./i18n": "./src/i18n.ts",
|
|
"./i18n-react": "./src/i18n-react.ts",
|
|
"./orval-template": "./templates/orval.config.template.ts"
|
|
},
|
|
"files": ["bin/", "src/", "templates/", "README.md", "LICENSE"],
|
|
"peerDependencies": {
|
|
"vite": "^6.0.0",
|
|
"@vitejs/plugin-react": "^4.0.0",
|
|
"react": "^19.0.0"
|
|
},
|
|
"peerDependenciesMeta": {
|
|
"react": { "optional": true }
|
|
},
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "http://127.0.0.1:3000/uwe.admin/webapp-scaffold.git"
|
|
},
|
|
"license": "UNLICENSED",
|
|
"private": true
|
|
}
|