当前位置: 首页>>代码示例>>C++>>正文


C++ Language类代码示例

本文整理汇总了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
}
开发者ID:vnwildman,项目名称:poedit,代码行数:42,代码来源:language.cpp

示例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;
}
开发者ID:mjbshaw,项目名称:derp,代码行数:20,代码来源:foobar-list.cpp

示例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);
}
开发者ID:mfloryan,项目名称:poedit,代码行数:20,代码来源:edapp.cpp

示例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();
}
开发者ID:drodin,项目名称:Crimson,代码行数:20,代码来源:lang.cpp

示例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;
    }
开发者ID:Jakub-Ciecierski,项目名称:AutomataPT,代码行数:21,代码来源:language_relations.cpp

示例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;
    }
开发者ID:Jakub-Ciecierski,项目名称:AutomataPT,代码行数:21,代码来源:language_relations.cpp

示例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());
        }
    }
}
开发者ID:frankencode,项目名称:fluxkit,代码行数:40,代码来源:Palette.cpp

示例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);
}
开发者ID:mapme,项目名称:poedit,代码行数:39,代码来源:propertiesdlg.cpp

示例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); 
}
开发者ID:OS2World,项目名称:LIB-Cubus_OS2_Class_Library,代码行数:23,代码来源:language.cpp

示例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);
}
开发者ID:benpope82,项目名称:poedit,代码行数:14,代码来源:crowdin_client.cpp

示例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);
            }
        }
    }
开发者ID:KDE,项目名称:artikulate,代码行数:37,代码来源:testlanguagefiles.cpp

示例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;
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:37,代码来源:program.cpp

示例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);
}
开发者ID:benpope82,项目名称:poedit,代码行数:16,代码来源:crowdin_client.cpp

示例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; }
	}
}
开发者ID:Poindexter-Games,项目名称:Javamon,代码行数:46,代码来源:KText.cpp

示例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() );
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:36,代码来源:translation.cpp


注:本文中的Language类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。