# Internationalization (i18n)
# Overview
We're using react-i18next (opens new window) for Internationalization. You can find its configurations in src/configs/i18n.ts file and the locales in public/locales folder in the full version.
# Usage
Refer to this article to implement the internationalization.
# Add i18n
WARNING
Only for those who are using the starter-kit
If you are using the full version, then you don't need to add i18n as it is already available in that version. But if you are using the starter-kit (which is recommended) and want to add i18n, then follow these steps:
- You need to add these npm packages:
i18nextreact-i18nexti18next-http-backendi18next-browser-languagedetector
- Copy
src/configs/i18n.tsfile from the full version and paste it under the same directory in your project - Add
import 'src/configs/i18n'import statement insrc/pages/_app.tsxfile - Add your locale files in
public/localesfolder - If you want to translate the navigation menu, then copy the whole code from
src/layouts/components/Translations.tsxfile from the full version and paste it under the same directory in your project - If you want a language dropdown in the appBar to change the current language in the app, then import
src/@core/layouts/components/shared-components/LanguageDropdown.tsxfile and renderLanguageDropdowncomponent insrc/layouts/components/vertical/AppBarContent.tsxorsrc/layouts/components/horizontal/AppBarContent.tsxfile
<LanguageDropdown settings={settings} saveSettings={saveSettings} />
# Remove i18n
WARNING
Only for those who are using the full version
If you do not want to use i18n, we recommend you start your project with the starter-kit. But if you are using the full version and does not want to use i18n, then follow these steps:
- You may remove all the packages related to i18n from
package.jsonfile if you want toi18nextreact-i18nexti18next-http-backendi18next-browser-languagedetector
- Remove
src/configs/i18n.tsfile - Remove
import 'src/configs/i18n'import statement fromsrc/pages/_app.tsxfile - Replace the following code in
src/layouts/components/Translations.tsxfile
- Remove
LanguageDropdownfile import statement and rendered component fromsrc/layouts/components/vertical/AppBarContent.tsxand/orsrc/layouts/components/horizontal/AppBarContent.tsxfile
<LanguageDropdown settings={settings} saveSettings={saveSettings} />
- Remove your locale files from
public/localesfolder
# Add / Remove a language
Suppose you want to add de (German) language and remove ar (Arabic) language. For this, you need to follow these steps:
- Remove
public/locales/ar.jsonfile and addpublic/locales/de.jsonfile. You need to keep the format of the file as it is in other locale files - Make a new file in
src/layouts/componentsfolder and place the following code in this file
- Import the
src/layouts/components/UserLanguageDropdown.tsxfile and render it in thesrc/layouts/components/vertical/AppBarContent.tsxand/orsrc/layouts/components/horizontal/AppBarContent.tsxfile.