You can add translations to your site. By default it is set to en
. Available translations are present in locales/
folders in the root directory. You can add more translations by adding a new file in the locales
folder.
Once you have added a new translation file in the locales
folder, you can enable it by adding the locale code in the site.yaml
file.
Let us say you have added a hi.json
file in the locales
folder. You can enable it by adding the following to the site.yaml
file.
1linki18n:
2link defaultLocale: en
3link locales:
4link en: English
5link hi: हिन्दी
defaultLocale: The default locale to be used. This will be the language used when a user visits the site for the first time. It is important to note that the default locale json file should be present in the locales folder.
There are few variables that you you should not change,
locales:_ A list of locales that you want to enable. The key is the locale code and the value is the name of the language. The locale code should be the same as the json file name in the locales folder.
en
meansen.json
should be present in the locales folder.
Adding more than one locales will enable a dropdown in the navbar to select the language.
Selected languages are stored in cookies and will be used when the user visits the site again.
There is no auto detection of the language. The user has to manually select the language.