File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ export type PreCompileHandler = () => {
84
84
functions : MessageFunctions
85
85
}
86
86
87
- export type CustomBlocks = string [ ] | PreCompileHandler
87
+ export type CustomBlocks = Array < string | LocaleMessages > | PreCompileHandler
88
88
89
89
/**
90
90
* Composer Options
@@ -222,7 +222,7 @@ function getLocaleMessages(
222
222
// merge locale messages of i18n custom block
223
223
if ( isArray ( __i18n ) ) {
224
224
__i18n . forEach ( raw => {
225
- ret = Object . assign ( ret , JSON . parse ( raw ) )
225
+ ret = Object . assign ( ret , isString ( raw ) ? JSON . parse ( raw ) : raw )
226
226
} )
227
227
return ret
228
228
}
Original file line number Diff line number Diff line change @@ -849,6 +849,35 @@ describe('__i18n', () => {
849
849
}
850
850
} )
851
851
} )
852
+
853
+ test ( 'locale messages object' , ( ) => {
854
+ const { messages } = createComposer ( {
855
+ __i18n : [
856
+ { en : { hello : 'Hello,world!' } } ,
857
+ {
858
+ ja : {
859
+ hello : 'こんにちは、世界!' ,
860
+ nest : {
861
+ foo : {
862
+ bar : 'ばー'
863
+ }
864
+ }
865
+ }
866
+ }
867
+ ]
868
+ } )
869
+ expect ( messages . value ) . toEqual ( {
870
+ en : { hello : 'Hello,world!' } ,
871
+ ja : {
872
+ hello : 'こんにちは、世界!' ,
873
+ nest : {
874
+ foo : {
875
+ bar : 'ばー'
876
+ }
877
+ }
878
+ }
879
+ } )
880
+ } )
852
881
} )
853
882
854
883
describe ( '__transrateVNode' , ( ) => {
You can’t perform that action at this time.
0 commit comments