예제 #1
0
void CFileZillaApp::InitLocale()
{
	wxString language = COptions::Get()->GetOption(OPTION_LANGUAGE);
	const wxLanguageInfo* pInfo = wxLocale::FindLanguageInfo(language);
	if (!language.empty()) {
#ifdef __WXGTK__
		if (CInitializer::error) {
			wxString error;

			wxLocale *loc = wxGetLocale();
			const wxLanguageInfo* currentInfo = loc ? loc->GetLanguageInfo(loc->GetLanguage()) : 0;
			if (!loc || !currentInfo) {
				if (!pInfo)
					error.Printf(_("Failed to set language to %s, using default system language."),
						language);
				else
					error.Printf(_("Failed to set language to %s (%s), using default system language."),
						pInfo->Description, language);
			}
			else {
				wxString currentName = currentInfo->CanonicalName;

				if (!pInfo)
					error.Printf(_("Failed to set language to %s, using default system language (%s, %s)."),
						language, loc->GetLocale(),
						currentName);
				else
					error.Printf(_("Failed to set language to %s (%s), using default system language (%s, %s)."),
						pInfo->Description, language, loc->GetLocale(),
						currentName);
			}

			error += _T("\n");
			error += _("Please make sure the requested locale is installed on your system.");
			wxMessageBoxEx(error, _("Failed to change language"), wxICON_EXCLAMATION);

			COptions::Get()->SetOption(OPTION_LANGUAGE, _T(""));
		}
#else
		if (!pInfo || !SetLocale(pInfo->Language)) {
			for( language = GetFallbackLocale(language); !language.empty(); language = GetFallbackLocale(language) ) {
				const wxLanguageInfo* fallbackInfo = wxLocale::FindLanguageInfo(language);
				if( fallbackInfo && SetLocale(fallbackInfo->Language )) {
					COptions::Get()->SetOption(OPTION_LANGUAGE, language.ToStdWstring());
					return;
				}
			}
			COptions::Get()->SetOption(OPTION_LANGUAGE, std::wstring());
			if (pInfo && !pInfo->Description.empty())
				wxMessageBoxEx(wxString::Format(_("Failed to set language to %s (%s), using default system language"), pInfo->Description, language), _("Failed to change language"), wxICON_EXCLAMATION);
			else
				wxMessageBoxEx(wxString::Format(_("Failed to set language to %s, using default system language"), language), _("Failed to change language"), wxICON_EXCLAMATION);
		}
#endif
	}
}
예제 #2
0
파일: lset.cpp 프로젝트: drodin/Crimson
int UnitSet::LoadUnitTypes( MemBuffer &file ) {
  ut = new UnitType [num_tiles];
  if ( !ut ) return -1;

  int rc = 0;

  for ( int i = 0; i < num_tiles; ++i ) {
    if ( ut[i].Load( file, this ) ) {
      rc = -1;
      break;
    }
  }

  // load unit names in different languages
  if ( rc == 0 )
    rc = unit_names.Load( file );

  if ( rc == -1 ) {
      delete [] ut;
      ut = NULL;
      num_tiles = 0;
      return -1;
  }

  SetLocale( CF_LANG_DEFAULT );
  return 0;
}
예제 #3
0
void App::InitLocale()
{
    g_locale = new wxLocale();

    // add translations missing from wxWidgets
    UD_LNG(wxUD_LANGUAGE_BOSNIAN,           "bs"   , LANG_BOSNIAN  , SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN, wxLayout_LeftToRight, "Bosnian");
    UD_LNG(wxUD_LANGUAGE_ILOKO,             "ilo"  , 0             , 0              , wxLayout_LeftToRight, "Iloko");
    UD_LNG(wxUD_LANGUAGE_KAPAMPANGAN,       "pam"  , 0             , 0              , wxLayout_LeftToRight, "Kapampangan");
    UD_LNG(wxUD_LANGUAGE_NORWEGIAN,         "no"   , LANG_NORWEGIAN, SUBLANG_DEFAULT, wxLayout_LeftToRight, "Norwegian");
    UD_LNG(wxUD_LANGUAGE_WARAY_WARAY,       "war"  , 0             , 0              , wxLayout_LeftToRight, "Waray-Waray");
    UD_LNG(wxUD_LANGUAGE_ACOLI,             "ach"  , 0             , 0              , wxLayout_LeftToRight, "Acoli");
    UD_LNG(wxUD_LANGUAGE_SINHALA_SRI_LANKA, "si_LK", 0             , 0              , wxLayout_LeftToRight, "Sinhala (Sri Lanka)");

    // get initial language selection
    int id = wxLANGUAGE_ENGLISH_US;
    wxConfigBase *cfg = wxConfigBase::Get();
    if(cfg->HasGroup(wxT("Language"))){
        id = (int)cfg->Read(wxT("/Language/Selected"),id);
    } else {
        id = g_locale->GetSystemLanguage();
        if(id == wxLANGUAGE_UNKNOWN)
            id = wxLANGUAGE_ENGLISH_US;
    }

    SetLocale(id);
}
예제 #4
0
bool CaMuleExternalConnector::OnInit()
{
#ifndef __WINDOWS__ 
	#if wxUSE_ON_FATAL_EXCEPTION
		// catch fatal exceptions
		wxHandleFatalExceptions(true);
	#endif
#endif

	// If we didn't know that OnInit is called only once when creating the
	// object, it could cause a memory leak. The two pointers below should
	// be free()'d before assigning the new value.
	// cppcheck-suppress publicAllocationError
	m_strFullVersion = strdup((const char *)unicode2char(GetMuleVersion()));
	m_strOSDescription = strdup((const char *)unicode2char(wxGetOsDescription()));

	// Handle uncaught exceptions
	InstallMuleExceptionHandler();

	bool retval = wxApp::OnInit();
	OnInitCommandSet();
	InitCustomLanguages();
	SetLocale(m_language);
	return retval;
}
예제 #5
0
void
TAutoVal::operator =(TString s)
{
  vt = atString;
  bstrVal = ::SysAllocString((const OLECHAR *)s);
  SetLocale(s.GetLangId() ? s.GetLangId() : TLocaleString::NativeLangId);
}
예제 #6
0
bool CInitializer::SetLocale(const std::string& arg)
{
    const char *encodings[] = {
        "UTF-8",
        "UTF8",
        "utf-8",
        "utf8",
        0
    };

    for (int i = 0; encodings[i]; i++)
    {
        std::string locale = CInitializer::LocaleAddEncoding(arg, encodings[i]);
        if (SetLocaleReal(locale))
            return true;
    }

    if (CInitializer::SetLocaleReal(arg))
        return true;

    int i = 0;
    while (fallbacks[i].locale)
    {
        if (fallbacks[i].locale == arg)
            return SetLocale(fallbacks[i].fallback);
        i++;
    }

    return false;
}
예제 #7
0
void CTestUTCSort::CreateMessagesL()
	{
	
	TMsvId emailMessageID;
	CImEmailOperation* emailOp;
	TMsvPartList partList;
	partList = (KMsvMessagePartBody | KMsvMessagePartAttachments);
		
	for(TInt count=0;count<KNumEmailMessages;++count)
		{
		//change the UTC offset for each message
		SetLocale(count);
		//wait for a bit
		User::After(1000000);
		
		emailOp = CImEmailOperation::CreateNewL(iTestActive->iStatus, *iSession, KMsvDraftEntryIdValue, KMsvMessagePartBody, partList, KUidMsgTypeSMTP); 
		CleanupStack::PushL(emailOp);
		// Active object which stops the active scheduler
		iTestActive->StartL(); 
		CActiveScheduler::Start();
		
		// Get the new message id.
		TPckg<TMsvId> param(emailMessageID);
		param.Copy(emailOp->FinalProgress());
		
		iTMsvIdList->AppendL(emailMessageID);		
		CleanupStack::PopAndDestroy(emailOp); 
		}	
	
	}
예제 #8
0
void
fbLocaleManager::SetCountry(const char* country)
{
	if (country && strlen(country))
	{
		SetLocale(NULL, country);
	}
}
예제 #9
0
void
fbLocaleManager::SetLanguage(const char* language)
{
	if (language && strlen(language))
	{
		SetLocale(language, NULL);
	}
}
예제 #10
0
void UnionLabelPreparerRus::PrepareUnitedPossibleStates()
{
    wifstream in(string(DISAMBIGUATOR_CONFIG) + "Token_Label.txt");
    SetLocale(in);
    wstring line;
    vector<wstring> splitted;
    int enumerator = 0;
    while (getline(in, line))
    {
        ++enumerator;
        wcout << enumerator << std::endl;
        // Get token and label
        wstring token;
        wstring label;
        Tools::Split(line, L"\t", splitted);
        if (splitted.size() != 2)
        {
            continue;
        }
        label = splitted[1];
        Tools::Split(wstring(splitted[0]), L"|", splitted);
        token = splitted[0];
        // Get gram info
        vector<GrammInfo> data = dictionary->getGrammInfo(token, 2);
        // Get labels
        vector<wstring> labels;
        for (size_t tokenIndex = 0; tokenIndex < data.size(); ++tokenIndex)
        {
            vector<wstring> opFeatures = data[tokenIndex].features;
            if (opFeatures.size() == 0)
            {
                continue;
            }
            wstring opLabel = opFeatures[0];
            for (size_t iter = 1; iter < opFeatures.size(); ++iter)
            {
                opLabel += L" - " + opFeatures[iter];
            }
            vector<wstring> syntagLabel = converter.PartialConvert(opLabel);
            labels.insert(labels.end(), syntagLabel.begin(), syntagLabel.end());
        }
        // Add united label
        wstring unitedLabel = getUnitedLabel(labels);
        if (unitedLabel.size() == 0)
        {
            unitedLabel = label;
        }
        if (unitedLabels.find(unitedLabel) != unitedLabels.end())
        {
            ++unitedLabels[unitedLabel];
        } else {
            unitedLabels[unitedLabel] = 1;
        }
        Print(string(DISAMBIGUATOR_CONFIG) + "UnitedLabels.txt", unitedLabels);
    }
    in.close();
}
예제 #11
0
void
fbLocaleManager::ReadSystemSettings()
{
	string systemSettings = C_SYSTEM_SETTINGS;
	if(!FileExists(systemSettings.c_str()))
	{
		systemSettings  = C_ROOTFS;
		systemSettings.append(C_SYSTEM_SETTINGS);
		if(!FileExists(systemSettings.c_str()))
		{
			systemSettings.erase();
		}
	}
	if(!systemSettings.empty())
	{
		FILE* fp;
		if ((fp = fopen(systemSettings.c_str(), "r")) != NULL)
		{
			string language;
			string country;
			uint16_t bufSize = 80;
			char buffer[bufSize];
			while (fgets(buffer, bufSize, fp) != NULL && (country.empty() || language.empty()))
			{
				char* p = strrchr(buffer, '\n');
				if (p)
				{
					*p = '\0';
				}
				if (strlen(buffer))
				{
					if (language.empty() && strstr(buffer, C_LOCALE_LANGUAGE_PATTERN) == buffer)
					{
						language = buffer + strlen(C_LOCALE_LANGUAGE_PATTERN);
						language = trim(language);
					}
					else if (country.empty() && strstr(buffer, C_LOCALE_COUNTRY_PATTERN) == buffer)
					{
						country = buffer + strlen(C_LOCALE_COUNTRY_PATTERN);
						country = trim(country);
					}
				}
			}
			if (!language.empty())
			{
				m_language = to_lower(language);
			}
			if (!country.empty())
			{
				m_country = to_lower(country);
			}
			SetLocale(NULL, NULL);
			fclose(fp);
		}
	}
}
예제 #12
0
void
fbLocaleManager::Init()
{
	m_language = C_DEFAULT_LANGUAGE;
	m_country  = C_DEFAULT_COUNTRY;
	to_lower(m_language);
	to_lower(m_country);
	SetLocale(NULL, NULL);
	m_default = m_locale;
	ReadSystemSettings();
}
예제 #13
0
void
TAutoVal::operator =(const owl::tstring& s)
{
  vt = atString;
#if defined(_UNICODE)
  bstrVal = ::SysAllocString(s.c_str());
#else
  bstrVal = ::owl::SysAllocString(s.c_str());
#endif
  SetLocale(TLocaleString::NativeLangId);
}
예제 #14
0
bool LocaleRoster::SetLocale(const char *name)
{
	if(!name)
		return false;
	
	for(int32 i=0; i<fLocaleList.CountItems(); i++)
	{
		Locale *locale = (Locale*)fLocaleList.ItemAt(i);
		if(locale && strcmp(locale->Name(),name)==0)
		{
			SetLocale(locale);
			return true;
		}
	}
	return false;
}
예제 #15
0
void
fbLocaleManager::SetLocale(string& language, string& country)
{
	SetLocale(language.c_str(), country.c_str());
}
예제 #16
0
void LocaleRoster::SetLocale(const int32 &index)
{
	Locale *locale = (Locale *) fLocaleList.ItemAt(index);
	
	SetLocale(locale);
}
예제 #17
0
// Read the string table
bool LoadTableMain(wchar_t *filename)
{
	BUF *b;
	UINT64 t1, t2;
	UCHAR hash[MD5_SIZE];
	// Validate arguments
	if (filename == NULL)
	{
		return false;
	}

	if (MayaquaIsMinimalMode())
	{
		return true;
	}

	if (UniStrCmpi(old_table_name, filename) == 0)
	{
		// Already loaded
		return true;
	}

	t1 = Tick64();

	// Open the file
	b = ReadDumpW(filename);
	if (b == NULL)
	{
		char tmp[MAX_SIZE];
		StrCpy(tmp, sizeof(tmp), "Error: Can't read string tables (file not found).\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)");
		Alert(tmp, NULL);
		exit(-1);
		return false;
	}

	Hash(hash, b->Buf, b->Size, false);

	if (LoadUnicodeCache(filename, b->Size, hash) == false)
	{
		if (LoadTableFromBuf(b) == false)
		{
			FreeBuf(b);
			return false;
		}

		SaveUnicodeCache(filename, b->Size, hash);

		//Debug("Unicode Source: strtable.stb\n");
	}
	else
	{
		//Debug("Unicode Source: unicode_cache\n");
	}

	FreeBuf(b);

	SetLocale(_UU("DEFAULE_LOCALE"));

	UniStrCpy(old_table_name, sizeof(old_table_name), filename);

	t2 = Tick64();

	if (StrCmpi(_SS("STRTABLE_ID"), STRTABLE_ID) != 0)
	{
		char tmp[MAX_SIZE];
		Format(tmp, sizeof(tmp), "Error: Can't read string tables (invalid version: '%s'!='%s').\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)",
			_SS("STRTABLE_ID"), STRTABLE_ID);
		Alert(tmp, NULL);
		exit(-1);
		return false;
	}

	//Debug("Unicode File Read Cost: %u (%u Lines)\n", (UINT)(t2 - t1), LIST_NUM(TableList));

	return true;
}