Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type safe improvements #489

Merged
merged 25 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist
docs/api/*.md
!docs/api/injection.md
types
packages/vue-i18n/index.html
temp
coverage
node_modules
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"volar.tsPlugin": true
}
14 changes: 7 additions & 7 deletions examples/lazy-loading/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"dev": "vite"
},
"dependencies": {
"vue": "^3.0.7",
"vue-i18n": "^9.0.0",
"vue-router": "^4.0.5"
"vue": "^3.0.11",
"vue-i18n": "link:../../packages/vue-i18n",
"vue-router": "^4.0.8"
},
"devDependencies": {
"@intlify/vite-plugin-vue-i18n": "^2.0.2",
"@vitejs/plugin-vue": "^1.1.5",
"@vue/compiler-sfc": "^3.0.7",
"vite": "^2.0.5"
"@intlify/vite-plugin-vue-i18n": "^2.1.2",
"@vitejs/plugin-vue": "^1.2.2",
"@vue/compiler-sfc": "^3.0.11",
"vite": "^2.3.0"
},
"private": true
}
6 changes: 3 additions & 3 deletions examples/lazy-loading/vite/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
</template>

<script>
<script lang="ts">
import { defineComponent, watch, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
Expand All @@ -50,7 +50,7 @@ export default defineComponent({

// sync to switch locale from router locale path
watch(router.currentRoute, route => {
currentLocale.value = route.params.locale
currentLocale.value = route.params.locale as string
})

/**
Expand All @@ -61,7 +61,7 @@ export default defineComponent({
*/
watch(currentLocale, val => {
router.push({
name: router.currentRoute.value.name,
name: router.currentRoute.value.name!,
params: { locale: val }
})
})
Expand Down
6 changes: 3 additions & 3 deletions examples/lazy-loading/vite/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { I18n, I18nOptions, Composer } from 'vue-i18n'
export const SUPPORT_LOCALES = ['en', 'ja']

export function setupI18n(options: I18nOptions = { locale: 'en' }): I18n {
const i18n = createI18n(options) as I18n
const i18n = createI18n(options)
setI18nLanguage(i18n, options.locale!)
return i18n
}
Expand All @@ -24,12 +24,12 @@ export function setI18nLanguage(i18n: I18n, locale: string): void {
*
* axios.defaults.headers.common['Accept-Language'] = locale
*/
document.querySelector('html').setAttribute('lang', locale)
document.querySelector('html')!.setAttribute('lang', locale)
}

export async function loadLocaleMessages(i18n: I18n, locale: string) {
// load locale messages
const messages = await import(/* @vite-ignore */ `./locales/${locale}.yaml`)
const messages = await import(/* @vite-ignore */ `./locales/${locale}.json`)

// set locale and locale message
i18n.global.setLocaleMessage(locale, messages.default)
Expand Down
Loading