本文整理汇总了C++中Language类的典型用法代码示例。如果您正苦于以下问题:C++ Language类的具体用法?C++ Language怎么用?C++ Language使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Language类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fn
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: main
int main()
{
using Language = derp::Language<char>;
using GC = Language::GarbageCollector;
using Factory = derp::Factory<Language>;
GC gc;
Factory F(gc);
// Language = ("foo" | "bar")*
Language l = *(F("foo") | "bar");
std::cout << "grammar: " << l.toString() << std::endl;
std::cout << "input: " << std::flush;
std::string input;
std::getline(std::cin, input);
std::cout << "matches? " << derp::matches(input, l) << std::endl;
}
示例3: defined
void PoeditApp::SetupLanguage()
{
#if defined(__WXMSW__)
wxLocale::AddCatalogLookupPathPrefix(wxStandardPaths::Get().GetResourcesDir() + "\\Translations");
#elif !defined(__WXMAC__)
wxLocale::AddCatalogLookupPathPrefix(wxStandardPaths::Get().GetInstallPrefix() + "/share/locale");
#endif
wxTranslations *trans = new wxTranslations();
wxTranslations::Set(trans);
#if NEED_CHOOSELANG_UI
trans->SetLanguage(GetUILanguage());
#endif
trans->AddCatalog("poedit");
trans->AddStdCatalog();
Language uiLang = Language::TryParse(trans->GetBestTranslation("poedit"));
UErrorCode err = U_ZERO_ERROR;
icu::Locale::setDefault(uiLang.ToIcu(), err);
}
示例4: SetDefaultLanguage
int Locale::Load( MemBuffer &file ) {
unsigned short langs = file.Read16();
for ( int i = 0; i < langs; ++i ) {
Language lang;
int rc = lang.ReadCatalog( file );
if ( rc >= 0 ) AddLanguage( lang );
else return -1;
}
if ( lib.size() == 0 ) return -1;
if ( !SetDefaultLanguage( CF_LANG_DEFAULT ) ) {
// no english translation found, use something we have
SetDefaultLanguage( lib.begin()->first );
}
return lib.size();
}
示例5: intersection
Language* intersection(const Language& language1,
const Language& language2){
if (!equalAlphabets(language1, language2)){
throw std::invalid_argument("Languages Alphabets must match");
}
Language* intersectionLanguage = new Language(language1.getAlphabet());
for(unsigned int i = 0; i < language1.size(); i++){
Word* word1 = language1.getWord(i);
for(unsigned int j = 0; j < language2.size(); j++){
Word* word2 = language2.getWord(j);
if(*word1 == *word2){
Word* intersectingWord = new Word(word1);
intersectionLanguage->addWord(intersectingWord);
}
}
}
return intersectionLanguage;
}
示例6: similarity
double similarity(const Language &language1, const Language &language2) {
unsigned int size1 = language1.size();
unsigned int size2 = language2.size();
std::vector<double> wordSimilarities;
double similarityLanguage = 0;
for(unsigned int i = 0; i < size1; i++){
wordSimilarities.clear();
Word* word1 = language1.getWord(i);
for(unsigned int j = 0; j < size2; j++){
Word* word2 = language2.getWord(j);
double similarity = word::similarity(*word1, *word2);
wordSimilarities.push_back(similarity);
}
double maxSimilarity = math::max(wordSimilarities);
similarityLanguage += maxSimilarity;
}
similarityLanguage /= size1;
return similarityLanguage;
}
示例7: resourceContext
void Palette::realize(const ByteArray *text, Token *objectToken)
{
scopeName_ = resourceContext()->top()->fileName();
if (scopeName_ == "default") {
scope_ = SyntaxDefinition::scope(scopeName_);
for (int i = 0; i < children()->count(); ++i) {
Style *style = cast<Style>(children()->at(i));
style->rule_ = defaultRuleByName(style->ruleName());
if (style->rule_ == Undefined) {
Token *token = childToken(objectToken, i);
token = valueToken(text, token, "name");
throw SemanticError(
Format("Undefined default style '%%'") << style->ruleName(),
text, token->i1()
);
}
styleByRule_->establish(style->rule_, style);
}
return;
}
Language *language = 0;
if (!registry()->lookupLanguageByName(scopeName_, &language))
throw SemanticError(Format("Undefined language '%%'") << scopeName_);
const SyntaxDefinition *syntax = language->highlightingSyntax();
scope_ = syntax->id();
for (int i = 0; i < children()->count(); ++i) {
Style *style = cast<Style>(children()->at(i));
try {
style->rule_ = syntax->ruleByName(style->ruleName());
styleByRule_->insert(style->rule_, style);
}
catch (DebugError &ex) {
Token *token = childToken(objectToken, i);
token = valueToken(text, token, "name");
throw SemanticError(ex.message(), text, token->i1());
}
}
}
示例8: GetCharsetFromCombobox
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);
}
示例9: main
void main(void)
{
Language l;
try
{
l.selectLang().showDialog();
}
catch(OPMException ex)
{
ex.viewError();
}
catch(OVioException ex)
{
ex.description + "\n";
ex.description + OMessage(ex.rc);
OMsgs().error(ex.description);
}
_exit(0);
}
示例10: DownloadFile
void CrowdinClient::DownloadFile(const std::string& project_id, const std::wstring& file, const Language& lang,
const std::wstring& output_file,
std::function<void()> onSuccess,
error_func_t onError)
{
// NB: "export_translated_only" means the translation is not filled with the source string
// if there's no translation, i.e. what Poedit wants.
auto url = "/api/project/" + project_id + "/export-file"
"?json="
"&export_translated_only=1"
"&language=" + lang.LanguageTag() +
"&file=" + http_client::url_encode(file);
m_api->download(url, output_file, onSuccess, onError);
}
示例11: QString
void TestLanguageFiles::checkIdUniqueness()
{
ResourceManager manager;
QStringList languageFiles = QStandardPaths::locateAll(QStandardPaths::DataLocation, QString("data/languages/*.xml"));
foreach (const QString &file, languageFiles) {
qDebug() << "File being parsed: " << file;
QStringList idList;
const QUrl &languageFile = QUrl::fromLocalFile(file);
QVERIFY(languageFile.isLocalFile());
QXmlSchema schema = loadXmlSchema("language");
QVERIFY(schema.isValid());
QDomDocument document = loadDomDocument(languageFile, schema);
QVERIFY(!document.isNull());
QDomElement root(document.documentElement());
Language *language = new Language(this);
language->setFile(languageFile);
language->setId(root.firstChildElement("id").text());
language->setTitle(root.firstChildElement("title").text());
// create phoneme groups
for (QDomElement groupNode = root.firstChildElement("phonemeGroups").firstChildElement();
!groupNode.isNull();
groupNode = groupNode.nextSiblingElement())
{
for (QDomElement phonemeNode = groupNode.firstChildElement("phonemes").firstChildElement();
!phonemeNode.isNull();
phonemeNode = phonemeNode.nextSiblingElement())
{
QString id = phonemeNode.firstChildElement("id").text();
qDebug() << "ID: " << id;
QVERIFY2(!idList.contains(id),"Phoneme ID used more than once in the tested file");
idList.append(id);
}
}
}
示例12: main
int Program::main(const std::vector<CL_String> &args)
{
try
{
// Initialize ClanLib base components
CL_SetupCore setup_core;
// Initialize the ClanLib display component
CL_SetupDisplay setup_display;
#ifdef USE_SOFTWARE_RENDERER
CL_SetupSWRender setup_swrender;
#endif
#ifdef USE_OPENGL_1
CL_SetupGL1 setup_gl1;
#endif
#ifdef USE_OPENGL_2
CL_SetupGL setup_gl;
#endif
// Start the Application
Language app;
int retval = app.start(args);
return retval;
}
catch(CL_Exception &exception)
{
// Create a console window for text-output if not available
CL_ConsoleWindow console("Console", 80, 160);
CL_Console::write_line("Exception caught: " + exception.get_message_and_stack_trace());
console.display_close_message();
return -1;
}
}
示例13: UploadFile
void CrowdinClient::UploadFile(const std::string& project_id, const std::wstring& file, const Language& lang,
const std::string& file_content,
std::function<void()> onSuccess,
error_func_t onError)
{
auto url = "/api/project/" + project_id + "/upload-translation";
multipart_form_data data;
data.add_value("json", "");
data.add_value("language", lang.LanguageTag());
data.add_value("import_duplicates", "0");
data.add_value("import_eq_suggestions", "0");
data.add_file("files[" + str::to_utf8(file) + "]", "upload.po", file_content);
m_api->post(url, data, onSuccess, onError);
}
示例14: file
KText::KText(Language lang)
{
KText::lang = lang;
sf::Image fontImg;
fontImg.loadFromFile(VIDEO + L"Basic_Latin.png");
basic_latin = sf::Texture();
basic_latin.loadFromImage(fontImg);
latinWidths = new int[256];
for (int i = 0; i < 256; i++) { latinWidths[i] = FONT_SIZE; }
KFile file(VIDEO + L"Latin_Widths.txt");
bool comment = false;
wstring w;
for (bool b = true; b; )
{
file.readLine(w);
if (w.length() == 0) continue;
if (StringEditor::equals(w, L"endFile;")) {
break;
}
else
{
int equals = StringEditor::findCharacter(w, L'=', 1);
latinWidths[stoi(StringEditor::substring(w, 0, equals))] = stoi(StringEditor::substring(w, equals + 1, w.length()));
}
}
file.close();
//JAPANESE
if (lang.getLanguageCode().toWideString().compare(L"ja-JP") == 0)
{
sf::Image japaneseImg;
japaneseImg.loadFromFile(VIDEO + L"Japanese.png");
japanese = sf::Texture();
japanese.loadFromImage(japaneseImg);
for (int i = 0; i < 256; i++) { latinWidths[i] = FONT_SIZE / 2; }
}
}
示例15: Trans_SetLanguage
void Trans_SetLanguage( const char* lang )
{
Language requestLang = Language::from_env( std::string( lang ) );
// default to english
Language bestLang = Language::from_env( "en" );
int bestScore = Language::match( requestLang, bestLang );
std::set<Language> langs = trans_manager.get_languages();
for( std::set<Language>::iterator i = langs.begin(); i != langs.end(); i++ )
{
int score = Language::match( requestLang, *i );
if( score > bestScore )
{
bestScore = score;
bestLang = *i;
}
}
// language not found, display warning
if( bestScore == 0 )
{
Com_Printf( S_WARNING "Language \"%s\" (%s) not found. Default to \"English\" (en)\n",
requestLang.get_name().empty() ? "Unknown Language" : requestLang.get_name().c_str(),
lang );
}
trans_manager.set_language( bestLang );
trans_managergame.set_language( bestLang );
Cvar_Set( "language", bestLang.str().c_str() );
Com_Printf( "Set language to %s" , bestLang.get_name().c_str() );
}