i18n
A guide to set up internationalization (i18n) for your shadcn-nuxt-docs
Configuring internationalization
Add i18n
Configuration
First, you need to add the i18n
configuration to your Nuxt.js project. Open your nuxt.config.ts
file and add the following configuration:
Organize Your Content Files
To support multiple languages, you need to organize your content files in a specific directory structure. Follow this file tree structure:
- The
content
directory contains your default language content files. - The
xx
directory insidecontent
contains the translations of your content files,xx
being the language code (e.g.,fr/index.md
for French).
Create i18n/i18n.config.ts
Next, create a new file named i18n/i18n.config.ts
. This file will contain the configuration for your i18n messages to translate. Add the following code to the file:
UI Translation
The UI locale will follow the selected language in the language switcher. UI translations are provided out-of-the-box for the following languages:
en
(English)fr
(Français)zh-CN
(简体中文)zh-TW
(繁體中文)km
(ភាសាខ្មែរ)ja
(日本語)km
(ភាសាខ្មែរ)ru
(Русский)ko
(한국어)hi
(हिन्दी)bn
(বাংলা)
If you want to add more UI locales, feel free to contribute to the project.
Or if you want to add your own translations, you can do so by following the structure in the i18n/i18n.config.ts
file. Just add the translations for the keys you want to translate in the respective language object.