-
-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
loadLocaleMessages
to manually load locale messages (#2799)
* feat: extend Vue i18n with `loadLocaleMessages` function * docs: add `loadLocaleMessages` to lazy-load en vue-i18n sections * test: add test for `loadLocaleMessages`
- Loading branch information
1 parent
de07830
commit bd8a2dd
Showing
8 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
specs/fixtures/lazy/i18n-module/locales/lazy-locale-module-nl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export default defineI18nLocale(locale => ({ | ||
moduleLayerText: 'This is a merged module layer locale key in Dutch', | ||
welcome: 'Welkom!', | ||
dynamicTime: new Date().toISOString() | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script lang="ts" setup> | ||
import { useI18n } from '#i18n' | ||
import { computed } from 'vue' | ||
const { loadLocaleMessages, t } = useI18n() | ||
await loadLocaleMessages('nl') | ||
const welcome = computed(() => t('welcome')) | ||
const welcomeDutch = computed(() => t('welcome', 1, { locale: 'nl' })) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<span id="welcome-english">{{ welcome }}</span> | ||
<span id="welcome-dutch">{{ welcomeDutch }}</span> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters