@os-team/i18next-tld-language-detector
The i18next language detector, which is used to detect the user's language by a top-level domain (TLD).
Usage
Install the package using the following command:
yarn add @os-team/i18next-tld-language-detector
If you use next-i18next, add the language detector to the customDetectors
and include the tld
detector to detection.order
.
import NextI18Next from 'next-i18next';
import path from 'path';
import tldLanguageDetector from 'libs/utils/packages/i18next-tld-language-detector/src/index';
const i18Next = new NextI18Next({
defaultLanguage: 'en',
otherLanguages: ['ru'],
localePath: path.resolve('./public/static/locales'),
fallbackLng: false,
customDetectors: [tldLanguageDetector],
detection: {
order: ['tld'],
},
});