Skip to content

garronej/i18nifty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18nifty Logo

Type-safe internationalization and translation React library fro SPAs

Home - Documentation - Sandbox

An internationalization and translation (i18n) library for React that focuses on the developer experience.
With ChatGPT capable of producing high-quality translations, there's no longer a need to rely on third-party translation services.
This allows us to shift our attention from making resource files editable in spreadsheet software to enhancing the developer experience.
In i18nifty, everything is TypeScript and type-safe. You can define your translations as functions and return them as React nodes, making the process more expressive, easier to write, and simpler to maintain.

i18nifty is intended for use in Single Page Application (SPA) projects, such as Vite or Create React App. It is not designed for use with Next.js or other SSR/SSG-enabled meta-frameworks.

What do I expect from my i18n library

  • I want true type safety, If I forgot something I want to be warned about it at compile time. I want to be guided by intelisence through and through so I can focus on my content.
  • I want to be able to use React components and involve JS logic in my translations (even if it means giving up support for third part translations services like https://locize.com/).
  • I want the language to default to the browser preference.
  • I want the language preferences to be persistent across reloads.
  • I want asynchronous loading of locales
  • SEO: I want to let Google know that my website is available in multiple languages.
  • I want to be able to change the language of my app by adding ?lang=xx to the URL without involving my routing library.
  • I want to be able to explicitly fallback to English (or another language) when the translation for a given language is incomplete.
  • a11y: When internationalized text received from the backend aren't in the language of the app I want a label to be added
  • Bundle size: I want only one translation to be downloaded. If the user select another language the required resources must be downloaded dynamically.

i18nifty is the only library i18n library (at the time of writing theses lines) that checks all the boxes. Discover.

demo_1_gh demo_2_gh demo_3

Showcases

This library has been used to build the following projects:

image image

## Contributing

git clone https://github.com/garronej/i18nifty
cd i18nifty
yarn

# Start the test app in watch mode
yarn start-test-app
# Start the alternative test app where resources are split into multiples files to enable lazy loading.
yarn start-test-app-lazy

# Link in an external app.
yarn link-in-app YOUR-APP # ../YOUR-APP is supposed to exist
npx tsc -w