---
name: naive-ui-i18n
description: Configure internationalization (i18n) in Naive UI with support for multiple languages and custom locales
metadata:
author: jiaiyan
version: 1.0.0
---
# Naive UI Internationalization (i18n)
Configure internationalization in Naive UI to support multiple languages and customize component locales.
## When to Use
Use this skill when you need to:
- Set up multi-language support in your application
- Change the language of Naive UI components
- Customize existing locale strings
- Add support for new languages
## Prerequisites
- Basic understanding of Naive UI setup
- Vue 3 Composition API knowledge
- Understanding of internationalization concepts
## Basic Usage
### Setting Up Locale
Use `n-config-provider` to set the locale for all descendant components:
```vue
```
### Switching Languages Dynamically
```vue
```
## Supported Languages
Naive UI supports the following languages (PRs are welcome for new languages):
| Language | Config | Date Config | Version |
|----------|--------|-------------|---------|
| Arabic (العربية) | `arDZ` | `dateArDZ` | 2.34.0 |
| Azerbaijani (Azərbaycanca) | `azAZ` | `dateAzAZ` | 2.39.0 |
| Czech (Czechia) | `csCZ` | `dateCsCz` | 2.38.2 |
| Danish (Denmark) | `daDK` | `dateDaDK` | 2.43.0 |
| German (Germany) | `deDE` | `dateDeDE` | - |
| English (British) | `enGB` | `dateEnGB` | 2.25.1 |
| English | `enUS` | `dateEnUS` | - |
| Esperanto | `eo` | `dateEo` | 2.25.2 |
| Spanish (Argentina) | `esAR` | `dateEsAR` | 2.24.2 |
| Estonian | `etEE` | `dateEtEE` | 2.38.0 |
| Persian | `faIR` | `dateFaIR` | 2.34.4 |
| French | `frFR` | `dateFrFR` | - |
| Bahasa Indonesia | `idID` | `dateIdID` | - |
| Italiano | `itIT` | `dateItIT` | 2.24.2 |
| Japanese | `jaJP` | `dateJaJP` | - |
| Khmer (Cambodia) | `kmKH` | `dateKmKH` | 2.41.0 |
| Korean (South Korea) | `koKR` | `dateKoKR` | 2.28.1 |
| Norwegian Bokmål (Norway) | `nbNO` | `dateNbNO` | - |
| Dutch (Netherlands) | `nlNL` | `dateNlNL` | 2.29.0 |
| Polish (Poland) | `plPL` | `datePlPL` | 2.25.2 |
| Portuguese (Brazil) | `ptBR` | `datePtBR` | 2.28.1 |
| Russian | `ruRU` | `dateRuRU` | - |
| Slovak | `skSK` | `dateSkSK` | 2.25.3 |
| Swedish | `svSE` | `dateSvSE` | 2.35.0 |
| Thai (Thailand) | `thTH` | `dateThTH` | 2.27.0 |
| Turkish | `trTR` | `dateTrTR` | 2.34.0 |
| Uyghur (China) | `ugCN` | `dateUgCN` | - |
| Ukrainian | `ukUA` | `dateUkUA` | - |
| Uzbek (Uzbekistan) | `uzUZ` | `dateUzUZ` | 2.39.0 |
| Vietnamese (Vietnam) | `viVN` | `dateViVN` | 2.30.7 |
| Chinese (Simplified) | `zhCN` | `dateZhCN` | - |
| Chinese (Traditional) | `zhTW` | `dateZhTW` | - |
## Customizing Locales
### Using createLocale
Customize existing locale strings using `createLocale`:
```vue
```
### Full Locale Customization Example
```vue
```
## API Reference
### n-config-provider Locale Props
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `locale` | `object` | `enUS` | Locale configuration for components |
| `date-locale` | `object` | `dateEnUS` | Date format locale configuration |
### createLocale Function
```typescript
function createLocale(
overrides: PartialLocale,
baseLocale: Locale
): Locale
```
Creates a new locale by merging custom overrides with a base locale.
## Common Patterns
### Persistent Language Selection
```vue
```
### Integration with vue-i18n
```vue
```
## Best Practices
1. **Persist Language Preference**: Store the user's language choice in localStorage
2. **Separate Date Locale**: Always set both `locale` and `date-locale` for consistent formatting
3. **Use Base Locale**: When customizing, always extend from an existing locale using `createLocale`
4. **Test All Languages**: Verify your application works correctly with all supported languages
5. **Consider RTL**: Some languages (Arabic, Persian) require right-to-left layout support
6. **Sync with App i18n**: Keep Naive UI locale in sync with your application's i18n system
## Component-Specific Locale Keys
Different components have their own locale keys that can be customized:
```javascript
const customLocale = createLocale({
// Button
Button: {
loadingText: 'Loading...'
},
// Input
Input: {
placeholder: 'Please input',
clear: 'Clear'
},
// DatePicker
DatePicker: {
placeholder: 'Select date',
clear: 'Clear',
confirm: 'OK',
now: 'Now'
},
// Table
DataTable: {
check: 'Check',
clear: 'Clear',
clearFilters: 'Clear filters',
clearSorter: 'Clear sorter'
},
// Transfer
Transfer: {
source: 'Source',
target: 'Target',
searchPlaceholder: 'Search',
clear: 'Clear'
},
// Upload
Upload: {
draggerClick: 'Click to upload',
draggerDrag: 'Drag files here',
fileDrag: 'Drag files here',
accept: 'Accept: {accept}',
upload: 'Upload',
retry: 'Retry',
remove: 'Remove',
cancel: 'Cancel'
}
}, enUS)
```