Add some docs
This commit is contained in:
parent
d152f08382
commit
b213796628
1 changed files with 20 additions and 6 deletions
|
@ -3,16 +3,30 @@ import { initReactI18next } from 'react-i18next';
|
|||
import Backend from 'i18next-http-backend';
|
||||
import { getBestPossibleUserLocale } from './utils';
|
||||
|
||||
/**
|
||||
* Load translations.
|
||||
*
|
||||
* Localization and related concerns (aka "internationalization", or "i18n") for
|
||||
* our apps is handled by i18n framework.
|
||||
*
|
||||
* In addition to the base i18next package, we use two of its plugins:
|
||||
*
|
||||
* - i18next-http-backend, for loading the JSON files containin the translations
|
||||
* at runtime, and
|
||||
*
|
||||
* - react-i18next, which adds React specific APIs
|
||||
*/
|
||||
export const setupI18n = async () => {
|
||||
// https://www.i18next.com/overview/api
|
||||
await i18n
|
||||
// i18next-http-backend
|
||||
// loads translations from your server
|
||||
// https://github.com/i18next/i18next-http-backend,
|
||||
// i18next-http-backend: Asynchronously loads translations over HTTP
|
||||
// https://github.com/i18next/i18next-http-backend
|
||||
.use(Backend)
|
||||
// pass the i18n instance to react-i18next.
|
||||
// react-i18next: React support
|
||||
// Pass the i18n instance to react-i18next.
|
||||
.use(initReactI18next)
|
||||
// init i18next
|
||||
// for all options read: https://www.i18next.com/overview/configuration-options
|
||||
// Initialize i18next
|
||||
// Option docs: https://www.i18next.com/overview/configuration-options
|
||||
.init({
|
||||
returnEmptyString: false,
|
||||
fallbackLng: 'en',
|
||||
|
|
Loading…
Add table
Reference in a new issue