/** * @brief Attempts to detect the system language unless cl_lang was already set. * Then loads the PO file containing translated strings. */ void I18N_Init(void) { FL_Locale *locale; std::set<tinygettext::Language> languages; std::set<tinygettext::Language> languages_mod; cl_lang = Cvar_Get("cl_lang", "en", CVAR_ARCHIVE | CVAR_LATCH); cl_langDebug = Cvar_Get("cl_langDebug", "0", CVAR_ARCHIVE); tinygettext::Log::set_log_error_callback(&Tinygettext_Error); tinygettext::Log::set_log_info_callback(&Tinygettext_Info); tinygettext::Log::set_log_warning_callback(&Tinygettext_Warning); FL_FindLocale(&locale); // Do not change the language if it is already set if (!cl_lang->string[0]) { // locale->country is also supported for 'en_US' format if (locale->lang && locale->lang[0]) { Cvar_Set("cl_lang", va("%s", locale->lang)); } else { // Language detection failed. Fallback to English Cvar_Set("cl_lang", "en"); } } dictionary.set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new QFileSystem)); dictionary_mod.set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new QFileSystem)); dictionary.add_directory("locale/client"); dictionary_mod.add_directory("locale/mod"); languages = dictionary.get_languages(); Com_Printf("Available client translations:"); for (std::set<tinygettext::Language>::iterator p = languages.begin(); p != languages.end(); p++) { Com_Printf(" %s", p->get_name().c_str()); } Com_Printf("\n"); languages_mod = dictionary_mod.get_languages(); Com_Printf("Available mod translations:"); for (std::set<tinygettext::Language>::iterator p = languages_mod.begin(); p != languages_mod.end(); p++) { Com_Printf(" %s", p->get_name().c_str()); } Com_Printf("\n"); I18N_SetLanguage(cl_lang->string); FL_FreeLocale(&locale); }