Skip to content

Commit

Permalink
⚡ improvement(index): Fixes global auto installation (#291) by @emileber
Browse files Browse the repository at this point in the history
  • Loading branch information
emileber authored and kazupon committed Feb 1, 2018
1 parent 6cc4f65 commit 2f016ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test/e2e/report
test/e2e/screenshots
node_modules
.DS_Store
.idea
.vscode
*.log
*.swp
Expand Down
12 changes: 7 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export default class VueI18n {
_dataListeners: Array<any>

constructor (options: I18nOptions = {}) {
// Auto install if it is not done yet and `window` has `Vue`.
// To allow users to avoid auto-installation in some cases,
// this code should be placed here. See #290
if (!Vue && typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}

const locale: Locale = options.locale || 'en-US'
const fallbackLocale: Locale = options.fallbackLocale || 'en-US'
const messages: LocaleMessages = options.messages || {}
Expand Down Expand Up @@ -585,8 +592,3 @@ VueI18n.availabilities = {
}
VueI18n.install = install
VueI18n.version = '__VERSION__'

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VueI18n)
}

0 comments on commit 2f016ff

Please sign in to comment.