Skip to content

Commit

Permalink
improvement: $i18n property deinition for vue-i18n-bridge (#1394)
Browse files Browse the repository at this point in the history
* improvement:  $i18n property deinition for vue-i18n-bridge

* fix: flow type annotation
  • Loading branch information
kazupon authored Oct 1, 2021
1 parent a5dac35 commit a1bc51b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/extend.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* @flow */

export default function extend (Vue: any): void {
if (!Vue.prototype.hasOwnProperty('$i18n')) {
export default function extend (Vue: any, bridge: boolean = false): void {
/**
* if `bridge` mode is avialable, `$i18n` is defined at `vue-i18n-bridge`
*/
if (!bridge && !Vue.prototype.hasOwnProperty('$i18n')) {
// $FlowFixMe
Object.defineProperty(Vue.prototype, '$i18n', {
get () { return this._i18n }
Expand Down
2 changes: 1 addition & 1 deletion src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function install (_Vue, options = { bridge: false }) {
return
}

extend(Vue)
extend(Vue, options.bridge)
Vue.mixin(defineMixin(options.bridge))
Vue.directive('t', { bind, update, unbind })
Vue.component(interpolationComponent.name, interpolationComponent)
Expand Down

0 comments on commit a1bc51b

Please sign in to comment.