MCPcopy Index your code
hub / github.com/codingcommons/typesafe-i18n

github.com/codingcommons/typesafe-i18n @5.27.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 5.27.1 ↗ · + Follow
1,599 symbols 2,900 edges 910 files 6 documented · 0% 2 cross-repo links updated 3mo ago5.27.1 · 2026-02-11★ 2,47522 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

:earth_africa: typesafe-i18n

A fully type-safe and lightweight internationalization library for all your TypeScript and JavaScript projects.

npm version GitHub Top Language bundle size types included bump version & publish to npm Generic badge Sponsor this project

Ivan Hofer

Created by Ivan Hofer (1995-2023)

Advantages

:baby_chick: lightweight (~1kb)\ :ok_hand: easy to use syntax\ :running: fast and efficient\ :safety_vest: prevents you from making mistakes (also in plain JavaScript projects)\ :construction_worker: creates boilerplate code for you\ :speech_balloon: supports plural rules\ :date: allows formatting of values e.g. locale-dependent date or number formats\ :left_right_arrow: supports switch-case statements e.g. for gender-specific output\ :arrow_down: option for asynchronous loading of locales\ :books: supports multiple namespaces\ :stopwatch: supports SSR (Server-Side Rendering)\ :handshake: can be used for frontend, backend and API projects\ :mag: locale-detection for browser and server environments\ :arrows_counterclockwise: import and export translations from/to files or services\ :no_entry: no external dependencies

Interactive Live Demo

Click here to see an interactive demo of typesafe-i18n showing some key aspects of the type-checking capabilities of this internationalization library.

Works with

Table of Contents

  • Get started - how to add typesafe-i18n to your project
  • Usage - how to implement different use-cases
  • Typesafety - how to get the best typesafety features
  • Syntax - how to use the translation functions
  • Dictionary - how to structure your translations
  • Namespaces - how to optimize loading of your translations
  • Formatters - how to format dates and numbers
  • Switch-Case - how to output different words depending on an argument
  • Locale-detection - how to detect an user's locale
  • Utility functions - useful utility functions
  • Integrations - how to integrate other i18n services
  • Sizes - how much does typesafe-i18n add to your bundle size
  • Performance - how efficient is typesafe-i18n implemented
  • Sponsors - how to help this project grow
  • FAQs - how to get your questions answered

Get started

  1. :keyboard: Run the setup process and automatically detect the config needed bash npx typesafe-i18n --setup-auto or manually configure typesafe-i18n by answering a few questions bash npx typesafe-i18n --setup

    It didn't work? See here for possible troubleshooting.

  2. :eyes: Take a look at the generated files and it's folder-structure after running npm run typesafe-i18n (or npx typesafe-i18n)

  3. :open_book: Explore the assets

    typesafe-i18n offers a lot. Just press cmd + F to search on this page or see the table of contents that will link you to more specific subpages with more details.

  4. :star: Star this project on GitHub

    Thanks! This helps the project to grow.

\ Having trouble setting up typesafe-i18n? Reach out to us via Github Discussions or on Discord.

manual installation

npm install typesafe-i18n

changelog

The changelog of this project can be found here

migrations

Long-term goals

Curious about what comes next? See this discussion to learn more about the plans for the future of this project.

Contributions

If you would like to get involved within this project, take a look at this discussion.

Usage

The package can be used inside JavaScript and TypeScript applications. You will get a lot of benefits by running the generator since it will create a few wrappers to provide you with full typesafety.

You can use typesafe-i18n in a variety of project-setups:

Other frameworks

All you need is inside the generated file i18n-util.ts. You can use the functions in there to create a small wrapper for your application.

Feel free to open a new discussion if you need a guide for a specific framework.

Custom usage

See here if you want to learn how you can use typesafe-i18n to implement your own specific use-case.

Browser Support

The library should work in all modern browsers. It uses some functionality from the Intl namespace. You can see the list of supported browsers here. If you want to support older browsers that don't include these functions, you would need to include a polyfill like intl-pluralrules.

Typesafety

If you want to get the best typesafety features, you will need to use the generator in order to create types and boilerplate code for you

Here you can see some examples where typesafe-i18n can help you:

typesafe auto-completion for all your defined locales

typesafe locales completion

typesafe auto-completion for all available translations

typesafe translation key completion

you will get an error if you forget to pass arguments

typesafe number of arguments

you will get an error if you pass the wrong type arguments

typesafe arguments 1 typesafe arguments 2

you will get an error if you forgot to add a translation in a locale

![typesafe keys in translations](https://raw.githubusercontent.com/ivanhofer/typesafe-i18n/main/assets/05_typesafe-keys-in-tr

Core symbols most depended-on inside this repo

run
called by 23
packages/adapter-react/examples/react-native/android/app/src/debug/java/com/reactnativetypesafei18n/ReactNativeFlipper.java
i18nObject
called by 10
packages/importer/example/src/i18n/i18n-util.ts
initI18nReact
called by 10
packages/adapter-react/src/index.tsx
render
called by 3
packages/formatters/example/src/main.ts
getPreferredLocale
called by 3
packages/adapter-node/example/src/index.ts
throwError
called by 3
packages/runtime/rename-cjs.ts
getPath
called by 2
packages/utils/esbuild.ts
getPath
called by 2
packages/importer/esbuild.ts

Shape

Function 1,530
Method 47
Class 22

Languages

TypeScript97%
Java3%
C++1%

Modules by API surface

packages/generator/test/generator.test.ts14 symbols
packages/adapter-react/examples/react-native/android/app/src/main/java/com/reactnativetypesafei18n/newarchitecture/MainApplicationReactNativeHost.java10 symbols
packages/importer/example/src/i18n/i18n-util.async.ts7 symbols
packages/generator/test/generated/namespaces/util.expected.async.ts7 symbols
packages/generator/test/generated/namespaces-with-locales/util.expected.async.ts7 symbols
packages/generator/test/generated/namespaces-with-locales-jsdoc/util.expected.async.js7 symbols
packages/generator/test/generated/namespaces-with-locales-esm/util.expected.async.ts7 symbols
packages/generator/test/generated/namespaces-with-locales-esm-jsdoc/util.expected.async.js7 symbols
packages/generator/test/generated/namespaces-only/util.expected.async.ts7 symbols
packages/generator/test/generated/namespaces-only-jsdoc/util.expected.async.js7 symbols
packages/generator/test/generated/namespaces-multiple/util.expected.async.ts7 symbols
packages/generator/test/generated/namespaces-multiple-jsdoc/util.expected.async.js7 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add typesafe-i18n \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact