1.1.0 • Public • Published


Internationalize your React application.


i18n, a.k.a. internationalization. Often you want to make your application available in multiple languages. @kaliber/i18n helps translating the static strings in your application.


yarn add @kaliber/i18n


Skip to reference

import { I18nProvider, useI18n, useI18nLanguage } from '@kaliber/i18n'
import { i18n } from './config/i18n.js'

function App() {
  return (
    <I18nProvider value={i18n} language='en'>
      <Page />

function Page() {
  const i18n = useI18n()
  const language = useI18nLanguage()

  return (
        <Navigation links={i18n('navigation')} />
        <PageMain i18nPath='home' />
        {/* Missing translations yield a warning in your console, when not in production mode */}
        {i18n('footer').copyright()} - {language.toUpperCase()}

// Please note that the i18nPath prop is not an actual part of this library,
// it's just a variable containing a path string ('home').

function PageMain({ i18nPath }) {
  const i18n = useI18n()

  return (
        {/* Prefix 'title' with the i18nPath */}
        <h1>{i18n(i18nPath, 'title')}</h1>

        {/* Access a translation in 'global' */}
        <em>{i18n('global.writtenBy')}: Kaliber</em>

        {/* Pass down the internationalized items as props */}
        <Tags tags={i18n(i18nPath, 'meta.tags')} />

      {/* Or pass down the i18nPath and handle translations lower in the tree */}
      <PageContent {...{ i18nPath }} />

Example i18n object:

const i18n = {
  navigation: [
      label: 'Home',
      link: '#'
      label: {
        nl: 'Neem contact op',
        en: 'Contact us'
      link: '#contact'
  home: {
    title: {
      nl: 'Welkom!',
      en: 'Welcome!'
    meta: {
      tags: [
          nl: 'dummy tekst',
          en: 'dummy text'
          nl: 'pagina',
          en: 'page'
    content: {
      title: {
        nl: 'Een klein beetje typesetting tekst',
        en: 'A bit of typesetting text'
      body: <p>Lorem ipsum dolor sit amet <strong>consectetur adipisicing elit</strong>. Facere esse unde aut officiis repudiandae vero placeat totam voluptas. Doloribus iste quae maiores officia praesentium magni, perspiciatis quibusdam necessitatibus sequi nemo.</p>,
  footer: {
    copyright: () => `Copyright ${(new Date()).getFullYear()}`
  global: {
    writtenBy: {
      nl: 'geschreven door',
      en: 'written by'
    tags: 'tags'



<I18nProvider value={i18n} language='en'>
value The i18n object to use.
language Optional.
When a language is given, normalization will be attempted at the leave nodes. E.g.: given the language en this means a leafnode with the shape { en: 'countries', nl: 'landen' } will be normalized to just 'countries'.
logMissingTranslation Optional. (default: console.warn)
If you want to change how missing translations are logged, you can provide your own logMissingTranslation function. This function is called with an object of the shape: { language, path }.

The provided i18n object may be a deeply nested object, optionally containing arrays. Values don't have to be strings, you can also provide numbers, functions or React elements (see the example i18n object under usage)


Returns (a subsection of) the i18n object.

const i18n = useI18n(i18nPath) 
const translatedString = i18n('path')
i18nPath Optional.
When given, the returned i18n function looks up its translations in a subset of the i18n object indicated by i18nPath.
i18n A function which accepts one or multiple i18nPath segments as arguments, which will be joined by dots. The value at this resulting path (prefixed with the i18nPath) will be normalized, then returned. When no value is found a warning will be logged (unless you're running production mode).


const i18n = useI18n()
const translatedString = i18n('global.cta')
const i18n = useI18n('global')
const translatedString = i18n('cta')
function Component({ i18nPath }) {
  const i18n = useI18n()
  const translatedString = i18n(i18nPath, 'content.title')
  const anotherTranslatedString = i18n('global.cta')

  // ...


Returns the language that is being used.

const language = useI18nLanguage() 


This library is intended for internal use, we provide no support, use at your own risk. It does not import React, but expects it to be provided, which @kaliber/build can handle for you.

This library is not transpiled.



Package Sidebar


npm i @kaliber/i18n

Weekly Downloads






Unpacked Size

9.59 kB

Total Files


Last publish


  • melissabos18
  • janbru
  • albertkaliber
  • jerryduijm
  • hjsielcken
  • kaliber-owner
  • daveykropf
  • eecolor
  • larsvankleef