i18n | Kener
Kener supports multiple languages. You can add translations to your site.
You can add translations to your site. By default it is set to en. Available translations are present in src/lib/locales/ folders in the root directory. You can add more translations by adding a new file in the src/lib/locales folder.
How to enable a translation
Kener has made it simple to add new translations.
Step 1
Copy and update the translation file in the locales folder. The translation file should be a json file with the locale code as the name of the file. For example, en.json, fr.json, de.json.
Step 2
Open src/lib/locales/locales.json and add the locale code and the name of the language.
[
{
"code": "en",
"name": "English"
},
{
"code": "hi",
"name": "हिन्दी"
},
{
"code": "zh-CN",
"name": "中文"
},
{
"code": "ja",
"name": "日本語"
},
{
"code": "vi",
"name": "Tiếng Việt"
},
{
"code": "fr",
"name": "Français"
}
]
Step 3
Open src/lib/i18n/client.js and add the locale code to the locales array.
import { ru, enUS, hi, de, zhCN, vi, ja, nl, da, fr, ko } from "date-fns/locale"
This should be valid for the date-fns library. You can find the list of locales here.
Next add a mapping in the locales object.
const locales = { ru, en: enUS, hi, dk: de, "zh-CN": zhCN, vi, ja, nl, dk: da, fr, ko }
Step 4
Restart the server and you will see a dropdown in the navbar to select the language.
Variables in translations
There are few variables that you you should not change,
- %status : This will be replaced by the status
- %lastedFor : This will be replaced by the duration the incident lasted
- %startedAt : This will be replaced by the time the incident started
- %date : This will be replaced by the date
- %duration : This will be replaced by the duration
Dates
The localization for dates are still not there. We are working on it and will be available soon.