File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -367,7 +367,7 @@ export function translate<
367
367
isString ( options . default ) || isBoolean ( options . default ) // default by function option
368
368
? ! isBoolean ( options . default )
369
369
? options . default
370
- : key
370
+ : ( ! messageCompiler ? ( ) => key : key )
371
371
: fallbackFormat // default by `fallbackFormat` option
372
372
? ( ! messageCompiler ? ( ) => key : key )
373
373
: ''
@@ -646,6 +646,13 @@ function compileMessageFormat<Messages, Message>(
646
646
return msg
647
647
}
648
648
649
+ if ( messageCompiler == null ) {
650
+ const msg = ( ( ) => format ) as MessageFunctionInternal
651
+ msg . locale = targetLocale
652
+ msg . key = key
653
+ return msg
654
+ }
655
+
649
656
// for vue-devtools timeline event
650
657
let start : number | null = null
651
658
let startTag : string | undefined
@@ -657,7 +664,7 @@ function compileMessageFormat<Messages, Message>(
657
664
mark && mark ( startTag )
658
665
}
659
666
660
- const msg = messageCompiler ! (
667
+ const msg = messageCompiler (
661
668
format as string ,
662
669
getCompileOptions (
663
670
context ,
Original file line number Diff line number Diff line change @@ -470,3 +470,24 @@ test('issue #933', async () => {
470
470
471
471
expect ( wrapper . html ( ) ) . toEqual ( '<div>hi! hello man! - local!</div>' )
472
472
} )
473
+
474
+ test ( 'issue #964' , async ( ) => {
475
+ const i18n = createI18n ( {
476
+ legacy : false ,
477
+ locale : 'ja' ,
478
+ fallbackLocale : 'en' ,
479
+ messages : {
480
+ en : {
481
+ hello : 'hello man!'
482
+ }
483
+ }
484
+ } )
485
+ const { t } = i18n . global
486
+
487
+ // set no compiler
488
+ registerMessageCompiler ( null as any ) // eslint-disable-line @typescript-eslint/no-explicit-any
489
+
490
+ const defaultMsg = t ( 'foo' )
491
+ expect ( defaultMsg ) . toEqual ( 'foo' )
492
+ expect ( t ( 'bar' , defaultMsg ) ) . toEqual ( 'foo' )
493
+ } )
You can’t perform that action at this time.
0 commit comments