43typedef struct msgid_s {
51#define MAX_MSGIDHASH 256
54#define MSGIDSIZE 65536
61 if (!*text || *token !=
'{') {
62 Com_Printf(
"CL_ParseMessageID: msgid \"%s\" without body ignored\n",
name);
76 Sys_Error(
"CL_ParseMessageID: MAX_MSGIDS exceeded");
84 const char* errhead =
"CL_ParseMessageID: unexpected end of file (msgid ";
98 msgid->
text =
_(token);
101 if (msgid->
text == token) {
108 Com_Printf(
"CL_ParseMessageID: msgid \"%s\" with same already exists - ignore the second one\n",
name);
117 if (
Q_streq(
id, (*anchor)->id))
118 return (*anchor)->text;
130 if (msgid !=
nullptr)
151 Com_Printf(
"\n----------- parse msgids -----------\n");
154 const char* text =
nullptr;
167typedef struct localeMapping_s {
176typedef struct language_s {
199 mapping = mapping->
next;
201 language = language->
next;
204 "Add it to the languages script file and send a patch please.\n", fullLocale);
213 const char* errhead =
"CL_ParseLanguages: unexpected end of file (language ";
216 Com_Printf(
"CL_ParseLanguages: language without body ignored (%s)\n",
name);
221 if (!*text || *token !=
'{') {
222 Com_Printf(
"CL_ParseLanguages: language without body ignored (%s)\n",
name);
235 if (!*text || *token ==
'}')
243 for (
linkedList_t* element = list; element !=
nullptr; element = element->
next) {
251 }
else if (
Q_streq(token,
"name")) {
253 if (!*text || *token ==
'}')
256 Com_Printf(
"CL_ParseLanguages: language: '%s' - not marked translatable (%s)\n",
name, token);
259 }
else if (
Q_streq(token,
"native")) {
261 if (!*text || *token ==
'}')
292 Com_sprintf(languagePath,
sizeof(languagePath), LOCALEDIR);
297 Q_strcat(languagePath,
sizeof(languagePath),
"%s/LC_MESSAGES/ufoai.mo", localeID);
306 if (
Sys_Setenv(
"LANGUAGE=%s", localeID) == 0) {
333 mapping = mapping->
next;
360 language = language->
next;
380 char systemLanguage[
MAX_VAR] =
"";
382 Com_Printf(
"CL_LanguageInit: language settings are stored in configuration: %s\n",
s_language->string);
389 Q_strncpyz(systemLanguage, localeID,
sizeof(systemLanguage));
429 Com_Printf(
"Could not find locale with id '%s'\n", localeID);
435 Com_Printf(
"No locale mappings for locale with id '%s'\n", localeID);
439 Cvar_Set(
"s_language",
"%s", localeID);
448 mapping = mapping->
next;
bool CL_LanguageTryToSet(const char *localeID)
Cycle through all parsed locale mappings and try to set one after another.
static const char * CL_GetMessageID(const char *id)
void CL_LanguageShutdown(void)
void CL_LanguageInit(void)
Fills the options language menu node with the parsed language mappings.
const char * CL_Translate(const char *t)
void CL_ParseLanguages(const char *name, const char **text)
Parse all language definitions from the script files.
void CL_LanguageInitMenu(void)
static const char * CL_GetLocaleID(const char *fullLocale)
Searches the locale script id with the given locale string.
void CL_ParseMessageIDs(void)
static cvar_t * fs_i18ndir
static void CL_NewLanguage(void)
Adjust game for new language: reregister fonts, etc.
static void CL_ParseMessageID(const char *name, const char **text)
static msgid_t * msgIDHash[MAX_MSGIDHASH]
static language_t * languageList
static msgid_t msgIDs[MAX_MSGIDS]
static bool CL_LanguageTest(const char *localeID)
Test given language by trying to set locale.
static memPool_t * cl_msgidPool
memPool_t * cl_genericPool
void R_FontSetTruncationMarker(const char *marker)
void R_FontShutdown(void)
frees the SDL_ttf fonts
Primary header for client.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
#define HASH_Add(hash, elem, index)
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
char * FS_NextScriptHeader(const char *files, const char **name, const char **text)
const char * FS_GetCwd(void)
Return current working dir.
int FS_BuildFileList(const char *fileList)
Build a filelist.
bool FS_FileExists(const char *filename,...)
Checks whether a file exists (not in virtual filesystem).
void Sys_Error(const char *error,...)
void LIST_Delete(linkedList_t **list)
#define Mem_FreePool(pool)
#define Mem_DeletePool(pool)
#define Mem_PoolAllocTypeN(type, n, pool)
#define Mem_PoolStrDup(in, pool, tagNum)
#define Mem_CreatePool(name)
#define Mem_PoolAllocType(type, pool)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
void Com_SkipBlock(const char **text)
Skips a block of {} in our script files.
Shared parsing functions.
static wrapCache_t * hash[MAX_WRAP_HASH]
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
const char * Com_EParse(const char **text, const char *errhead, const char *errinfo, char *target, size_t size)
Parsing function that prints an error message when there is no text in the buffer.
bool Com_ParseList(const char **text, linkedList_t **list)
#define Q_strvalid(string)
unsigned int Com_HashKey(const char *name, int hashsize)
returns hash key for a string
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Struct that reflects parsed language definitions from our script files.
localeMapping_t * localeMapping
const char * nativeString
const char * localeString
List of all mappings for a locale.
struct localeMapping_s * next
struct msgid_s * hash_next
Atomic structure used to define most of the UI.
const char * Sys_GetLocale(void)
int Sys_Setenv(const char *name, const char *value)
set/unset environment variables (empty value removes it)
const char * Sys_SetLocale(const char *localeID)
void UI_RegisterOption(int dataId, uiNode_t *option)
void UI_SortOptions(uiNode_t **first)
Sort options by alphabet.
uiNode_t * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
Append an option to an option list.
void UI_InitFonts(void)
after a video restart we have to reinitialize the fonts