@@ -63,11 +63,11 @@ const normalizeTranslationLine = (
6363) : NWSTranslationLine => {
6464 if ( isNWPTranslationLine ( line ) ) {
6565 const key = line . match ( / ^ " ( [ ^ " ] + ) " / ) ?. [ 1 ] ;
66- const value = line . match ( / : " ( [ ^ " ] + ) " / ) ?. [ 1 ] ;
67- return `${ key } : ${ value } ` ;
66+ const value = line . match ( / : " ( [ ^ " ] + ) " / ) ?. [ 1 ] ;
67+ return `${ key } : ${ value || "<empty>" } ` ;
6868 }
6969
70- return line ;
70+ return ( line . endsWith ( "\r" ) ? line . slice ( 0 , - 1 ) : line ) as NWSTranslationLine ;
7171} ;
7272
7373export const parseTranslationFile = ( file : TranslationFile ) : ProgramUIFile => {
@@ -79,9 +79,13 @@ export const parseTranslationFile = (file: TranslationFile): ProgramUIFile => {
7979
8080 lines . forEach ( ( line ) => {
8181 const [ key , ...rest ] = line . trim ( ) . split ( KEY_VALUE_SEPARATOR ) ;
82- const value = rest . join ( KEY_VALUE_SEPARATOR ) ;
8382
84- if ( key ) programUI [ key ] = value ?? "" ; // Value can be empty in NWP translation file
83+ // Some strings end with a colon and space (": "), keep it in the value
84+ const value = line . endsWith ( KEY_VALUE_SEPARATOR )
85+ ? rest . join ( KEY_VALUE_SEPARATOR ) + " "
86+ : rest . join ( KEY_VALUE_SEPARATOR ) ;
87+
88+ if ( key && value ) programUI [ key ] = value === "<empty>" ? "" : value ; // Value can be empty in NWP translation file
8589 } ) ;
8690
8791 return programUI ;
@@ -93,9 +97,9 @@ export const serializeTranslationFile = (
9397 const isNWP = isNWPProgramUIFile ( record ) ;
9498 return Object . entries ( record )
9599 . map (
96- ( [ key , value ] ) : TranslationLine =>
100+ ( [ key , value ] , i ) : TranslationLine =>
97101 isNWP
98- ? `"${ key } "${ KEY_VALUE_SEPARATOR } "${ value } ", `
102+ ? `"${ key } "${ KEY_VALUE_SEPARATOR } "${ value } "${ i < Object . keys ( record ) . length - 1 ? "," : "" } `
99103 : `${ key } : ${ value } ` ,
100104 )
101105 . join ( LINE_SEPARATOR ) ;
0 commit comments