Xonotic
i18n.qh File Reference
#include "log.qh"
#include "map.qh"
#include "unsafe.qh"
+ Include dependency graph for i18n.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CTX_CACHE   1
 
#define ZCTX(s)   strzone(CTX(s))
 

Functions

ERASEABLE string CTX (string s)
 
ERASEABLE string language_filename (string s)
 
 SHUTDOWN (CTX_cache)
 
 STATIC_INIT (CTX_cache)
 

Variables

HashMap CTX_cache
 
string prvm_language
 

Macro Definition Documentation

◆ CTX_CACHE

#define CTX_CACHE   1

Definition at line 29 of file i18n.qh.

◆ ZCTX

Function Documentation

◆ CTX()

ERASEABLE string CTX ( string  s)

Definition at line 45 of file i18n.qh.

References CTX_cache, HM_gets, HM_sets, LOG_DEBUGF, strstrofs, and substring().

Referenced by count_fill(), Label_getInfo(), and XonoticDecibelsSlider_valueToText().

46 {
47 #if CTX_CACHE
48  string c = HM_gets(CTX_cache, s);
49  if (c != "") return c;
50 #endif
51  int caret_ofs = strstrofs(s, "^", 0);
52  string ret = s;
53  // empty (caret_ofs == 0) and one char (caret_ofs == 1) prefixes are invalid
54  if (caret_ofs > 1)
55  {
56  int space_ofs = strstrofs(substring(s, 0, caret_ofs), " ", 0);
57  // prefixes containing a space are invalid (likely the caret is part of a color code)
58  if (space_ofs < 0 || space_ofs > caret_ofs)
59  ret = substring(s, caret_ofs + 1, -1);
60  }
61 #if CTX_CACHE
62  LOG_DEBUGF("CTX(\"%s\")", s);
63  HM_sets(CTX_cache, s, ret);
64 #endif
65  return ret;
66 }
#define HM_gets(this, k)
Definition: map.qh:96
#define HM_sets(this, key, val)
Definition: map.qh:106
#define strstrofs
Definition: dpextensions.qh:42
HashMap CTX_cache
Definition: i18n.qh:33
#define LOG_DEBUGF(...)
Definition: log.qh:86
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ language_filename()

ERASEABLE string language_filename ( string  s)
Deprecated:
prefer _("translatable text") - GMQCC's -ftranslatable-strings feature

Definition at line 14 of file i18n.qh.

References fclose(), FILE_READ, fopen(), prvm_language, and strcat().

Referenced by CampaignFile_Load().

15 {
16  string fn = prvm_language;
17  if (fn == "" || fn == "dump") return s;
18  fn = strcat(s, ".", fn);
19  int fh = fopen(fn, FILE_READ);
20  if (fh >= 0)
21  {
22  fclose(fh);
23  return fn;
24  }
25  return s;
26 }
const float FILE_READ
Definition: csprogsdefs.qc:231
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
string prvm_language
Definition: i18n.qh:8
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SHUTDOWN()

SHUTDOWN ( CTX_cache  )

Definition at line 38 of file i18n.qh.

References CTX_cache, ERASEABLE, and HM_DELETE.

39  {
41  }
HashMap CTX_cache
Definition: i18n.qh:33
#define HM_DELETE(this)
Definition: map.qh:88

◆ STATIC_INIT()

STATIC_INIT ( CTX_cache  )

Definition at line 34 of file i18n.qh.

References CTX_cache, and HM_NEW.

35  {
37  }
#define HM_NEW(this)
Definition: map.qh:29
HashMap CTX_cache
Definition: i18n.qh:33

Variable Documentation

◆ CTX_cache

HashMap CTX_cache

Definition at line 33 of file i18n.qh.

Referenced by CTX(), SHUTDOWN(), and STATIC_INIT().

◆ prvm_language