X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fi18n.qh;h=3069f519dc33454a5310a68a52e9ba16d2570fd8;hb=c29b4218e63c53fdf5194af78a9dea26f04c395e;hp=c66d7b9a88bd8a163d20d5a13cef85132102892c;hpb=7bcb3a89b3271e018da4d92437dc5ba125ea8698;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/i18n.qh b/qcsrc/lib/i18n.qh index c66d7b9a8..3069f519d 100644 --- a/qcsrc/lib/i18n.qh +++ b/qcsrc/lib/i18n.qh @@ -8,8 +8,9 @@ string prvm_language; /** - * @deprecated prefer _("translated") + * @deprecated prefer _("translatable text") - GMQCC's -ftranslatable-strings feature */ +ERASEABLE string language_filename(string s) { string fn = prvm_language; @@ -40,17 +41,26 @@ string language_filename(string s) } #endif +ERASEABLE string CTX(string s) { #if CTX_CACHE - string c = HM_gets(CTX_cache, s); - if (c != "") return c; + 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\")\n", s); - HM_sets(CTX_cache, s, ret); + LOG_DEBUGF("CTX(\"%s\")", s); + HM_sets(CTX_cache, s, ret); #endif return ret; }