From: terencehill Date: Mon, 7 Oct 2019 08:51:14 +0000 (+0200) Subject: Ignore context tags (prefixes) in translatable strings with less than 2 characters... X-Git-Tag: xonotic-v0.8.5~1245 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1d81a2ae5ceb65ecc434cb3b8f6f3176da4889f3;p=xonotic%2Fxonotic-data.pk3dir.git Ignore context tags (prefixes) in translatable strings with less than 2 characters or with a space. It fixes some translated team chat messages sent trimmed from the quickmenu --- diff --git a/qcsrc/lib/i18n.qh b/qcsrc/lib/i18n.qh index 841486f58..cbdf55375 100644 --- a/qcsrc/lib/i18n.qh +++ b/qcsrc/lib/i18n.qh @@ -48,8 +48,16 @@ string CTX(string s) string c = HM_gets(CTX_cache, s); if (c != "") return c; #endif - int p = strstrofs(s, "^", 0); - string ret = (p < 0) ? s : substring(s, p + 1, -1); + int caret_ofs = strstrofs(s, "^", 0); + string ret = s; + // empty (caret_ofs == 0) and one char (caret_ofs == 1) prefixes are invalid + if (caret_ofs > 1) + { + int space_ofs = strstrofs(substring(s, 0, caret_ofs), " ", 0); + // prefixes containing a space are invalid (likely the caret is part of a color code) + if (space_ofs < 0 || space_ofs > caret_ofs) + ret = substring(s, caret_ofs + 1, -1); + } #if CTX_CACHE LOG_DEBUGF("CTX(\"%s\")", s); HM_sets(CTX_cache, s, ret);