UFO: Alien Invasion
cl_language.cpp File Reference

Language code. More...

#include "client.h"
#include "cl_language.h"
#include "../shared/parse.h"
#include "../ports/system.h"
#include "ui/ui_main.h"
#include "ui/ui_font.h"
#include "ui/node/ui_node_abstractoption.h"
Include dependency graph for cl_language.cpp:

Go to the source code of this file.

Data Structures

struct  msgid_t
 
struct  localeMapping_t
 List of all mappings for a locale. More...
 
struct  language_t
 Struct that reflects parsed language definitions from our script files. More...
 

Macros

#define MAX_MSGIDS   512
 
#define MAX_MSGIDHASH   256
 
#define MSGIDSIZE   65536
 

Functions

static void CL_ParseMessageID (const char *name, const char **text)
 
static const char * CL_GetMessageID (const char *id)
 
const char * CL_Translate (const char *t)
 
void CL_ParseMessageIDs (void)
 
static const char * CL_GetLocaleID (const char *fullLocale)
 Searches the locale script id with the given locale string. More...
 
void CL_ParseLanguages (const char *name, const char **text)
 Parse all language definitions from the script files. More...
 
static bool CL_LanguageTest (const char *localeID)
 Test given language by trying to set locale. More...
 
void CL_LanguageShutdown (void)
 
void CL_LanguageInitMenu (void)
 
void CL_LanguageInit (void)
 Fills the options language menu node with the parsed language mappings. More...
 
static void CL_NewLanguage (void)
 Adjust game for new language: reregister fonts, etc. More...
 
bool CL_LanguageTryToSet (const char *localeID)
 Cycle through all parsed locale mappings and try to set one after another. More...
 

Variables

static cvar_tfs_i18ndir
 
static memPool_tcl_msgidPool
 
static msgid_t msgIDs [MAX_MSGIDS]
 
static int numMsgIDs
 
static msgid_tmsgIDHash [MAX_MSGIDHASH]
 
static char * msgIDText
 
static language_tlanguageList
 
static int languageCount
 

Detailed Description

Language code.

Definition in file cl_language.cpp.

Macro Definition Documentation

◆ MAX_MSGIDHASH

#define MAX_MSGIDHASH   256

Definition at line 51 of file cl_language.cpp.

◆ MAX_MSGIDS

#define MAX_MSGIDS   512

Definition at line 38 of file cl_language.cpp.

◆ MSGIDSIZE

#define MSGIDSIZE   65536

Definition at line 54 of file cl_language.cpp.

Function Documentation

◆ CL_GetLocaleID()

static const char * CL_GetLocaleID ( const char *  fullLocale)
static

Searches the locale script id with the given locale string.

Parameters
[in]fullLocaleThe full locale string. E.g. en_US.UTF-8

Definition at line 191 of file cl_language.cpp.

References Com_DPrintf(), DEBUG_CLIENT, languageList, language_t::localeID, localeMapping_t::localeMapping, language_t::localeMapping, localeMapping_t::next, language_t::next, and Q_streq.

Referenced by CL_LanguageInit().

◆ CL_GetMessageID()

static const char * CL_GetMessageID ( const char *  id)
static

Definition at line 113 of file cl_language.cpp.

References Com_HashKey(), hash, msgid_t::hash_next, id, MAX_MSGIDHASH, msgIDHash, and Q_streq.

Referenced by CL_Translate().

◆ CL_LanguageInit()

void CL_LanguageInit ( void  )

Fills the options language menu node with the parsed language mappings.

See also
CL_InitAfter
CL_LocaleSet

Definition at line 376 of file cl_language.cpp.

References CL_GetLocaleID(), Com_DPrintf(), Com_Printf(), Cvar_Get(), DEBUG_CLIENT, fs_i18ndir, MAX_VAR, Q_strncpyz(), Q_strvalid, s_language, cvar_t::string, and Sys_GetLocale().

Referenced by CL_InitAfter().

◆ CL_LanguageInitMenu()

◆ CL_LanguageShutdown()

void CL_LanguageShutdown ( void  )

Definition at line 341 of file cl_language.cpp.

References cl_msgidPool, languageCount, languageList, Mem_DeletePool, msgIDHash, msgIDText, numMsgIDs, and OBJZERO.

Referenced by CL_Shutdown().

◆ CL_LanguageTest()

static bool CL_LanguageTest ( const char *  localeID)
static

Test given language by trying to set locale.

Parameters
[in]localeIDlanguage abbreviation.
Returns
true if setting given language is possible.

Definition at line 277 of file cl_language.cpp.

References BASEDIRNAME, Com_DPrintf(), Com_sprintf(), DEBUG_CLIENT, FS_FileExists(), FS_GetCwd(), fs_i18ndir, i, languageCount, languageList, language_t::localeID, localeMapping_t::localeMapping, language_t::localeMapping, MAX_OSPATH, localeMapping_t::next, language_t::next, Q_strcat(), Q_streq, Q_strncpyz(), cvar_t::string, and Sys_Setenv().

Referenced by CL_LanguageInitMenu().

◆ CL_LanguageTryToSet()

bool CL_LanguageTryToSet ( const char *  localeID)

Cycle through all parsed locale mappings and try to set one after another.

Parameters
[in]localeIDthe locale id parsed from scriptfiles (e.g. en or de [the short id])
See also
CL_LocaleSet

Definition at line 413 of file cl_language.cpp.

References CL_NewLanguage(), Com_DPrintf(), Com_Printf(), Cvar_Set(), DEBUG_CLIENT, i, languageCount, languageList, language_t::localeID, localeMapping_t::localeMapping, language_t::localeMapping, cvar_t::modified, localeMapping_t::next, language_t::next, Q_streq, s_language, and Sys_SetLocale().

Referenced by CL_LanguageInitMenu(), and CL_SlowFrame().

◆ CL_NewLanguage()

static void CL_NewLanguage ( void  )
static

Adjust game for new language: reregister fonts, etc.

Definition at line 399 of file cl_language.cpp.

References _, CL_ParseMessageIDs(), R_FontInit(), R_FontSetTruncationMarker(), R_FontShutdown(), and UI_InitFonts().

Referenced by CL_LanguageTryToSet().

◆ CL_ParseLanguages()

◆ CL_ParseMessageID()

static void CL_ParseMessageID ( const char *  name,
const char **  text 
)
static

◆ CL_ParseMessageIDs()

◆ CL_Translate()

Variable Documentation

◆ cl_msgidPool

memPool_t* cl_msgidPool
static

Definition at line 36 of file cl_language.cpp.

Referenced by CL_LanguageShutdown(), CL_ParseMessageID(), and CL_ParseMessageIDs().

◆ fs_i18ndir

cvar_t* fs_i18ndir
static

Definition at line 35 of file cl_language.cpp.

Referenced by CL_Init(), CL_LanguageInit(), and CL_LanguageTest().

◆ languageCount

int languageCount
static

how many languages do we have

Definition at line 185 of file cl_language.cpp.

Referenced by CL_LanguageShutdown(), CL_LanguageTest(), CL_LanguageTryToSet(), and CL_ParseLanguages().

◆ languageList

language_t* languageList
static

linked list of all parsed languages

Definition at line 184 of file cl_language.cpp.

Referenced by CL_GetLocaleID(), CL_LanguageInitMenu(), CL_LanguageShutdown(), CL_LanguageTest(), CL_LanguageTryToSet(), and CL_ParseLanguages().

◆ msgIDHash

msgid_t* msgIDHash[MAX_MSGIDHASH]
static

◆ msgIDs

msgid_t msgIDs[MAX_MSGIDS]
static

Definition at line 49 of file cl_language.cpp.

Referenced by CL_ParseMessageID().

◆ msgIDText

char* msgIDText
static

Definition at line 55 of file cl_language.cpp.

Referenced by CL_LanguageShutdown(), CL_ParseMessageID(), and CL_ParseMessageIDs().

◆ numMsgIDs

int numMsgIDs
static

Definition at line 50 of file cl_language.cpp.

Referenced by CL_LanguageShutdown(), CL_ParseMessageID(), and CL_ParseMessageIDs().