i18next-http-backend
react-i18next
Our great sponsors
i18next-http-backend | react-i18next | |
---|---|---|
4 | 53 | |
297 | 7,974 | |
2.0% | 1.1% | |
8.5 | 8.8 | |
3 days ago | 18 days ago | |
JavaScript | JavaScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
i18next-http-backend
-
How to properly internationalize a Vue application using i18next
import i18next from 'i18next' import I18NextVue from 'i18next-vue' import LanguageDetector from 'i18next-browser-languagedetector' import Backend from 'i18next-http-backend' export const i18nextPromise = i18next // i18next-http-backend // loads translations from your server // https://github.com/i18next/i18next-http-backend .use(Backend) // detect user language // learn more: https://github.com/i18next/i18next-browser-languageDetector .use(LanguageDetector) // init i18next // for all options read: https://www.i18next.com/overview/configuration-options .init({ debug: true, fallbackLng: 'en' }); export default function (app) { app.use(I18NextVue, { i18next }) return app }
-
The progressive guide to jQuery internationalization (i18n) using i18next
// ... $(function () { // use plugins and options as needed, for options, detail see // https://www.i18next.com i18next // i18next-http-backend // loads translations from your server // https://github.com/i18next/i18next-http-backend .use(i18nextHttpBackend) // detect user language // learn more: https://github.com/i18next/i18next-browser-languageDetector .use(i18nextBrowserLanguageDetector) // init i18next // for all options read: https://www.i18next.com/overview/configuration-options .init({ debug: true, fallbackLng: 'en' }, (err, t) => { if (err) return console.error(err); // ... }); });
-
How to Internationalize a React App
In addition, we need to install i18next-http-backend which allows us to fetch translations from a directory, and i18next-browser-languagedetector which allows us to detect the user's language:
-
How to properly internationalize a React application using i18next
import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import LanguageDetector from 'i18next-browser-languagedetector'; import Backend from 'i18next-http-backend'; import { DateTime } from 'luxon'; i18n // i18next-http-backend // loads translations from your server // https://github.com/i18next/i18next-http-backend .use(Backend) // detect user language // learn more: https://github.com/i18next/i18next-browser-languageDetector .use(LanguageDetector) // pass the i18n instance to react-i18next. .use(initReactI18next) // init i18next // for all options read: https://www.i18next.com/overview/configuration-options .init({ debug: true, fallbackLng: 'en', interpolation: { escapeValue: false, // not needed for react as it escapes by default format: (value, format, lng) => { if (value instanceof Date) { return DateTime.fromJSDate(value).setLocale(lng).toLocaleString(DateTime[format]) } return value; } }, resources: { en: { translation: { description: { part1: 'Edit <1>src/App.js and save to reload.', part2: 'Learn React' }, counter: 'Changed language just once', counter_plural: 'Changed language already {{count}} times', footer: { date: 'Today is {{date, DATE_HUGE}}', date_morning: 'Good morning! Today is {{date, DATE_HUGE}} | Have a nice day!', date_afternoon: 'Good afternoon! It\'s {{date, DATE_HUGE}}', date_evening: 'Good evening! Today was the {{date, DATE_HUGE}}' } } }, de: { translation: { description: { part1: 'Ändere <1>src/App.js und speichere um neu zu laden.', part2: 'Lerne React' }, counter: 'Die Sprache wurde erst ein mal gewechselt', counter_plural: 'Die Sprache wurde {{count}} mal gewechselt', footer: { date: 'Heute ist {{date, DATE_HUGE}}', date_morning: 'Guten Morgen! Heute ist {{date, DATE_HUGE}} | Wünsche einen schönen Tag!', date_afternoon: 'Guten Tag! Es ist {{date, DATE_HUGE}}', date_evening: 'Guten Abend! Heute war {{date, DATE_HUGE}}' } } } } }); export default i18n;
react-i18next
-
Translation in React Applications
React is a popular JavaScript library for building user interfaces. react-i18next is a library that integrates with React, providing an easy and efficient way to add internationalisation (i18n) support to your application. This library provides a simple API for handling translations and makes it easy to translate your content into different languages.
-
Alternative libs to migrate from React to Vue (or Vue to React)
react-i18next
-
Is it normal to make this much progress in 4 days?
But still, I think I'm too slow. In the project above I'm using MUI, react-i18next
-
Managing translations
I suggest react-i18next with more than one namespace
-
i18n with Next.js 13 and app directory
In this section you'll see how we can internationalize the new app directory with the use of i18next, react-i18next and i18next-resources-to-backend. npm install i18next react-i18next i18next-resources-to-backend
-
Internationalizing and Localizing a React App: i18n Made Easy
While I believe there is a lot of valid criticism for using a library for everything in the JavaScript ecosystem, I strongly believe this is a case where you want to put your trust in the experts of the open-source community. The most common library I've seen for serving translations in a React app is react-i18next.
-
How do you handle localization?
I am not an expert at all in this area so there may be way better ways to do this. But I really like this library: https://react.i18next.com/ You use a hook wherever you want to translate. The translation can come from a local or remote JSON file. As far as the backend - I would go the route of sending a specific key, like you suggested, or even just a number for each error that you then map to the i18next translation
-
How implementation a i18n in React App
The official site react-i18next
-
How To Add Multiple Language Support In ReactJS
Now inside tag add onChange method, this is where we get values from options provided and pass it to i18n to change language i18n.changeLanguage(e.target.value)}> Choose language Uzbek Russian English Enter fullscreen mode Exit fullscreen mode Final App.js import logo from './logo.svg'; import './App.css'; import { useTranslation } from 'react-i18next'; function App() { const { t, i18n } = useTranslation() return (
Edit
i18n.changeLanguage(e.target.value)}> Choose language Uzbek Russian English {t('welcome')}src/App.js
and save to reload.
{t('goodbye')} -
16 Libraries You Should Know as a React Developer 💯🔥
13. react-i18next
What are some alternatives?
React Intl - The monorepo home to all of the FormatJS related libraries, most notably react-intl.
next-i18next - The easiest way to translate your NextJs apps.
jsLingui - 🌍📖 A readable, automated, and optimized (5 kb) internationalization for JavaScript
i18next - i18next: learn once - translate everywhere
nextjs-monorepo-example - Collection of monorepo tips & tricks
react-globalize - Bringing the i18n functionality of Globalize, backed by CLDR, to React
transloco - 🚀 😍 The internationalization (i18n) library for Angular
i18next-locize-backend - A simple i18next backend for locize.com which can be used in Node.js, in the browser and for Deno.
react-translate-maker - Universal internationalization (i18n) open source library for React
i18next-chained-backend - An i18next backend to chain multiple backends (add fallbacks, caches, ...)
i18next-fs-backend - i18next-fs-backend is a backend layer for i18next using in Node.js and for Deno to load translations from the filesystem.
react-intl-universal - Internationalize React apps. Not only for Component but also for Vanilla JS.