{"_id":"@brandup/ui-i18n","_rev":"5-c607951bdbc59e93dd6cd3092227d651","name":"@brandup/ui-i18n","dist-tags":{"latest":"2.0.16"},"versions":{"2.0.11":{"name":"@brandup/ui-i18n","version":"2.0.11","keywords":["brandup","typescript","ui","i18n","localization"],"author":{"name":"Dmitry Kovyazin","email":"it@brandup.online"},"license":"Apache-2.0","_id":"@brandup/ui-i18n@2.0.11","maintainers":[{"name":"dkovyazin","email":"it@brandup.online"}],"homepage":"https://github.com/brandup-online/brandup-ui","bugs":{"url":"https://github.com/brandup-online/brandup-ui/issues","email":"it@brandup.online"},"dist":{"shasum":"3b2a427dbecabd08ddfc6acb2f9bc86376f477e3","tarball":"https://registry.npmjs.org/@brandup/ui-i18n/-/ui-i18n-2.0.11.tgz","fileCount":7,"integrity":"sha512-KzOPylZ4hGvkeJJZ7yJ5pSqKfJ1twcPi5YhbogfYPDxMU1w2kToznvgJubHtqR0i1/EmOzDDZ4T5k67Q89Dg7g==","signatures":[{"sig":"MEUCIQDF7C183T1+MDG/JyOTpl/BXw9Hu0uFgJisZFYmrn0rLAIgNwZPljX1tvxuumCQhnU9i/32cEMJViEM+iwOB5S1I50=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20531},"main":"dist/cjs/index.js","types":"dist/types.d.ts","module":"dist/mjs/index.js","exports":{".":{"types":"./dist/types.d.ts","import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"_npmUser":{"name":"dkovyazin","email":"it@brandup.online"},"repository":{"url":"git+https://github.com/brandup-online/brandup-ui.git","type":"git"},"_npmVersion":"10.9.8","description":"Lightweight type-safe localization for web applications.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"@brandup/ui-helpers":"^2.0.11"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ui-i18n_2.0.11_1789187249426_0.4650923233542006","host":"s3://npm-registry-packages-npm-production"}},"2.0.12":{"name":"@brandup/ui-i18n","version":"2.0.12","keywords":["brandup","typescript","ui","i18n","localization"],"author":{"name":"Dmitry Kovyazin","email":"it@brandup.online"},"license":"Apache-2.0","_id":"@brandup/ui-i18n@2.0.12","maintainers":[{"name":"dkovyazin","email":"it@brandup.online"}],"homepage":"https://github.com/brandup-online/brandup-ui","bugs":{"url":"https://github.com/brandup-online/brandup-ui/issues","email":"it@brandup.online"},"dist":{"shasum":"0a604d014ece2ba8a9fb7b8e912a5e0a7319e131","tarball":"https://registry.npmjs.org/@brandup/ui-i18n/-/ui-i18n-2.0.12.tgz","fileCount":7,"integrity":"sha512-c8qQ4XpdtwobWQ/zC2TKzYTKwPsb2qcZ3Q8yP+4WGkiEzPUXRxd7jaCw04neL9aQOAJLpY/GBIs5YLa1RIJHMg==","signatures":[{"sig":"MEUCIQDehLaxg9z90BkL8RFk2fZQHUyvU7OkJHVQPXyG/yOg0wIgVyMDzeLx7bR/a2omkmjXES6Y+GrIfrEt+22AXzJMCn4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIFTrA1lU9Czym+zNTBGWMlW0AUzoBSzrn4zYWlLlOQ+4AiEAk3WtHSHw9Zmu8+edWJRqYBmk9DtAhXl/YSJp0KKf0XA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20531},"main":"dist/cjs/index.js","types":"dist/types.d.ts","module":"dist/mjs/index.js","exports":{".":{"types":"./dist/types.d.ts","import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"_npmUser":{"name":"dkovyazin","email":"it@brandup.online"},"repository":{"url":"git+https://github.com/brandup-online/brandup-ui.git","type":"git"},"_npmVersion":"10.9.8","description":"Lightweight type-safe localization for web applications.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"@brandup/ui-helpers":"^2.0.12"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ui-i18n_2.0.12_1789192963344_0.13549162687993244","host":"s3://npm-registry-packages-npm-production"}},"2.0.14":{"name":"@brandup/ui-i18n","version":"2.0.14","keywords":["brandup","typescript","ui","i18n","localization"],"author":{"name":"Dmitry Kovyazin","email":"it@brandup.online"},"license":"Apache-2.0","_id":"@brandup/ui-i18n@2.0.14","maintainers":[{"name":"dkovyazin","email":"it@brandup.online"}],"homepage":"https://github.com/brandup-online/brandup-ui","bugs":{"url":"https://github.com/brandup-online/brandup-ui/issues","email":"it@brandup.online"},"dist":{"shasum":"c7a6bbc64b578efd93ec3896b205d69c236db3ce","tarball":"https://registry.npmjs.org/@brandup/ui-i18n/-/ui-i18n-2.0.14.tgz","fileCount":7,"integrity":"sha512-mMkBcP23yx8822orM52wEaO218vxtbjda8er0UqjJjgcovW179nF2bhv2WXQAURl0JwWwSovV6a3sIC2GXASyw==","signatures":[{"sig":"MEUCIE2cGrOZ4whZ2hY7BiXQqZyOm53SdP2uJKcXo4fHP2cmAiEAuSyzbb21swpOyVR9bnvI5cvAjYBpPdeQtaMStpHTa1o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQCeMD+We2VOqomCZJ4XFqgW+4rCuQ5ycMX36+HuqD2pKAIgIRPZGnCQ7RSdAnFwEgJBvNT7jbDx/rvOsipSfNtrSF0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27946},"main":"dist/cjs/index.js","types":"dist/types.d.ts","module":"dist/mjs/index.js","exports":{".":{"types":"./dist/types.d.ts","import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"_npmUser":{"name":"dkovyazin","email":"it@brandup.online"},"repository":{"url":"git+https://github.com/brandup-online/brandup-ui.git","type":"git"},"_npmVersion":"10.9.8","description":"Lightweight type-safe localization for web applications.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"@brandup/ui-helpers":"^2.0.14"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ui-i18n_2.0.14_1789196620977_0.4453461702479651","host":"s3://npm-registry-packages-npm-production"}},"2.0.15":{"name":"@brandup/ui-i18n","version":"2.0.15","keywords":["brandup","typescript","ui","i18n","localization"],"author":{"name":"Dmitry Kovyazin","email":"it@brandup.online"},"license":"Apache-2.0","_id":"@brandup/ui-i18n@2.0.15","maintainers":[{"name":"dkovyazin","email":"it@brandup.online"}],"homepage":"https://github.com/brandup-online/brandup-ui","bugs":{"url":"https://github.com/brandup-online/brandup-ui/issues","email":"it@brandup.online"},"dist":{"shasum":"3399f4636f5b8f5870d4aa96ddcc8a5fbd4dbc18","tarball":"https://registry.npmjs.org/@brandup/ui-i18n/-/ui-i18n-2.0.15.tgz","fileCount":7,"integrity":"sha512-aZ091/fYs3y0y7YRGga2lZg9miLVVOkehepln4nu9i3LNIx9Y3JnmgB8Jv/KgmsFazbH7FP2teGNOk6k+mSsWQ==","signatures":[{"sig":"MEUCIQC3Xplp+O16brsuzQ3TnNXleDuQ0kcaEe82tVmwWCkwxwIgEdvjmkxFCWwsiZrfwKvQVz1LowYtL2mguYz5Ev/Mr0A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQDRE2p5HUWDilJiyDhBvrysIz2TxTOiX/kBx6H+ykYceAIhAO+c5dhQsdNfxFDprDDWpBKfDO+CCRJJ8nnsxXZYxhlA","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27946},"main":"dist/cjs/index.js","types":"dist/types.d.ts","module":"dist/mjs/index.js","exports":{".":{"types":"./dist/types.d.ts","import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"_npmUser":{"name":"dkovyazin","email":"it@brandup.online"},"repository":{"url":"git+https://github.com/brandup-online/brandup-ui.git","type":"git"},"_npmVersion":"10.9.8","description":"Lightweight type-safe localization for web applications.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"@brandup/ui-helpers":"^2.0.15"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ui-i18n_2.0.15_1789197461490_0.6104591113119151","host":"s3://npm-registry-packages-npm-production"}},"2.0.16":{"_id":"@brandup/ui-i18n@2.0.16","bugs":{"url":"https://github.com/brandup-online/brandup-ui/issues","email":"it@brandup.online"},"dist":{"shasum":"4ad73d425990b3e9af9e7e30f78d846004c0b8d1","tarball":"https://registry.npmjs.org/@brandup/ui-i18n/-/ui-i18n-2.0.16.tgz","fileCount":7,"integrity":"sha512-1szFI5xu7e82rhJ1vlBA/lHHWftpWmKBX/tQIqhtaVS8Pxtlx7uM/2UWt80MIqehagDykqSZH2Misw0YNTlMsw==","signatures":[{"sig":"MEYCIQCJmRZleXpeIWKh1FqnQWA8McvVvneCHEGUtBGLxHxRFQIhAMoApWuL9RBuLH4xPHxObSAE7mG371QANZSfPg0pLWb2","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB/Piw9LhwgUNR0XImKTjvpKy8vBsQzHQDQiHZi2F76RAiBMREmvqZWqP0KqvGF9VOS54M3wKeth2CxH2VlxoXaVLg=="}],"unpackedSize":27946},"main":"dist/cjs/index.js","name":"@brandup/ui-i18n","types":"dist/types.d.ts","author":{"name":"Dmitry Kovyazin","email":"it@brandup.online"},"module":"dist/mjs/index.js","exports":{".":{"types":"./dist/types.d.ts","import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"license":"Apache-2.0","version":"2.0.16","_npmUser":{"name":"dkovyazin","email":"it@brandup.online"},"homepage":"https://github.com/brandup-online/brandup-ui","keywords":["brandup","typescript","ui","i18n","localization"],"repository":{"url":"git+https://github.com/brandup-online/brandup-ui.git","type":"git"},"_npmVersion":"10.9.8","description":"Lightweight type-safe localization for web applications.","directories":{},"maintainers":[{"name":"dkovyazin","email":"it@brandup.online"}],"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"@brandup/ui-helpers":"^2.0.16"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ui-i18n_2.0.16_1790283648383_0.3234994673315208"}}},"time":{"created":"2026-09-12T04:27:29.318Z","modified":"2026-09-24T21:00:48.650Z","2.0.11":"2026-09-12T04:27:29.571Z","2.0.12":"2026-09-12T06:02:43.453Z","2.0.14":"2026-09-12T07:03:41.066Z","2.0.15":"2026-09-12T07:17:41.619Z","2.0.16":"2026-09-24T21:00:48.467Z"},"bugs":{"url":"https://github.com/brandup-online/brandup-ui/issues","email":"it@brandup.online"},"author":{"name":"Dmitry Kovyazin","email":"it@brandup.online"},"license":"Apache-2.0","homepage":"https://github.com/brandup-online/brandup-ui","keywords":["brandup","typescript","ui","i18n","localization"],"repository":{"url":"git+https://github.com/brandup-online/brandup-ui.git","type":"git"},"description":"Lightweight type-safe localization for web applications.","maintainers":[{"name":"dkovyazin","email":"it@brandup.online"}],"readme":"# brandup-ui-i18n\n\n[![Build Status](https://dev.azure.com/brandup/BrandUp%20Core/_apis/build/status%2FBrandUp%2Fbrandup-ui?branchName=master)](https://dev.azure.com/brandup/BrandUp%20Core/_build)\n\nLightweight type-safe localization for web applications.\n\nThe engine is generic: it does not know the concrete set of languages, the application passes it to `createI18n`. Keys are extracted from the lambda source (`m => m.a.b.c`), which gives autocomplete and refactoring safety. With `resolveJsonModule` TypeScript checks every dictionary against the model interface, so a missing key is caught at build time.\n\n## Installation\n\nInstall NPM package [@brandup/ui-i18n](https://www.npmjs.com/package/@brandup/ui-i18n).\n\n```bash\nnpm i @brandup/ui-i18n@latest\n```\n\n## Usage\n\n```TypeScript\nimport { createI18n } from \"@brandup/ui-i18n\";\n\nexport type ApplicationLanguage = \"en\" | \"ru\" | \"ar\" | \"zh\";\n\nconst i18n = createI18n<ApplicationLanguage>({\n    lang: document.documentElement.lang, // raw value; region \"ar-SA\" is reduced to \"ar\"\n    supported: [\"en\", \"ru\", \"ar\", \"zh\"],\n    default: \"en\",\n    rtl: [\"ar\"],\n});\n\nexport const { CURRENT_LANG, IS_RTL, buildLocalization } = i18n;\n```\n\nRegister a namespace with lazy dictionary loading (only the current and the default language are loaded):\n\n```TypeScript\ninterface CommonLocaleModel {\n    layout: { footer: { copy: string } };\n}\n\nconst localize = await buildLocalization<CommonLocaleModel>(\n    \"common\", builder => builder\n        .add(\"en\", () => import(\"./en.json\"))\n        .add(\"ru\", () => import(\"./ru.json\"))\n);\n\nlocalize.t(m => m.layout.footer.copy, { year: \"2025\" });\nlocalize.t(\"layout.footer.copy\"); // safe string path\n```\n\n## Behaviour\n\n- **Fallback:** current language, then default language, then the key path itself (shown in the UI instead of crashing).\n- **RTL:** `IS_RTL` for client-side logic; the `dir` attribute on `<html>` is set by the server.\n- **Namespaces:** a name can be registered once; a repeated `buildLocalization` for the same name is rejected, including while the first one is still loading. A build that failed is not cached, so it can be retried.\n- **Testability:** `lang` is accepted as a string, no DOM is required.\n- **Lambda keys:** arrow and transpiled `function` forms are supported, including block bodies. If a minifier ever breaks the parsing, use the string form `t(\"a.b\")`.\n\nDepends on `@brandup/ui-helpers` (`ObjectHelper.getProperty`, `formatText`).\n","readmeFilename":"README.md"}