Ejemplo n.º 1
0
/**
 * @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);
}
Ejemplo n.º 2
0
// Get all filenames and directories
void
PingusMain::init_path_finder()
{
  if (cmd_options.userdir.is_set())
    System::set_userdir(cmd_options.userdir.get());

  System::init_directories();

  if (cmd_options.datadir.is_set())
  {
    g_path_manager.set_path(cmd_options.datadir.get());
  }
  else
  { // do magic to guess the datadir
#if defined(__APPLE__)
    char resource_path[PATH_MAX];
    CFURLRef ref = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
    if (!ref || !CFURLGetFileSystemRepresentation(ref, true, (UInt8*)resource_path, PATH_MAX))
    {
      std::cout << "Error: Couldn't get Resources path.\n" << std::endl;
      exit(EXIT_FAILURE);
    }
    CFRelease(ref);
    g_path_manager.set_path("data");
#else
    g_path_manager.set_path("data"); // assume game is run from source dir
#endif
  }

  // Language is automatically picked from env variable
  //dictionary_manager.set_language(tinygettext::Language::from_env("it_IT.utf8")); // maybe overwritten by file ~/.pingus/config
  dictionary_manager.add_directory(g_path_manager.complete("po/"));
}
void initFactories()
{
    static bool initialized = false;
    if(!initialized) {
        new INTERN_ButtonFactory();
        new INTERN_DesktopFactory();
        new INTERN_DocumentFactory();
        new INTERN_FilledRectangleFactory();
        new INTERN_GradientFactory();
        new INTERN_ImageFactory();
        new INTERN_PanelFactory();
        new INTERN_ParagraphFactory();
        new INTERN_ScrollBarFactory();
        new INTERN_ScrollViewFactory();
        new INTERN_SwitchComponentFactory();
        new INTERN_TableLayoutFactory();
        new INTERN_TooltipManagerFactory();
        new INTERN_WindowFactory();
        new ImportFactory();

        dictionaryGUIManager.set_charset("UTF-8");
        dictionaryGUIManager.add_directory("locale/gui");

        initialized = true;
    }
}
Ejemplo n.º 4
0
static void init_tinygettext()
{
  dictionary_manager.add_directory("locale");
  dictionary_manager.set_charset("UTF-8");
}