{"_id":"@bedrock-core/i18n","name":"@bedrock-core/i18n","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@bedrock-core/i18n","version":"0.1.0","description":"Localization for Minecraft Bedrock: typed keys, interpolation and plurals, resolved client-side per player","keywords":["i18n","i18next","localization","minecraft","bedrock","typescript"],"license":"MIT","author":{"name":"DrAv0011"},"contributors":[{"name":"DrAv0011","email":"contact@drav.dev","url":"https://drav.dev"}],"repository":{"type":"git","url":"git+https://github.com/bedrock-core/ui.git"},"type":"module","main":"src/index.ts","types":"src/index.ts","exports":{".":{"types":"./src/index.ts","import":"./src/index.ts"}},"publishConfig":{"access":"public"},"sideEffects":false,"scripts":{"build":"tsc -p tsconfig.json","lint":"eslint .","test":"vitest run","coverage":"vitest run --coverage"},"devDependencies":{"@minecraft/server":"2.8.0","typescript":"^6.0.3","vitest":"^4.1.5"},"peerDependencies":{"@minecraft/server":">=2.8.0"},"gitHead":"bf5d114faa49533b1bb776c4ff0c95e547009c99","_id":"@bedrock-core/i18n@0.1.0","bugs":{"url":"https://github.com/bedrock-core/ui/issues"},"homepage":"https://github.com/bedrock-core/ui#readme","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-DmK+7mQfa6NgTZ+99x222M6cIAv+V5NOTQJIhzYmx3DlJxQwAhfgCKfOQCva6e6x+JbXnJtLA73WFR5HcuJVDQ==","shasum":"eaca98a024eae9ebe02d7eddef08d5d7bb68862a","tarball":"https://registry.npmjs.org/@bedrock-core/i18n/-/i18n-0.1.0.tgz","fileCount":18,"unpackedSize":57491,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBu/7gxJUiqLI5osbF15YYhB+XD3SXN2JTF+iwR1IE/jAiEAvphGvQMs+Ecf6nYU18hoHNeLo3xIRahcKKbdYOgg8vE="}]},"_npmUser":{"name":"drav0011","email":"drav0011@gmail.com"},"directories":{},"maintainers":[{"name":"drav0011","email":"drav0011@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/i18n_0.1.0_1787100085548_0.6385204360539669"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-19T00:41:25.242Z","0.1.0":"2026-08-19T00:41:25.689Z","modified":"2026-08-19T00:41:25.963Z"},"maintainers":[{"name":"drav0011","email":"drav0011@gmail.com"}],"description":"Localization for Minecraft Bedrock: typed keys, interpolation and plurals, resolved client-side per player","homepage":"https://github.com/bedrock-core/ui#readme","keywords":["i18n","i18next","localization","minecraft","bedrock","typescript"],"repository":{"type":"git","url":"git+https://github.com/bedrock-core/ui.git"},"contributors":[{"name":"DrAv0011","email":"contact@drav.dev","url":"https://drav.dev"}],"author":{"name":"DrAv0011"},"bugs":{"url":"https://github.com/bedrock-core/ui/issues"},"license":"MIT","readme":"# @bedrock-core/i18n\n\n![Logo](https://raw.githubusercontent.com/bedrock-core/ui/main/assets/logo/title.png)\n\nLocalization for Minecraft Bedrock addons: typed keys, typed interpolation and plurals — resolved\non the **client** in each player's own language wherever possible, and on the **server** whenever\nyour code needs the actual string.\n\nThis is the runtime half of a two-part system. The build half is the\n[`i18n` Regolith filter](https://bedrock-core.drav.dev/docs/ui/i18n/regolith-filter), which turns\nyour `packs/data/i18n/<locale>.ts` modules into `.lang` files, a runtime bundle, and the types\nevery verb below infers from.\n\n## Install\n\nAlready have `@bedrock-core/ui`? It is reachable as `@bedrock-core/ui/i18n` — nothing to add.\nStandalone:\n\n```bash\nyarn add @bedrock-core/i18n\n```\n\nThen the build half, once per addon (before `bundler` in `config.json`, and after `guides` if you\nuse it):\n\n```bash\nregolith install github.com/bedrock-core/regolith-filters/i18n\n```\n\n## What it gives you\n\n- **Three verbs, one contract** — `key()` for keys the client resolves, `raw()` for a `RawMessage`\n  the client resolves *with* arguments, `t()` for a plain string right now, on the server\n- **Types inferred from your resources** — key paths, `{{var}}` interpolation variables and plural\n  forms all come from the authored bundle; a missing or misspelled argument is a compile error\n- **Plurals without `Intl`** — `_one` / `_other` (and `_zero`/`_two`/`_few`/`_many`) collapse into\n  one leaf taking `count`, chosen server-side from a built-in CLDR table\n- **A locale chain per player** — persisted override → client language → sibling region of that\n  language → the addon's default → anything published\n- **`DisplayText` everywhere** — components take a literal, a key or a `RawMessage`\n  interchangeably; `display()` collapses any of them to a string when you need one\n- **Cross-addon bundles** — publish yours through `core.register({ translations: bundle })` and any\n  peer can resolve and measure your strings\n- **No runtime dependencies** — a few KB, i18next's conventions, none of i18next\n\n## Usage\n\n```ts\n// packs/data/i18n/en_US.ts — `as const` is what lets the compiler infer the key space\nexport default {\n  shop: {\n    title: 'Shop',\n    bought: 'You bought {{item}} for {{price}} emeralds.',\n  },\n} as const;\n```\n\n```ts\n// BP/scripts/i18n.ts — the addon's one instance\nimport { createI18n } from '@bedrock-core/i18n';\nimport bundle from '@bedrock-core/generated/i18n';\nimport type { Player } from '@minecraft/server';\n\nexport const i18n = createI18n(bundle);\n\nexport function receipt(player: Player, item: string, price: number): void {\n  // Bind the verbs to this player's locale chain.\n  const { key, raw, t } = i18n.forPlayer(player);\n\n  key($ => $.shop.title);                    // 'drav0011_shop.shop.title' — the client resolves it\n  raw($ => $.shop.bought, { item, price });  // RawMessage — the client resolves and fills it\n  t($ => $.shop.bought, { item, price });    // 'You bought Apple for 5 emeralds.' — here, now\n}\n```\n\nThat one `createI18n(bundle)` call is also the UI wiring: it registers itself as the addon's\ndefault translation source, so localized `Text` children measure and resolve through it with no\nprovider at the root and no prop to declare.\n\n## Documentation\n\n- [i18n](https://bedrock-core.drav.dev/docs/ui/i18n) — the verbs, interpolation, plurals, locale\n  resolution, `display()`, cross-addon sharing, and the full API reference\n- [i18n Regolith filter](https://bedrock-core.drav.dev/docs/ui/i18n/regolith-filter) — authoring,\n  namespacing, the `tsconfig.json` alias, what gets generated and what the build checks\n- [Translations in the server runtime](https://bedrock-core.drav.dev/docs/server/server-runtime/translations) —\n  publishing a bundle and resolving a peer's strings\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-90046596012208bb39d07dfa9dc366fb"}