mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
@@ -60,7 +60,7 @@ import { fr } from '@nuxt/ui-pro/locale'
|
||||
|
||||
### Custom locale
|
||||
|
||||
You also have the option to add your own locale using `defineLocale`:
|
||||
You can create your own locale using the `defineLocale` composable:
|
||||
|
||||
::module-only
|
||||
|
||||
@@ -125,6 +125,65 @@ Look at the `code` parameter, there you need to pass the iso code of the languag
|
||||
|
||||
::
|
||||
|
||||
### Extend locale :badge{label="Soon" class="align-text-top"}
|
||||
|
||||
You can customize an existing locale by overriding its `messages` or `code` using the `extendLocale` composable:
|
||||
|
||||
::module-only
|
||||
|
||||
#ui
|
||||
:::div
|
||||
|
||||
```vue [app.vue]
|
||||
<script setup lang="ts">
|
||||
import { en } from '@nuxt/ui/locale'
|
||||
|
||||
const locale = extendLocale(en, {
|
||||
code: 'en-GB',
|
||||
messages: {
|
||||
commandPalette: {
|
||||
placeholder: 'Search a component...'
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UApp :locale="locale">
|
||||
<NuxtPage />
|
||||
</UApp>
|
||||
</template>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
#ui-pro
|
||||
:::div
|
||||
|
||||
```vue [app.vue]
|
||||
<script setup lang="ts">
|
||||
import { en } from '@nuxt/ui-pro/locale'
|
||||
|
||||
const locale = extendLocale(en, {
|
||||
code: 'en-GB',
|
||||
messages: {
|
||||
commandPalette: {
|
||||
placeholder: 'Search a component...'
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UApp :locale="locale">
|
||||
<NuxtPage />
|
||||
</UApp>
|
||||
</template>
|
||||
```
|
||||
|
||||
:::
|
||||
::
|
||||
|
||||
### Dynamic locale
|
||||
|
||||
To dynamically switch between languages, you can use the [Nuxt I18n](https://i18n.nuxtjs.org/) module.
|
||||
|
||||
@@ -60,7 +60,7 @@ import { fr } from '@nuxt/ui-pro/locale'
|
||||
|
||||
### Custom locale
|
||||
|
||||
You also have the option to add your locale using `defineLocale`:
|
||||
You can create your own locale using the `defineLocale` composable:
|
||||
|
||||
::module-only
|
||||
|
||||
@@ -127,6 +127,67 @@ Look at the `code` parameter, there you need to pass the iso code of the languag
|
||||
|
||||
::
|
||||
|
||||
### Extend locale :badge{label="Soon" class="align-text-top"}
|
||||
|
||||
You can customize an existing locale by overriding its `messages` or `code` using the `extendLocale` composable:
|
||||
|
||||
::module-only
|
||||
|
||||
#ui
|
||||
:::div
|
||||
|
||||
```vue [App.vue]
|
||||
<script setup lang="ts">
|
||||
import { en } from '@nuxt/ui/locale'
|
||||
import { extendLocale } from '@nuxt/ui/composables/defineLocale.js'
|
||||
|
||||
const locale = extendLocale(en, {
|
||||
code: 'en-GB',
|
||||
messages: {
|
||||
commandPalette: {
|
||||
placeholder: 'Search a component...'
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UApp :locale="locale">
|
||||
<RouterView />
|
||||
</UApp>
|
||||
</template>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
#ui-pro
|
||||
:::div
|
||||
|
||||
```vue [App.vue]
|
||||
<script setup lang="ts">
|
||||
import { en } from '@nuxt/ui-pro/locale'
|
||||
import { extendLocale } from '@nuxt/ui/composables/defineLocale.js'
|
||||
|
||||
const locale = extendLocale(en, {
|
||||
code: 'en-GB',
|
||||
messages: {
|
||||
commandPalette: {
|
||||
placeholder: 'Search a component...'
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UApp :locale="locale">
|
||||
<RouterView />
|
||||
</UApp>
|
||||
</template>
|
||||
```
|
||||
|
||||
:::
|
||||
::
|
||||
|
||||
### Dynamic locale
|
||||
|
||||
To dynamically switch between languages, you can use the [Vue I18n](https://vue-i18n.intlify.dev/) plugin.
|
||||
|
||||
Reference in New Issue
Block a user