本文整理汇总了C++中Language::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Language::IsValid方法的具体用法?C++ Language::IsValid怎么用?C++ Language::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::IsValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TryGuessFromFilename
Language Language::TryGuessFromFilename(const wxString& filename)
{
wxFileName fn(filename);
fn.MakeAbsolute();
// Try matching the filename first:
// - entire name
// - suffix (foo.cs_CZ.po, wordpressTheme-cs_CZ.po)
// - directory name (cs_CZ, cs.lproj, cs/LC_MESSAGES)
wxString name = fn.GetName();
Language lang = Language::TryParseWithValidation(name);
if (lang.IsValid())
return lang;
size_t pos = name.find_first_of(".-_");
while (pos != wxString::npos)
{
auto part = name.substr(pos+1);
lang = Language::TryParseWithValidation(part);
if (lang.IsValid())
return lang;
pos = name.find_first_of(".-_", pos+1);
}
auto dirs = fn.GetDirs();
if (!dirs.empty())
{
auto d = dirs.rbegin();
if (d->IsSameAs("LC_MESSAGES", /*caseSensitive=*/false))
{
if (++d == dirs.rend())
return Language(); // failed to match
}
wxString rest;
if (d->EndsWith(".lproj", &rest))
return Language::TryParseWithValidation(rest);
else
return Language::TryParseWithValidation(*d);
}
return Language(); // failed to match
}
示例2: TransferFrom
void PropertiesDialog::TransferFrom(Catalog *cat)
{
cat->Header().Charset = GetCharsetFromCombobox(m_charset);
cat->Header().SourceCodeCharset = GetCharsetFromCombobox(m_sourceCodeCharset);
#define GET_VAL(what,what2) cat->Header().what = m_##what2->GetValue()
GET_VAL(Team, team);
GET_VAL(TeamEmail, teamEmail);
GET_VAL(Project, project);
GET_VAL(BasePath, basePath);
#undef GET_VAL
Language lang = m_language->GetLang();
if (lang.IsValid())
cat->Header().Lang = lang;
wxString dummy;
wxArrayString arr;
cat->Header().SearchPaths.Clear();
cat->Header().Keywords.Clear();
m_paths->GetStrings(arr);
for (size_t i = 0; i < arr.GetCount(); i++)
{
dummy = arr[i];
if (dummy[dummy.Length() - 1] == _T('/') ||
dummy[dummy.Length() - 1] == _T('\\'))
dummy.RemoveLast();
if (!dummy.empty())
cat->Header().SearchPaths.Add(dummy);
}
if (arr.GetCount() > 0 && cat->Header().BasePath.empty())
cat->Header().BasePath = ".";
m_keywords->GetStrings(arr);
cat->Header().Keywords = arr;
wxString pluralForms;
if (m_pluralFormsDefault->GetValue() && cat->Header().Lang.IsValid())
{
pluralForms = cat->Header().Lang.DefaultPluralFormsExpr();
}
if (pluralForms.empty())
{
pluralForms = m_pluralFormsExpr->GetValue().Strip(wxString::both);
if ( !pluralForms.empty() && !pluralForms.EndsWith(";") )
pluralForms += ";";
}
cat->Header().SetHeaderNotEmpty("Plural-Forms", pluralForms);
}
示例3: OnPluralFormsDefault
void PropertiesDialog::OnPluralFormsDefault(wxCommandEvent& event)
{
m_rememberedPluralForm = m_pluralFormsExpr->GetValue();
Language lang = m_language->GetLang();
if (lang.IsValid())
{
wxString defaultForm = lang.DefaultPluralFormsExpr();
if (!defaultForm.empty())
m_pluralFormsExpr->SetValue(defaultForm);
}
event.Skip();
}
示例4: TryParseWithValidation
Language Language::TryParseWithValidation(const std::wstring& s)
{
Language lang = Language::TryParse(s);
if (!lang.IsValid())
return Language(); // invalid
if (!IsISOLanguage(lang.Lang()))
return Language(); // invalid
auto country = lang.Country();
if (!country.empty() && !IsISOCountry(country))
return Language(); // invalid
return lang;
}
示例5: TransferFrom
void PropertiesDialog::TransferFrom(Catalog *cat)
{
cat->Header().Charset = GetCharsetFromCombobox(m_charset);
cat->Header().SourceCodeCharset = GetCharsetFromCombobox(m_sourceCodeCharset);
#define GET_VAL(what,what2) cat->Header().what = m_##what2->GetValue()
GET_VAL(Team, team);
GET_VAL(TeamEmail, teamEmail);
GET_VAL(Project, project);
GET_VAL(BasePath, basePath);
#undef GET_VAL
Language lang = m_language->GetLang();
if (lang.IsValid())
cat->Header().Lang = lang;
GetStringsFromControl(m_keywords, cat->Header().Keywords);
GetPathsFromControl(m_paths, cat->Header().SearchPaths);
GetPathsFromControl(m_excludedPaths, cat->Header().SearchPathsExcluded);
if (!cat->Header().SearchPaths.empty() && cat->Header().BasePath.empty())
cat->Header().BasePath = ".";
m_keywords->GetStrings(cat->Header().Keywords);
wxString pluralForms;
if (m_pluralFormsDefault->GetValue() && cat->Header().Lang.IsValid())
{
pluralForms = cat->Header().Lang.DefaultPluralFormsExpr();
}
if (pluralForms.empty())
{
pluralForms = m_pluralFormsExpr->GetValue().Strip(wxString::both);
if ( !pluralForms.empty() && !pluralForms.EndsWith(";") )
pluralForms += ";";
}
cat->Header().SetHeaderNotEmpty("Plural-Forms", pluralForms);
}