From: Abdelrazak Younes Date: Thu, 14 Jul 2011 08:47:56 +0000 (+0000) Subject: - Coding style X-Git-Tag: 2.1.0beta1~2932 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=dba4f28b6269c0ebd7a4e70a82ca10cf6c4a6ff8;p=lyx.git - Coding style - Move local functions closer to where they are used. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39296 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Language.cpp b/src/Language.cpp index 8f984325d8..8e5f86fa83 100644 --- a/src/Language.cpp +++ b/src/Language.cpp @@ -28,7 +28,6 @@ using namespace std; using namespace lyx::support; - namespace lyx { Languages languages; @@ -194,57 +193,14 @@ bool Language::read(Lexer & lex) } -namespace { - -bool readTranslations(Lexer & lex, Language::TranslationMap & trans) -{ - while (lex.isOK()) { - if (lex.checkFor("End")) - break; - if (!lex.next(true)) - return false; - string const key = lex.getString(); - if (!lex.next(true)) - return false; - docstring const val = lex.getDocString(); - trans[key] = val; - } - return true; -} - -enum Match{NoMatch, ApproximateMatch, ExactMatch}; - -Match match(string const & code, Language const & lang) -{ - // we need to mimic gettext: code can be a two-letter code, which - // should match all variants, e.g. "de" should match "de_DE", - // "de_AT" etc. - // special case for chinese: - // simplified => code == "zh_CN", langcode == "zh_CN" - // traditional => code == "zh_TW", langcode == "zh_CN" - string const variety = lang.variety(); - string const langcode = variety.empty() ? - lang.code() : lang.code() + '_' + variety; - string const name = lang.lang(); - if ((code == langcode && name != "chinese-traditional") || - (code == "zh_TW" && name == "chinese-traditional")) - return ExactMatch; - if ((code.size() == 2 && langcode.size() > 2 && - code + '_' == langcode.substr(0, 3))) - return ApproximateMatch; - return NoMatch; -} - -} - - void Language::readLayoutTranslations(Language::TranslationMap const & trans, bool replace) { TranslationMap::const_iterator const end = trans.end(); - for (TranslationMap::const_iterator it = trans.begin(); it != end; ++it) - if (replace || - layoutTranslations_.find(it->first) == layoutTranslations_.end()) + for (TranslationMap::const_iterator it = trans.begin(); it != end; ++it) { + if (replace + || layoutTranslations_.find(it->first) == layoutTranslations_.end()) layoutTranslations_[it->first] = it->second; + } } @@ -294,6 +250,56 @@ void Languages::read(FileName const & filename) } +namespace { + +bool readTranslations(Lexer & lex, Language::TranslationMap & trans) +{ + while (lex.isOK()) { + if (lex.checkFor("End")) + break; + if (!lex.next(true)) + return false; + string const key = lex.getString(); + if (!lex.next(true)) + return false; + docstring const val = lex.getDocString(); + trans[key] = val; + } + return true; +} + + +enum Match { + NoMatch, + ApproximateMatch, + ExactMatch +}; + + +Match match(string const & code, Language const & lang) +{ + // we need to mimic gettext: code can be a two-letter code, which + // should match all variants, e.g. "de" should match "de_DE", + // "de_AT" etc. + // special case for chinese: + // simplified => code == "zh_CN", langcode == "zh_CN" + // traditional => code == "zh_TW", langcode == "zh_CN" + string const variety = lang.variety(); + string const langcode = variety.empty() ? + lang.code() : lang.code() + '_' + variety; + string const name = lang.lang(); + if ((code == langcode && name != "chinese-traditional") + || (code == "zh_TW" && name == "chinese-traditional")) + return ExactMatch; + if ((code.size() == 2) && (langcode.size() > 2) + && (code + '_' == langcode.substr(0, 3))) + return ApproximateMatch; + return NoMatch; +} + +} + + void Languages::readLayoutTranslations(support::FileName const & filename) { Lexer lex;