All pastes #898401 Raw Edit

Zeug

public c v1 · immutable
·published 2008-02-10 08:59 UTC
rendered paste body
static void CL_ListTranslations (void){	char languagePath[MAX_OSPATH];	char **filelist = NULL;	language_t *tl = NULL, *tc;	cvar_t *fs_i18ndir;	int ndirs, i;	/* Find the proper *.mo file. */	fs_i18ndir = Cvar_Get("fs_i18ndir", "", 0, "System path to language files");	if (*fs_i18ndir->string) {		Q_strncpyz(languagePath, fs_i18ndir->string, sizeof(languagePath));	} else {		Com_sprintf(languagePath, sizeof(languagePath), "%s/"BASEDIRNAME"/i18n/*", FS_GetCwd());	}	/* now check all locale subdirectories if they contain a ufoai.mo file */	Com_DPrintf(DEBUG_CLIENT, "CL_ListTranslations: Searching for mo files using '%s'\n", languagePath);	if ((filelist = FS_ListFiles(languagePath, &ndirs, 0, SFF_HIDDEN | SFF_SYSTEM)) != 0) {		char moPath[MAX_OSPATH];		for (i = 0; i < ndirs - 1; i++) {			Com_sprintf(moPath, sizeof(moPath), "%s/LC_MESSAGES/ufoai.mo", filelist[i]);			if (FS_FileExists(moPath)) {				char lang[32];				char *l = strrchr(filelist[i], '/');				int keylength;				language_t *translation = NULL;				Q_strncpyz(lang, ++l, 32);				if (strlen(lang) == 3) 					continue; /* just ignore 3 letter aliases here... */				keylength = strlen(lang) + 7;				Com_DPrintf(DEBUG_CLIENT, "CL_ListTranslations: Found mo file for Translation '%s'\n", lang);				translation = (language_t *) Mem_PoolAlloc(sizeof(language_t), cl_genericPool, CL_TAG_NONE);				translation->translationLocale = Mem_PoolStrDup(lang, cl_genericPool, CL_TAG_NONE);				translation->msgKey = Mem_PoolAlloc(keylength, cl_genericPool, CL_TAG_NONE);				translationCount++;				Com_sprintf(translation->msgKey, keylength, "_LANG_%s", translation->translationLocale);				Com_DPrintf(DEBUG_CLIENT, "CL_ListTranslations: With msgKey '%s'\n", translation->msgKey);				translation->next = tl;				tl = translation;			}			Mem_Free(filelist[i]);		}		Mem_Free(filelist);	}	Com_DPrintf(DEBUG_CLIENT, "CL_ListTranslations: Found %d translations'\n", translationCount);	translationList = Mem_PoolAlloc(sizeof(language_t *) * translationCount, cl_genericPool, CL_TAG_NONE);	Com_Printf("Found %i translations: \n... ", translationCount);	for (tc = tl, i = 0; tc != NULL; tc = tc->next, i++) {		Com_Printf("%s ", tc->translationLocale);		translationList[i] = tc;	}	Com_Printf("\n");	/* warning about incomplatible poiter type comes from void * instead of const void *. Somewhere it has to be deconsted. */	qsort(translationList, translationCount, sizeof(language_t *), CL_Translation_Sort);}