A lightweight drop-in for react-i18next users looking to translate their projects

Phrasebook

A lightweight drop-in for react-i18next users looking to translate their projects. Currently in production on www.loveholidays.com.

Why phrasebook?

  • Tree-shakeable
  • Like for like interface with react-i18next
  • Native ESM module
  • Small bundle size (<1kb)

We leverage TFunction types in our site which are not exported properly from i18next without including the entire bundle. With this package you have all the types you need alongside a fully working set of functions that translate i18next files.

This package uses native ESM and does not provide a CommonJS export.

Bundle size comparisons

Package Bundle size Difference
react-i18next 6.5kb
@loveholidays/phrasebook 883b 736% smaller than react-i18next
@lingui/react 2.5kb 260% smaller than react-i18next

Installation

Currently available on NPM

$ npm i @loveholidays/phrasebook --save

Usage

As this is a drop-in replacement usage is the same as i18next. For example if you are currently using react-i18next you can replace you imports like so:

import { useTranslation } from 'react-i18next';

becomes

import { useTranslation } from '@loveholidays/phrasebook';

Contributing

Please see our guidelines

GitHub

View Github