Skip to content

Commit 77d9ff2

Browse files
committed
MenuStrings: replace double backslashes and backslash-n with single backslash and newline found in translation keys
1 parent 9a53376 commit 77d9ff2

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

MenuStrings.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,49 @@ int UTFToCP1251( char *out, const char *instr, int len, int maxoutlen )
266266
return out - outbegin;
267267
}
268268

269+
static uint Localize_ProcessString( char *dst, const char *src )
270+
{
271+
const char *p;
272+
uint i = 0;
273+
274+
p = src;
275+
276+
while( *p )
277+
{
278+
if( *p == '\\' )
279+
{
280+
char replace = 0;
281+
282+
switch( p[1] )
283+
{
284+
case '\\': replace = '\\'; break;
285+
case 'n': replace = '\n'; break;
286+
}
287+
288+
if( replace )
289+
{
290+
if( dst )
291+
dst[i] = replace;
292+
i++;
293+
p += 2;
294+
continue;
295+
}
296+
}
297+
298+
if( dst )
299+
dst[i] = *p;
300+
i++;
301+
p++;
302+
}
303+
304+
// null terminator
305+
if( dst )
306+
dst[i] = '\0';
307+
i++;
308+
309+
return i;
310+
}
311+
269312
static void Localize_AddToDictionary( const char *name, const char *lang )
270313
{
271314
char filename[64], token[4096];
@@ -374,6 +417,7 @@ static void Localize_AddToDictionary( const char *name, const char *lang )
374417
if( pfile )
375418
{
376419
// Con_DPrintf("New token: %s %s\n", token, szLocString );
420+
Localize_ProcessString( token, token );
377421
Dictionary_Insert( token, szLocString );
378422
i++;
379423
}

0 commit comments

Comments
 (0)