@@ -3,7 +3,7 @@ import { I18nSymbol, I18n, I18nInternal } from './i18n'
33import { Translation , NumberFormat , DatetimeFormat } from './components'
44import { vTDirective } from './directive'
55import { I18nWarnCodes , getWarnMessage } from './warnings'
6- import { isPlainObject , warn } from './utils'
6+ import { isPlainObject , warn , isBoolean } from './utils'
77
88/**
99 * I18n plugin options
@@ -13,6 +13,7 @@ import { isPlainObject, warn } from './utils'
1313 */
1414export interface I18nPluginOptions {
1515 useI18nComponentName ?: boolean
16+ globalInstall ?: boolean
1617}
1718
1819export function apply (
@@ -24,19 +25,27 @@ export function apply(
2425 ? ( options [ 0 ] as I18nPluginOptions )
2526 : { }
2627 const useI18nComponentName = ! ! pluginOptions . useI18nComponentName
28+ const globalInstall = isBoolean ( pluginOptions . globalInstall )
29+ ? pluginOptions . globalInstall
30+ : true
2731
28- if ( __DEV__ && useI18nComponentName ) {
32+ if ( __DEV__ && globalInstall && useI18nComponentName ) {
2933 warn (
3034 getWarnMessage ( I18nWarnCodes . COMPONENT_NAME_LEGACY_COMPATIBLE , {
3135 name : Translation . name
3236 } )
3337 )
3438 }
3539
36- // install components
37- app . component ( ! useI18nComponentName ? Translation . name : 'i18n' , Translation )
38- app . component ( NumberFormat . name , NumberFormat )
39- app . component ( DatetimeFormat . name , DatetimeFormat )
40+ if ( globalInstall ) {
41+ // install components
42+ app . component (
43+ ! useI18nComponentName ? Translation . name : 'i18n' ,
44+ Translation
45+ )
46+ app . component ( NumberFormat . name , NumberFormat )
47+ app . component ( DatetimeFormat . name , DatetimeFormat )
48+ }
4049
4150 // install directive
4251 app . directive ( 't' , vTDirective ( i18n ) )
0 commit comments