@@ -116,6 +116,26 @@ describe('LocalizeManager', () => {
116116 } ) ;
117117 } ) ;
118118
119+ it ( 'can load a namespace for a different locale' , async ( ) => {
120+ setupFakeImport ( './my-component/nl-NL.js' , { default : { greeting : 'Hello!' } } ) ;
121+
122+ const manager = new LocalizeManager ( ) ;
123+ manager . locale = 'en-US' ;
124+
125+ await manager . loadNamespace (
126+ {
127+ 'my-component' : locale => fakeImport ( `./my-component/${ locale } .js` ) ,
128+ } ,
129+ { locale : 'nl-NL' } ,
130+ ) ;
131+
132+ expect ( manager . __storage ) . to . deep . equal ( {
133+ 'nl-NL' : {
134+ 'my-component' : { greeting : 'Hello!' } ,
135+ } ,
136+ } ) ;
137+ } ) ;
138+
119139 it ( 'loads multiple namespaces via loadNamespaces()' , async ( ) => {
120140 setupFakeImport ( './my-defaults/en-GB.js' , { default : { submit : 'Submit' } } ) ;
121141 setupFakeImport ( './my-send-button/en-GB.js' , { default : { submit : 'Send' } } ) ;
@@ -135,6 +155,29 @@ describe('LocalizeManager', () => {
135155 } ) ;
136156 } ) ;
137157
158+ it ( 'can load multiple namespaces for a different locale' , async ( ) => {
159+ setupFakeImport ( './my-defaults/nl-NL.js' , { default : { submit : 'Submit' } } ) ;
160+ setupFakeImport ( './my-send-button/nl-NL.js' , { default : { submit : 'Send' } } ) ;
161+
162+ const manager = new LocalizeManager ( ) ;
163+ manager . locale = 'en-US' ;
164+
165+ await manager . loadNamespaces (
166+ [
167+ { 'my-defaults' : locale => fakeImport ( `./my-defaults/${ locale } .js` ) } ,
168+ { 'my-send-button' : locale => fakeImport ( `./my-send-button/${ locale } .js` ) } ,
169+ ] ,
170+ { locale : 'nl-NL' } ,
171+ ) ;
172+
173+ expect ( manager . __storage ) . to . deep . equal ( {
174+ 'nl-NL' : {
175+ 'my-defaults' : { submit : 'Submit' } ,
176+ 'my-send-button' : { submit : 'Send' } ,
177+ } ,
178+ } ) ;
179+ } ) ;
180+
138181 it ( 'fallbacks to language file if locale file is not found' , async ( ) => {
139182 setupFakeImport ( './my-component/en.js' , { default : { greeting : 'Hello!' } } ) ;
140183
0 commit comments