@@ -406,6 +406,64 @@ msgstr ""`;
406406 expect ( result ) . not . toContain ( '"Language: en\\n"' ) ;
407407 expect ( result ) . toContain ( 'msgstr "Hola mundo"' ) ;
408408 } ) ;
409+
410+ it ( "should preserve Language header for each locale when multiple target locales are pulled before push" , async ( ) => {
411+ // This test verifies the fix for a bug where pulling multiple target locales
412+ // before pushing would cause the Language header to be overwritten with the
413+ // wrong locale's value (e.g., es.po would get "Language: en" instead of "Language: es")
414+ const loader = createLoader ( ) ;
415+
416+ const sourceInput = `msgid ""
417+ msgstr ""
418+ "Language: en\\n"
419+ "Content-Type: text/plain; charset=utf-8\\n"
420+
421+ #: hello.py:1
422+ msgid "Hello"
423+ msgstr "Hello"` ;
424+
425+ const spanishInput = `msgid ""
426+ msgstr ""
427+ "Language: es\\n"
428+ "Content-Type: text/plain; charset=utf-8\\n"
429+
430+ #: hello.py:1
431+ msgid "Hello"
432+ msgstr ""` ;
433+
434+ const portugueseInput = `msgid ""
435+ msgstr ""
436+ "Language: pt\\n"
437+ "Content-Type: text/plain; charset=utf-8\\n"
438+
439+ #: hello.py:1
440+ msgid "Hello"
441+ msgstr ""` ;
442+
443+ await loader . pull ( "en" , sourceInput ) ;
444+
445+ // Pull multiple target locales (simulates concurrent processing)
446+ await loader . pull ( "es" , spanishInput ) ;
447+ await loader . pull ( "pt" , portugueseInput ) ;
448+
449+ const spanishResult = await loader . push ( "es" , {
450+ Hello : { singular : "Hola" , plural : null } ,
451+ } ) ;
452+
453+ const portugueseResult = await loader . push ( "pt" , {
454+ Hello : { singular : "Olá" , plural : null } ,
455+ } ) ;
456+
457+ expect ( spanishResult ) . toContain ( '"Language: es\\n"' ) ;
458+ expect ( spanishResult ) . not . toContain ( '"Language: pt\\n"' ) ;
459+ expect ( spanishResult ) . not . toContain ( '"Language: en\\n"' ) ;
460+ expect ( spanishResult ) . toContain ( 'msgstr "Hola"' ) ;
461+
462+ expect ( portugueseResult ) . toContain ( '"Language: pt\\n"' ) ;
463+ expect ( portugueseResult ) . not . toContain ( '"Language: es\\n"' ) ;
464+ expect ( portugueseResult ) . not . toContain ( '"Language: en\\n"' ) ;
465+ expect ( portugueseResult ) . toContain ( 'msgstr "Olá"' ) ;
466+ } ) ;
409467} ) ;
410468
411469function createLoader ( params : PoLoaderParams = { multiline : false } ) {
0 commit comments