Пример #1
0
language_c::language_c(char * setupLang, SystemDefault_c * SystemDefault) : collection_c() {
  current = -1;
  langDir = new char[MAX_PATH];
  strcpy(langDir,SystemDefault->PrgPath);
  strcat(langDir,"lang\\");
  char * SerPath = new char[MAX_PATH];
  strcpy(SerPath,langDir);
  strcat(SerPath,"*.xml");
  WIN32_FIND_DATA FindFileData;
  HANDLE hFind;
  hFind = FindFirstFile(SerPath, &FindFileData);
  if (hFind != INVALID_HANDLE_VALUE) {
    LoadLanguageFile(FindFileData.cFileName);
    while (FindNextFile(hFind,&FindFileData )) {
      LoadLanguageFile(FindFileData.cFileName);
    }
    FindClose(hFind);
  }
  delete[] SerPath;
//////////////////////////////
// Detect Systemdefault
//////////////////////////////
//  setup = aSetup;
  int ConfigLang = hexToInt(setupLang);
  current = getLangID(ConfigLang);
  if (current == -1) {
    int UserLang = GetUserDefaultUILanguage();
    if (current == -1) {current = getLangID(UserLang);}
    if (current == -1) {current = getLangIDMain(PRIMARYLANGID(UserLang));}
    int SysLang = GetSystemDefaultUILanguage();
    if (current == -1) {current = getLangID(SysLang);}
    if (current == -1) {current = getLangIDMain(PRIMARYLANGID(SysLang));}
  }
}
Пример #2
0
/**
 * Reads the selected LanguageFile into the cache
 */
void
ReadLanguageFile()
{
#ifndef HAVE_NATIVE_GETTEXT
  CloseLanguageFile();

  LogFormat("Loading language file");

  TCHAR buffer[MAX_PATH], second_buffer[MAX_PATH];
  const TCHAR *value = Profile::GetPath(ProfileKeys::LanguageFile, buffer)
    ? buffer : _T("");

  if (StringIsEqual(value, _T("none")))
    return;

  if (StringIsEmpty(value) || StringIsEqual(value, _T("auto"))) {
    AutoDetectLanguage();
    return;
  }

  const TCHAR *base = BaseName(value);
  if (base == NULL)
    base = value;

  if (base == value) {
    LocalPath(second_buffer, value);
    value = second_buffer;
  }

  if (!LoadLanguageFile(value) && !ReadResourceLanguageFile(base))
    AutoDetectLanguage();
#endif
}
/**
 * Reads the selected LanguageFile into the cache
 */
void
ReadLanguageFile()
{
  CloseLanguageFile();

  LogStartUp(_T("Loading language file"));

  TCHAR buffer[MAX_PATH], second_buffer[MAX_PATH];
  const TCHAR *value = Profile::GetPath(szProfileLanguageFile, buffer)
    ? buffer : _T("");

  if (_tcscmp(value, _T("none")) == 0)
    return;

  if (string_is_empty(value) || _tcscmp(value, _T("auto")) == 0) {
    AutoDetectLanguage();
    return;
  }

  const TCHAR *base = BaseName(value);
  if (base == NULL)
    base = value;

  if (base == value) {
    LocalPath(second_buffer, value);
    value = second_buffer;
  }

  if (!LoadLanguageFile(value) && !ReadResourceLanguageFile(base))
    AutoDetectLanguage();
}
Пример #4
0
bool SearchAndLoadLanguageFile(
		const TCHAR* lpPath,
		const TCHAR* lpLanguage,
		TCHAR**& pStrings,
		int& nStringsCount
		)
{
	return FALSE; //BUGBUG

	bool bResult = false;

	TCHAR* lpMask = StrDuplicate(lpPath);
	CutToSlash (lpMask);

	_tcscat (lpMask, _T("*.lng"));

	WIN32_FIND_DATA FindData;

	HANDLE hSearch = FindFirstFile (
			lpMask,
			(WIN32_FIND_DATA*)&FindData
			);

	if ( hSearch != INVALID_HANDLE_VALUE )
	{
		do {

			CutToSlash (lpMask);
			_tcscat (lpMask, FindData.cFileName);

			pStrings = NULL;

			bResult = LoadLanguageFile(
					lpMask,
					lpLanguage,
					pStrings,
					nStringsCount
					);

		} while ( !bResult && FindNextFile (hSearch, (WIN32_FIND_DATA*)&FindData) );

		FindClose (hSearch);
	}

	StrFree(lpMask);

	return bResult;
}