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<
367367 isString ( options . default ) || isBoolean ( options . default ) // default by function option
368368 ? ! isBoolean ( options . default )
369369 ? options . default
370- : key
370+ : ( ! messageCompiler ? ( ) => key : key )
371371 : fallbackFormat // default by `fallbackFormat` option
372372 ? ( ! messageCompiler ? ( ) => key : key )
373373 : ''
@@ -646,6 +646,13 @@ function compileMessageFormat<Messages, Message>(
646646 return msg
647647 }
648648
649+ if ( messageCompiler == null ) {
650+ const msg = ( ( ) => format ) as MessageFunctionInternal
651+ msg . locale = targetLocale
652+ msg . key = key
653+ return msg
654+ }
655+
649656 // for vue-devtools timeline event
650657 let start : number | null = null
651658 let startTag : string | undefined
@@ -657,7 +664,7 @@ function compileMessageFormat<Messages, Message>(
657664 mark && mark ( startTag )
658665 }
659666
660- const msg = messageCompiler ! (
667+ const msg = messageCompiler (
661668 format as string ,
662669 getCompileOptions (
663670 context ,
Original file line number Diff line number Diff line change @@ -470,3 +470,24 @@ test('issue #933', async () => {
470470
471471 expect ( wrapper . html ( ) ) . toEqual ( '<div>hi! hello man! - local!</div>' )
472472} )
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