Skip to content
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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"@nexhome/yorkie": "^2.0.8",
"@types/js-yaml": "^4.0.5",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"bumpp": "^8.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.26.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^3.5.2",
Expand All @@ -31,8 +31,8 @@
"js-yaml": "^4.1.0",
"lint-staged": "^12.5.0",
"npm-run-all": "^4.1.5",
"pathe": "^0.3.9",
"pkg-types": "^0.3.6",
"pathe": "^1.0.0",
"pkg-types": "^1.0.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"typescript": "^4.8.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-i18n-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"peerDependencies": {
"vue": "^2.6.14 || ^2.7.0 || ^3.2.0",
"vue-i18n": "^8.26.1 || ^9.2.0 || ^9.3.0-beta.8",
"vue-i18n-bridge": "^9.2.0 || ^9.3.0-beta.6",
"vue-i18n": "^8.26.1 || ^9.2.0 || ^9.3.0-beta.10",
"vue-i18n-bridge": "^9.2.0 || ^9.3.0-beta.10",
"vue-router": "^3.5.3 || ^3.6.0 || ^4.0.0",
"@vue/composition-api": "^1.0.0-rc.1"
},
Expand Down
19 changes: 16 additions & 3 deletions packages/vue-i18n-routing/src/extends/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isBoolean, isObject } from '@intlify/shared'
import { isBoolean, isObject, isFunction, assign } from '@intlify/shared'
import { ref, computed, watch, isVue3, effectScope, isVue2 } from 'vue-demi'

import {
Expand Down Expand Up @@ -98,22 +98,31 @@ export function extendI18n<Context = unknown, TI18n extends I18n = I18n>(

const orgInstall = i18n.install
i18n.install = (vue: Vue, ...options: unknown[]) => {
const pluginOptions = isPluginOptions(options[0]) ? options[0] : { inject: true }
const pluginOptions = isPluginOptions(options[0]) ? assign({}, options[0]) : { inject: true }
if (pluginOptions.inject == null) {
pluginOptions.inject = true
}
const orgComposerExtend = pluginOptions.__composerExtend
pluginOptions.__composerExtend = (c: Composer) => {
const g = getComposer(i18n)
c.locales = computed(() => g.locales.value)
c.localeCodes = computed(() => g.localeCodes.value)
c.baseUrl = computed(() => g.baseUrl.value)
if (isFunction(orgComposerExtend)) {
Reflect.apply(orgComposerExtend, pluginOptions, [c])
}
}
if (isVueI18n(i18n.global)) {
const orgVueI18nExtend = pluginOptions.__vueI18nExtend
pluginOptions.__vueI18nExtend = (vueI18n: VueI18n) => {
extendVueI18n(vueI18n, hooks.onExtendVueI18n)
if (isFunction(orgVueI18nExtend)) {
Reflect.apply(orgVueI18nExtend, pluginOptions, [vueI18n])
}
}
}

options[0] = pluginOptions
Reflect.apply(orgInstall, i18n, [vue, ...options])

const composer = getComposer(i18n)
Expand Down Expand Up @@ -254,5 +263,9 @@ function extendVueI18n(vueI18n: VueI18n, hook?: ExtendVueI18nHook): void {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isPluginOptions(options: any): options is VueI18nRoutingPluginOptions {
return isObject(options) && 'inject' in options && isBoolean(options.inject)
return (
isObject(options) &&
('inject' in options || '__composerExtend' in options || '__vueI18nExtend' in options) &&
isBoolean(options.inject)
)
}
4 changes: 2 additions & 2 deletions playground/vue2-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"vue": "2.6.14",
"vue-router": "3.5.3",
"vue-i18n": "^8",
"vue-i18n-bridge": "^9.3.0-beta.8",
"vue-i18n-routing": "0.9.2"
"vue-i18n-bridge": "^9.3.0-beta.10",
"vue-i18n-routing": "0.10.0"
},
"devDependencies": {
"@types/node": "^18.0.4",
Expand Down
4 changes: 2 additions & 2 deletions playground/vue2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"vue": "2.6.14",
"vue-router": "3.5.3",
"vue-i18n": "^8",
"vue-i18n-bridge": "^9.3.0-beta.8",
"vue-i18n-routing": "0.9.2"
"vue-i18n-bridge": "^9.3.0-beta.10",
"vue-i18n-routing": "0.10.0"
},
"devDependencies": {
"@types/node": "^18.0.4",
Expand Down
4 changes: 2 additions & 2 deletions playground/vue3-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"dependencies": {
"vue": "3.2.31",
"vue-router": "4.1.2",
"vue-i18n": "^9.3.0-beta.8",
"vue-i18n": "^9.3.0-beta.10",
"@vueuse/head": "0.7.6",
"vue-i18n-routing": "0.9.2"
"vue-i18n-routing": "0.10.0"
},
"devDependencies": {
"@types/node": "^18.0.4",
Expand Down
8 changes: 8 additions & 0 deletions playground/vue3-options/src/views/AboutView.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
mounted() {
console.log('foo', this.$i18n.locales, this.$i18n)
}
})
</script>
<template>
<div class="about">
<h1>{{ $t('views.AboutView') }}</h1>
Expand Down
4 changes: 2 additions & 2 deletions playground/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"dependencies": {
"vue": "3.2.31",
"vue-router": "4.1.2",
"vue-i18n": "9.3.0-beta.8",
"vue-i18n": "9.3.0-beta.10",
"@vueuse/head": "0.7.6",
"vue-i18n-routing": "file:../../packages/vue-i18n-routing/vue-i18n-routing-0.9.2.tgz"
"vue-i18n-routing": "0.10.0"
},
"devDependencies": {
"@types/node": "^18.0.4",
Expand Down
5 changes: 4 additions & 1 deletion playground/vue3/src/views/AboutView.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'

const { t } = useI18n()
const { t, locales, localeCodes } = useI18n({
useScope: 'local'
})
// console.log('locales', locales, localeCodes)
</script>

<template>
Expand Down
Loading