예제 #1
0
static void
AutoDetectLanguage()
{
  // Try to detect the language by calling the OS's corresponding functions
  const auto l = DetectLanguage();
  if (l != nullptr)
    // If a language was detected -> try to load the MO file
    ReadBuiltinLanguage(*l);
}
예제 #2
0
static void
AutoDetectLanguage()
{
#ifdef HAVE_NATIVE_GETTEXT

  // Set the current locale to the environment's default
  setlocale(LC_ALL, "");
  // always use a dot as decimal point in printf/scanf()
  setlocale(LC_NUMERIC, "C");
  bindtextdomain("xcsoar", "/usr/share/locale");
  textdomain("xcsoar");

#else /* !HAVE_NATIVE_GETTEXT */

  // Try to detect the language by calling the OS's corresponding functions
  const TCHAR *resource = DetectLanguage();
  if (resource != NULL)
    // If a language was detected -> try to load the MO file
    ReadResourceLanguageFile(resource);

#endif /* !HAVE_NATIVE_GETTEXT */
}
예제 #3
0
BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved )
{
	switch ( ul_reason_for_call )
	{
	case DLL_PROCESS_ATTACH:
		DisableThreadLibraryCalls( hModule );
		if( !prepareHeap())
			return FALSE;
		DebugWriteA("*** DLL Attach (" VERSIONNUMBER "-Debugbuild | built on " __DATE__ " at " __TIME__")\n");
		ZeroMemory( &g_strEmuInfo, sizeof(g_strEmuInfo) );
		ZeroMemory( g_devList, sizeof(g_devList) );
		ZeroMemory( &g_sysMouse, sizeof(g_sysMouse) );
		ZeroMemory( g_aszDefFolders, sizeof(g_aszDefFolders) );
		ZeroMemory( g_aszLastBrowse, sizeof(g_aszLastBrowse) );
		g_strEmuInfo.hinst = hModule;
		g_strEmuInfo.fDisplayShortPop = true;	// display pak switching message windows by default
#ifdef _UNICODE
		{
			g_strEmuInfo.Language = GetLanguageFromINI();
			if ( g_strEmuInfo.Language == 0 )
			{
				g_strEmuInfo.Language = DetectLanguage();
				DebugWriteA("Autoselect language: %d\n", g_strEmuInfo.Language);
			}
			g_hResourceDLL = LoadLanguageDLL(g_strEmuInfo.Language); // HACK: it's theoretically not safe to call LoadLibraryEx from DllMain... --rabid
			if( g_hResourceDLL == NULL )
			{
				g_strEmuInfo.Language = 0;
				g_hResourceDLL = hModule;
				DebugWriteA("couldn't load language DLL, falling back to defaults\n");
			}
		}
#else
		DebugWriteA("  (compiled in ANSI mode, language detection DISABLED.)\n");
		g_strEmuInfo.Language = 0;
		g_hResourceDLL = hModule;
#endif // #ifndef _UNICODE
		InitializeCriticalSection( &g_critical );
		break;

	case DLL_THREAD_ATTACH:
		break;

	case DLL_THREAD_DETACH:
		break;

	case DLL_PROCESS_DETACH:
		//CloseDLL();
		if (g_hResourceDLL != g_strEmuInfo.hinst)
			FreeLibrary(g_hResourceDLL); // HACK: it's not safe to call FreeLibrary from DllMain... but screw it

		DebugWriteA("*** DLL Detach\n");

		CloseDebugFile(); // Moved here from CloseDll
		DeleteCriticalSection( &g_critical );

		// Moved here from CloseDll... Heap is created from DllMain,
		// and now it's destroyed by DllMain... just safer code --rabid
		if( g_hHeap != NULL )
		{
			HeapDestroy( g_hHeap );
			g_hHeap = NULL;
		}
		break;
	}
    return TRUE;
}