]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/i18n.qh
Merge branch 'master' into Lyberta/WaypointIcons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / i18n.qh
index 841486f5837a9150cf730d77ef23a7d9c8443ca5..3069f519dc33454a5310a68a52e9ba16d2570fd8 100644 (file)
@@ -8,7 +8,7 @@
 string prvm_language;
 
 /**
- * @deprecated prefer _("translated")
+ * @deprecated prefer _("translatable text") - GMQCC's -ftranslatable-strings feature
  */
 ERASEABLE
 string language_filename(string s)
@@ -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);