From: H.G. Muller Date: Mon, 24 Oct 2011 17:26:02 +0000 (+0200) Subject: Add mechanism to translate variable messages in WinBoard X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f610658c8c9e9c0df5c77d546849c47162b7997a;p=xboard.git Add mechanism to translate variable messages in WinBoard A message prefixed with % in the lng file will be considered a match if it matches the start of the text to be printed, and the remaining part of the latter will remain untranslated. This was needed to allow translation of the perpetual change message, now it indicates the square of the chased piece. --- diff --git a/winboard/winboard.c b/winboard/winboard.c index febef6b..0016e7a 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -334,7 +334,7 @@ int dialogItems[][41 ] = { { 0 } }; -static char languageBuf[50000], *foreign[1000], *english[1000], *languageFile[MSG_SIZ]; +static char languageBuf[70000], *foreign[1000], *english[1000], *languageFile[MSG_SIZ]; static int lastChecked; static char oldLanguage[MSG_SIZ], *menuText[10][30]; extern int tinyLayout; @@ -388,11 +388,16 @@ T_(char *s) { // return the translation of the given string // efficiency can be improved a lot... int i=0; + static char buf[MSG_SIZ]; //if(appData.debugMode) fprintf(debugFP, "T_(%s)\n", s); if(!barbaric) return s; if(!s) return ""; // sanity while(english[i]) { if(!strcmp(s, english[i])) return foreign[i]; + if(english[i][0] == '%' && strstr(s, english[i]+1) == s) { // allow translation of strings with variable ending + snprintf(buf, MSG_SIZ, "%s%s", foreign[i], s + strlen(english[i]+1)); // keep unmatched portion + return buf; + } i++; } return s;