i18n-ts is a lightweight, type-safe internationalization library designed specifically for TypeScript applications. It allows developers to define translation messages as plain TypeScript objects, leveraging TypeScript's robust type inference system to ensure that message keys and their associated arguments are correctly used at compile time. This approach significantly reduces runtime errors related to missing translations or incorrect parameter usage, a common issue in dynamic i18n systems. The current stable version is 1.0.5, suggesting a relatively mature and stable codebase with a likely slow release cadence. Its key differentiator lies in its deep integration with TypeScript, providing compile-time safety without requiring external build steps or complex configuration files often found in other i18n solutions. It focuses on simplicity and type inference over a feature-rich runtime, making it ideal for projects prioritizing strong typing in their i18n layer.
npm install i18n-tsVerified import paths — ran on the pinned version, not inferred.
Demonstrates defining type-safe translation messages as plain TypeScript objects and using I18nResolver to access them.
For complex pluralization or formatting, manually add logic within your message functions, e.g., `(count: number) => count === 1 ? 'item' : 'items'`.
Consider code-splitting translation files if bundle size is a concern, and implement manual loading logic to pass the correct locale object to I18nResolver at runtime.
Always review the release notes carefully when upgrading to a new major version. Test your translation files thoroughly after any major version upgrade.
Ensure the translation key exists in the active locale object and matches the exact property name. TypeScript's inference will highlight these issues at compile time.
Pass arguments to your translation functions that precisely match the type signatures defined in your locale objects. TypeScript provides strong type checking for this.
Verify that the `i18n` object is correctly structured with defined locale objects (e.g., `en`, `de`) and that the selected locale key matches one of the defined keys. Also, ensure a `default` locale is provided.
No dependency data recorded yet.