]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/i18n.qh
Work around the need to include net_linked.qh from sv_model.qc (temporary hack for...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / i18n.qh
index afb38ff95686509917343c9af5af6b43efb8faca..8ebedb76f65f66110d3fd26ffaa46277e1b24021 100644 (file)
@@ -1,12 +1,15 @@
-#ifndef I18N_H
-#define I18N_H
+#pragma once
 
 #include "log.qh"
+#include "map.qh"
 #include "unsafe.qh"
 
 // translation helpers
 string prvm_language;
 
+/**
+ * @deprecated prefer _("translated")
+ */
 string language_filename(string s)
 {
        string fn = prvm_language;
@@ -26,33 +29,30 @@ string language_filename(string s)
 #endif
 
 #if CTX_CACHE
-       ArrayList CTX_cache;
+       HashMap CTX_cache;
        STATIC_INIT(CTX_cache)
        {
-               AL_NEW(CTX_cache, 0, string_null, s);
+               HM_NEW(CTX_cache);
        }
        SHUTDOWN(CTX_cache)
        {
-               AL_DELETE(CTX_cache);
+               HM_DELETE(CTX_cache);
        }
 #endif
 
 string CTX(string s)
 {
 #if CTX_CACHE
-               int i = strid(s);
-               string c = AL_gets(CTX_cache, i);
-               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);
 #if CTX_CACHE
-        LOG_DEBUGF("CTX(\"%s\")\n", s);
-               AL_sets(CTX_cache, i, ret);
+        LOG_DEBUGF("CTX(\"%s\")", s);
+               HM_sets(CTX_cache, s, ret);
 #endif
        return ret;
 }
 
 #define ZCTX(s) strzone(CTX(s))
-
-#endif