feat(locale): provide code (#2611)

This commit is contained in:
Alex
2024-11-12 16:57:40 +05:00
committed by GitHub
parent 30218f1b5b
commit 8a8b1ee2e1
16 changed files with 45 additions and 14 deletions

View File

@@ -38,7 +38,7 @@ You also have the option to add your own locale using `defineLocale`:
```vue [app.vue]
<script setup lang="ts">
const locale = defineLocale('My custom locale', {
const locale = defineLocale('My custom locale', 'en', {
// implement pairs
})
</script>
@@ -50,6 +50,12 @@ const locale = defineLocale('My custom locale', {
</template>
```
::tip
Look at the second parameter, there you need to pass the iso code of the language. Example:
* `hi` Hindi (language)
* `de-AT`: German (language) as used in Austria (region)
::
### Dynamic locale
To dynamically switch between languages, you can use the [Nuxt I18n](https://i18n.nuxtjs.org/) module.

View File

@@ -40,7 +40,7 @@ You also have the option to add your locale using `defineLocale`:
<script setup lang="ts">
import { defineLocale } from '@nuxt/ui/runtime/composables/defineLocale'
const locale = defineLocale('My custom locale', {
const locale = defineLocale('My custom locale', 'en', {
// implement pairs
})
</script>
@@ -52,6 +52,12 @@ const locale = defineLocale('My custom locale', {
</template>
```
::tip
Look at the second parameter, there you need to pass the iso code of the language. Example:
* `hi` Hindi (language)
* `de-AT`: German (language) as used in Austria (region)
::
### Dynamic locale
To dynamically switch between languages, you can use the [Vue I18n](https://vue-i18n.intlify.dev/) plugin.