{"_id":"@dcsv-io/d2-i18n","_rev":"2-26f876bbc2e27cae4ee01ed049d889c5","name":"@dcsv-io/d2-i18n","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.1":{"name":"@dcsv-io/d2-i18n","version":"0.1.1","_id":"@dcsv-io/d2-i18n@0.1.1","maintainers":[{"name":"dcsv-tristan","email":"tristan@dcsv.io"}],"dist":{"shasum":"a6981658f7cad6407bcfc9e49b9f9873177fc312","tarball":"https://registry.npmjs.org/@dcsv-io/d2-i18n/-/d2-i18n-0.1.1.tgz","fileCount":23,"integrity":"sha512-k1HA9EYlimBZRE+7vbN8yWbBeaI1lpBnqjv4M8mIqmo2TSsqHuE8mnBs3TuktsqIXcniYrujRQ9SsnFTIOdxwA==","signatures":[{"sig":"MEUCIHyzAa0GGVP01FFnGM+xo5dOgcbbQ7JEAuc48jgg58U2AiEA42vvpktT7q40EhXjYoFeguFF5GvIPKlofw1vh9Hitg4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33187},"main":"./dist/index.js","type":"module","_from":"file:bundle/npm/dcsv-io-d2-i18n-0.1.1.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./keys":{"types":"./dist/keys.d.ts","import":"./dist/keys.js"}},"scripts":{"test":"vitest run","build":"tsc -b","test:coverage":"vitest run --coverage","type-check:test":"tsc -p tsconfig.test.json"},"_npmUser":{"name":"dcsv-tristan","email":"tristan@dcsv.io"},"_resolved":"/home/runner/work/D2-Public/D2-Public/bundle/npm/dcsv-io-d2-i18n-0.1.1.tgz","_integrity":"sha512-k1HA9EYlimBZRE+7vbN8yWbBeaI1lpBnqjv4M8mIqmo2TSsqHuE8mnBs3TuktsqIXcniYrujRQ9SsnFTIOdxwA==","_npmVersion":"11.16.0","description":"<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->","directories":{},"_nodeVersion":"24.18.0","dependencies":{"@dcsv-io/d2-i18n-keys":"0.1.1","@dcsv-io/d2-utilities":"0.1.1","@dcsv-io/d2-i18n-abstractions":"0.1.1"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"4.0.18","typescript":"5.9.3","@vitest/coverage-v8":"4.0.18"},"_npmOperationalInternal":{"tmp":"tmp/d2-i18n_0.1.1_1784262833736_0.6642866869468971","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@dcsv-io/d2-i18n","version":"0.1.2","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./keys":{"types":"./dist/keys.d.ts","import":"./dist/keys.js"}},"dependencies":{"@dcsv-io/d2-utilities":"0.1.2","@dcsv-io/d2-i18n-keys":"0.1.2","@dcsv-io/d2-i18n-abstractions":"0.1.2"},"devDependencies":{"@vitest/coverage-v8":"4.0.18","typescript":"5.9.3","vitest":"4.0.18"},"scripts":{"build":"tsc -b","test":"vitest run","test:coverage":"vitest run --coverage","type-check:test":"tsc -p tsconfig.test.json"},"_id":"@dcsv-io/d2-i18n@0.1.2","description":"<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->","_integrity":"sha512-mV39qhww7flmf5VblaZx0NQtPD0gziVxSQH2hrKO8WJr+mus5L/jhRpx4B28b8Ep3DpgcGw9Acp7T6+59xJzfw==","_resolved":"/home/runner/work/D2-Public/D2-Public/bundle/npm/dcsv-io-d2-i18n-0.1.2.tgz","_from":"file:bundle/npm/dcsv-io-d2-i18n-0.1.2.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-mV39qhww7flmf5VblaZx0NQtPD0gziVxSQH2hrKO8WJr+mus5L/jhRpx4B28b8Ep3DpgcGw9Acp7T6+59xJzfw==","shasum":"62ae18915ac501692e27e23a9a11fe4c4766cfe4","tarball":"https://registry.npmjs.org/@dcsv-io/d2-i18n/-/d2-i18n-0.1.2.tgz","fileCount":23,"unpackedSize":33192,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBGFgR6kt6v71sxvVBBVdqWR0OsQhOoNpPU4wi/8F4NaAiBZvFgehSJPknX1ncCopi6EEbng5r9nhyjd7gcHfc2How=="}]},"_npmUser":{"name":"dcsv-tristan","email":"tristan@dcsv.io"},"directories":{},"maintainers":[{"name":"dcsv-tristan","email":"tristan@dcsv.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/d2-i18n_0.1.2_1784286975096_0.7107865160054383"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-17T04:33:53.609Z","modified":"2026-07-17T11:16:15.433Z","0.1.1":"2026-07-17T04:33:53.863Z","0.1.2":"2026-07-17T11:16:15.252Z"},"description":"<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->","maintainers":[{"name":"dcsv-tristan","email":"tristan@dcsv.io"}],"readme":"<!--\nCopyright (c) DCSV. Licensed under the Apache License, Version 2.0.\n-->\n\n# @dcsv-io/d2-i18n\n\n`ITranslator` interface + `SupportedLocales` registry + default `Translator`\nimplementation. Mirrors `DcsvIo.D2.I18n` (.NET) so cross-language wire stays\nconsistent. The TS-side TK constants catalog itself is provided by Paraglide\nin the SvelteKit BFF; this package is the SHARED interface that any TS\nconsumer (Paraglide-backed or hand-rolled) implements against.\n\n## Install\n\n```bash\npnpm add @dcsv-io/d2-i18n\n```\n\n## Public API\n\n| Export                                    | Purpose                                                                                   |\n| ----------------------------------------- | ----------------------------------------------------------------------------------------- |\n| `ITranslator` (interface)                 | `t(locale, message): string`. Resolves a TK message to its rendered string. NEVER throws. |\n| `SupportedLocales` (class)                | BCP 47 supported-locale registry with canonical casing + language fallback.               |\n| `SupportedLocalesConfig`                  | Constructor input — `enabled` list + optional `default`.                                  |\n| `loadSupportedLocalesConfig(prefix, env)` | Reads indexed env-var array (`PREFIX__0=en-US, PREFIX__1=fr-FR`).                         |\n| `Translator` (class)                      | Default `ITranslator` impl with locale fallback + `{name}` parameter substitution.        |\n| `LocaleCatalogs`                          | Map of `locale → key → template-string` consumed by `Translator`.                         |\n| `TKMessage` / `tk()`                      | Re-exported from `@dcsv-io/d2-i18n-abstractions` for caller convenience.                          |\n\n## Dependencies\n\n- `@dcsv-io/d2-utilities` — boundary helpers, env parsing\n- `@dcsv-io/d2-i18n-abstractions` — TKMessage type + tk() factory\n\n## Usage example\n\n```ts\nimport { SupportedLocales, Translator, tk } from \"@dcsv-io/d2-i18n\";\n\nconst locales = new SupportedLocales({ enabled: [\"en-US\", \"fr-FR\"] });\nconst catalogs = {\n  \"en-US\": { \"TK.greet\": \"Hello, {name}\" },\n  \"fr-FR\": { \"TK.greet\": \"Bonjour, {name}\" },\n};\nconst t = new Translator(locales, catalogs);\n\nt.t(\"fr-CH\", tk(\"TK.greet\", { name: \"Alice\" })); // \"Bonjour, Alice\"\n```\n\n## Parity with .NET\n\nMirrors `DcsvIo.D2.I18n`:\n\n- `ITranslator` ↔ `DcsvIo.D2.I18n.ITranslator`\n- `SupportedLocales` ↔ `DcsvIo.D2.I18n.SupportedLocales` — same canonical-casing + language-fallback semantics.\n- `Translator` ↔ `DcsvIo.D2.I18n.Translator` — same fallback chain (requested → default → key-verbatim) + same `{name}` placeholder syntax.\n\n## Edge cases\n\n- `SupportedLocales.resolve(null/undefined/empty)` returns the default locale (never throws).\n- `Translator.t` returns the key verbatim when no catalog entry matches — discoverable in output, never raises.\n- Unmatched placeholders are left literal (`{name}` stays in output) so the operator notices missing bindings.\n- `loadSupportedLocalesConfig` returns `enabled: []` when no env entries — the constructor then throws on construct, surfacing the misconfiguration immediately rather than silently using a default.\n","readmeFilename":"README.md"}