The languages file rewrite.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36285 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-11-13 17:25:03 +00:00
parent a85ae19bf8
commit 148f2d648c
8 changed files with 743 additions and 143 deletions

View File

@ -212,6 +212,11 @@ Known issues in version 2.0.0
Caveats when upgrading from earlier versions to 2.0.x Caveats when upgrading from earlier versions to 2.0.x
------------------------------------------------------- -------------------------------------------------------
- The syntax of the languages file has been changed. If you use a modified
languages file, you will need to adapt it to the new syntax, as LyX 2.0
is not able to read old languages file anymore.
Please refer to the beginning of the languages file for an explanation
of the new syntax.

View File

@ -1,89 +1,604 @@
# name babel name GUI name RTL? encoding code latex options ########################################################################
# LyX internal languages #
ignore ignore "Ignore" false iso8859-1 ignore "" # Languages supported by LyX.
latex "" "LaTeX" false iso8859-1 latex "" #
# Real languages now # Syntax:
afrikaans afrikaans "Afrikaans" false iso8859-15 af_ZA "" #
albanian albanian "Albanian" false iso8859-2 sq_AL "" # Language <lyxname>
american american "English (USA)" false iso8859-15 en_US "" # GuiName "<Gui Name>"
# FIXME: dummy babel language for arabic_arabtex to be able to switch the language the way of the ArabTeX-package # BabelName <babelname>
arabic_arabtex arabtex "Arabic (ArabTeX)" true cp1256 ar_SA "" # Encoding <encoding>
arabic_arabi arabic "Arabic (Arabi)" true cp1256 ar_SA "" # InternalEncoding <true|false>
armenian "" "Armenian" false armscii8 hy_AM "" # RTL <true|false>
austrian austrian "German (Austria, old spelling)" false iso8859-15 de_AT "" # LangCode <language_code>
naustrian naustrian "German (Austria)" false iso8859-15 de_AT "" # LangVariety <language_variety>
bahasa bahasa "Indonesian" false iso8859-15 id_ID "" # PostBabelPreamble
bahasam bahasam "Malay" false iso8859-15 ms_MY "" # <extra latex code inserted after babel>
basque basque "Basque" false iso8859-15 eu_ES "" # EndPostBabelPreamble
belarusian belarusian "Belarusian" false cp1251 be_BY "" # End
brazilian brazil "Portuguese (Brazil)" false iso8859-15 pt_BR "" #
breton breton "Breton" false iso8859-15 br_FR "" # Omitted elements will be treated as empty
british british "English (UK)" false iso8859-15 en_GB "" # (omitted RTL and InternalEncoding as "false")
bulgarian bulgarian "Bulgarian" false cp1251 bg_BG "" #
canadian canadian "English (Canada)" false iso8859-15 en_CA "" ########################################################################
canadien canadien "French (Canada)" false iso8859-15 fr_CA ""
catalan catalan "Catalan" false iso8859-15 ca_ES "" #
chinese-simplified "" "Chinese (simplified)" false euc-cn zh_CN "" # LyX-internal languages
chinese-traditional "" "Chinese (traditional)" false utf8-cjk zh_CN "" #
croatian croatian "Croatian" false iso8859-2 hr_HR ""
czech czech "Czech" false iso8859-2 cs_CZ "" Language ignore
danish danish "Danish" false iso8859-15 da_DK "" GuiName "Ignore"
dutch dutch "Dutch" false iso8859-15 nl_NL "" BabelName ignore
english english "English" false iso8859-15 en_US "" Encoding iso8859-1
LangCode ignore
End
Language latex
GuiName "LaTeX"
Encoding iso8859-1
LangCode latex
End
#
# Real languages
#
Language afrikaans
GuiName "Afrikaans"
BabelName afrikaans
Encoding iso8859-15
LangCode af_ZA
End
Language albanian
GuiName "Albanian"
BabelName albanian
Encoding iso8859-2
LangCode sq_AL
End
Language american
GuiName "English (USA)"
BabelName american
Encoding iso8859-15
LangCode en_US
End
# FIXME: dummy babel language for arabic_arabtex to be able
# to switch the language the way of the ArabTeX-package
Language arabic_arabtex
GuiName "Arabic (ArabTeX)"
BabelName arabtex
Encoding cp1256
RTL true
LangCode ar_SA
End
Language arabic_arabi
GuiName "Arabic (Arabi)"
BabelName arabic
Encoding cp1256
RTL true
LangCode ar_SA
End
Language armenian
GuiName "Armenian"
Encoding armscii8
LangCode hy_AM
End
Language austrian
GuiName "German (Austria, old spelling)"
BabelName austrian
Encoding iso8859-15
LangCode de_AT
End
Language naustrian
GuiName "German (Austria)"
BabelName naustrian
Encoding iso8859-15
LangCode de_AT
End
Language bahasa
GuiName "Indonesian"
BabelName bahasa
Encoding iso8859-15
LangCode id_ID
End
Language bahasam
GuiName "Malay"
BabelName bahasam
Encoding iso8859-15
LangCode ms_MY
End
Language basque
GuiName "Basque"
BabelName basque
Encoding iso8859-15
LangCode eu_ES
End
Language belarusian
GuiName "Belarusian"
BabelName belarusian
Encoding cp1251
LangCode be_BY
End
Language brazilian
GuiName "Portuguese (Brazil)"
BabelName brazil
Encoding iso8859-15
LangCode pt_BR
End
Language breton
GuiName "Breton"
BabelName breton
Encoding iso8859-15
LangCode br_FR
End
Language british
GuiName "English (UK)"
BabelName british
Encoding iso8859-15
LangCode en_GB
End
Language bulgarian
GuiName "Bulgarian"
BabelName bulgarian
Encoding cp1251
LangCode bg_BG
End
Language canadian
GuiName "English (Canada)"
BabelName canadian
Encoding iso8859-15
LangCode en_CA
End
Language canadien
GuiName "French (Canada)"
BabelName canadien
Encoding iso8859-15
LangCode fr_CA
End
Language catalan
GuiName "Catalan"
BabelName catalan
Encoding iso8859-15
LangCode ca_ES
End
Language chinese-simplified
GuiName "Chinese (simplified)"
Encoding euc-cn
LangCode zh_CN
End
Language chinese-traditional
GuiName "Chinese (traditional)"
Encoding utf8-cjk
LangCode zh_CN
End
Language croatian
GuiName "Croatian"
BabelName croatian
Encoding iso8859-2
LangCode hr_HR
End
Language czech
GuiName "Czech"
BabelName czech
Encoding iso8859-2
LangCode cs_CZ
End
Language danish
GuiName "Danish"
BabelName danish
Encoding iso8859-15
LangCode da_DK
End
Language dutch
GuiName "Dutch"
BabelName dutch
Encoding iso8859-15
LangCode nl_NL
End
Language english
GuiName "English"
BabelName english
Encoding iso8859-15
LangCode en_US
End
# Esperanto has no country code because it is an auxiliary language # Esperanto has no country code because it is an auxiliary language
esperanto esperanto "Esperanto" false iso8859-3 eo "" Language esperanto
estonian estonian "Estonian" false iso8859-15 et_EE "" GuiName "Esperanto"
# the definitions are only used due to bugs in the arabi-package - remove them if they become unnecessary! BabelName esperanto
farsi farsi "Farsi" true utf8 fa_IR "\DeclareTextSymbol{\guillemotright}{LFE}{62}\DeclareTextSymbol{\guillemotleft}{LFE}{60}" Encoding iso8859-3
finnish finnish "Finnish" false iso8859-15 fi_FI "" LangCode eo
End
Language estonian
GuiName "Estonian"
BabelName estonian
Encoding iso8859-15
LangCode et_EE
End
# the preamble definitions are only used due to bugs in the
# arabi-package -- remove them if they become unnecessary!
Language farsi
GuiName "Farsi"
BabelName farsi
Encoding utf8
RTL true
LangCode fa_IR
PostBabelPreamble
\DeclareTextSymbol{\guillemotright}{LFE}{62}
\DeclareTextSymbol{\guillemotleft}{LFE}{60}
EndPostBabelPreamble
End
Language finnish
GuiName "Finnish"
BabelName finnish
Encoding iso8859-15
LangCode fi_FI
End
# We redefine \og and \fg (guillemets) for older french language definitions # We redefine \og and \fg (guillemets) for older french language definitions
french french "French" false iso8859-15 fr_FR "\addto\extrasfrench{\providecommand{\og}{\leavevmode\flqq~}\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}}" Language french
galician galician "Galician" false iso8859-15 gl_ES "" GuiName "French"
german german "German (old spelling)" false iso8859-15 de-alt "" BabelName french
ngerman ngerman "German" false iso8859-15 de_DE "" Encoding iso8859-15
german-ch ngerman "German (Switzerland)" false iso8859-15 de_CH "" LangCode fr_FR
greek greek "Greek" false iso8859-7 el_GR "" PostBabelPreamble
polutonikogreek polutonikogreek "Greek (polytonic)" false iso8859-7 el_GR "" \addto\extrasfrench{%
hebrew hebrew "Hebrew" true cp1255 he_IL "" \providecommand{\og}{\leavevmode\flqq~}
\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}
}
EndPostBabelPreamble
End
Language galician
GuiName "Galician"
BabelName galician
Encoding iso8859-15
LangCode gl_ES
End
# german does not use a country code (due to the variety)
Language german
GuiName "German (old spelling)"
BabelName german
Encoding iso8859-15
LangCode de
LangVariety alt
End
Language ngerman
GuiName "German"
BabelName ngerman
Encoding iso8859-15
LangCode de_DE
End
Language german-ch
GuiName "German (Switzerland)"
BabelName ngerman
Encoding iso8859-15
LangCode de_CH
End
Language greek
GuiName "Greek"
BabelName greek
Encoding iso8859-7
InternalEncoding true
LangCode el_GR
End
Language polutonikogreek
GuiName "Greek (polytonic)"
BabelName polutonikogreek
Encoding iso8859-7
InternalEncoding true
LangCode el_GR
End
Language hebrew
GuiName "Hebrew"
BabelName hebrew
Encoding cp1255
InternalEncoding true
RTL true
LangCode he_IL
End
# "hungarian" is a synonym for the "magyar" babel language option # "hungarian" is a synonym for the "magyar" babel language option
# "hungarian" might be used for special purposes, see http://www.math.bme.hu/latex/magyar_pre_tug2004.pdf # "hungarian" might be used for special purposes,
#hungarian hungarian "Hungarian" false iso8859-2 hu_HU "" # see http://www.math.bme.hu/latex/magyar_pre_tug2004.pdf
icelandic icelandic "Icelandic" false iso8859-15 is_IS "" #Language hungarian
# GuiName "Hungarian"
# BabelName hungarian
# Encoding iso8859-2
## LangCode hu_HU
#End
Language icelandic
GuiName "Icelandic"
BabelName icelandic
Encoding iso8859-15
LangCode is_IS
End
# Interlingua has no country code because it is an auxiliary language # Interlingua has no country code because it is an auxiliary language
interlingua interlingua "Interlingua" false iso8859-15 ia "" Language interlingua
irish irish "Irish" false iso8859-15 ga_IE "" GuiName "Interlingua"
italian italian "Italian" false iso8859-15 it_IT "" BabelName interlingua
japanese japanese "Japanese" false jis-plain ja_JP "" Encoding iso8859-15
japanese-cjk "" "Japanese (CJK)" false euc-jp ja_JP "" LangCode ia
kazakh kazakh "Kazakh" false pt154 kk_KZ "" End
Language irish
GuiName "Irish"
BabelName irish
Encoding iso8859-15
LangCode ga_IE
End
Language italian
GuiName "Italian"
BabelName italian
Encoding iso8859-15
LangCode it_IT
End
Language japanese
GuiName "Japanese"
BabelName japanese
Encoding jis-plain
LangCode ja_JP
End
Language japanese-cjk
GuiName "Japanese (CJK)"
Encoding euc-jp
LangCode ja_JP
End
Language kazakh
GuiName "Kazakh"
BabelName kazakh
Encoding pt154
LangCode kk_KZ
End
# there is no country code for Korean because ko_KR is the same as ko_KI # there is no country code for Korean because ko_KR is the same as ko_KI
korean "" "Korean" false euc-kr ko "" Language korean
GuiName "Korean"
Encoding euc-kr
LangCode ko
End
# there is no country code for Latin because it is a dead language # there is no country code for Latin because it is a dead language
latin latin "Latin" false iso8859-15 la "" Language latin
latvian latvian "Latvian" false iso8859-4 lv_LV "" GuiName "Latin"
lithuanian lithuanian "Lithuanian" false iso8859-13 lt_LT "" BabelName latin
lowersorbian lowersorbian "Lower Sorbian" false iso8859-2 dsb_DE "" Encoding iso8859-15
magyar magyar "Hungarian" false iso8859-2 hu_HU "" LangCode la
mongolian mongolian "Mongolian" false utf8 mn_MN "" End
norsk norsk "Norsk" false iso8859-15 nb_NO ""
nynorsk nynorsk "Nynorsk" false iso8859-15 nn_NO "" Language latvian
polish polish "Polish" false iso8859-2 pl_PL "" GuiName "Latvian"
portuguese portuges "Portuguese" false iso8859-15 pt_PT "" BabelName latvian
romanian romanian "Romanian" false iso8859-2 ro_RO "" Encoding iso8859-4
russian russian "Russian" false koi8 ru_RU "" LangCode lv_LV
samin samin "North Sami" false iso8859-15 se_NO "" End
scottish scottish "Scottish" false iso8859-15 gd_GB ""
serbian serbian "Serbian" false iso8859-5 sr_RS "" Language lithuanian
serbian-latin serbian "Serbian (Latin)" false iso8859-2 sr_RS "" GuiName "Lithuanian"
slovak slovak "Slovak" false iso8859-2 sk_SK "" BabelName lithuanian
slovene slovene "Slovene" false iso8859-2 sl_SI "" Encoding iso8859-13
spanish spanish "Spanish" false iso8859-15 es_ES "\addto\shorthandsspanish{\spanishdeactivate{~<>}}" LangCode lt_LT
spanish-mexico spanish "Spanish (Mexico)" false iso8859-15 es_MX "\addto\shorthandsspanish{\spanishdeactivate{~<>.}}" End
swedish swedish "Swedish" false iso8859-15 sv_SE ""
thai thai "Thai" false tis620-0 th_TH "\usepackage{thswitch}" Language lowersorbian
turkish turkish "Turkish" false iso8859-9 tr_TR "" GuiName "Lower Sorbian"
turkmen turkmen "Turkmen" false utf8 tk_TM "" BabelName lowersorbian
ukrainian ukrainian "Ukrainian" false koi8-u uk_UA "" Encoding iso8859-2
uppersorbian uppersorbian "Upper Sorbian" false iso8859-2 hsb_DE "" LangCode dsb_DE
vietnamese vietnam "Vietnamese" false utf8 vi_VN "" End
welsh welsh "Welsh" false iso8859-15 cy_GB ""
Language magyar
GuiName "Hungarian"
BabelName magyar
Encoding iso8859-2
LangCode hu_HU
End
Language mongolian
GuiName "Mongolian"
BabelName mongolian
Encoding utf8
LangCode mn_MN
End
Language norsk
GuiName "Norsk"
BabelName norsk
Encoding iso8859-15
LangCode nb_NO
End
Language nynorsk
GuiName "Nynorsk"
BabelName nynorsk
Encoding iso8859-15
LangCode nn_NO
End
Language polish
GuiName "Polish"
BabelName polish
Encoding iso8859-2
LangCode pl_PL
End
Language portuguese
GuiName "Portuguese"
BabelName portuges
Encoding iso8859-15
LangCode pt_PT
End
Language romanian
GuiName "Romanian"
BabelName romanian
Encoding iso8859-2
LangCode ro_RO
End
Language russian
GuiName "Russian"
BabelName russian
Encoding koi8
LangCode ru_RU
End
Language samin
GuiName "North Sami"
BabelName samin
Encoding iso8859-15
LangCode se_NO
End
Language scottish
GuiName "Scottish"
BabelName scottish
Encoding iso8859-15
LangCode gd_GB
End
Language serbian
GuiName "Serbian"
BabelName serbian
Encoding iso8859-5
LangCode sr_RS
End
Language serbian-latin
GuiName "Serbian (Latin)"
BabelName serbian
Encoding iso8859-2
LangCode sr_RS
End
Language slovak
GuiName "Slovak"
BabelName slovak
Encoding iso8859-2
LangCode sk_SK
End
Language slovene
GuiName "Slovene"
BabelName slovene
Encoding iso8859-2
LangCode sl_SI
End
Language spanish
GuiName "Spanish"
BabelName spanish
Encoding iso8859-15
LangCode es_ES
PostBabelPreamble
\addto\shorthandsspanish{\spanishdeactivate{~<>}}
EndPostBabelPreamble
End
Language spanish-mexico
GuiName "Spanish (Mexico)"
BabelName spanish
Encoding iso8859-15
LangCode es_MX
PostBabelPreamble
\addto\shorthandsspanish{\spanishdeactivate{~<>.}}
EndPostBabelPreamble
End
Language swedish
GuiName "Swedish"
BabelName swedish
Encoding iso8859-15
LangCode sv_SE
End
Language thai
GuiName "Thai"
BabelName thai
Encoding tis620-0
LangCode th_TH
PostBabelPreamble
\usepackage{thswitch}
EndPostBabelPreamble
End
Language turkish
GuiName "Turkish"
BabelName turkish
Encoding iso8859-9
LangCode tr_TR
End
Language turkmen
GuiName "Turkmen"
BabelName turkmen
Encoding utf8
LangCode tk_TM
End
Language ukrainian
GuiName "Ukrainian"
BabelName ukrainian
Encoding koi8-u
LangCode uk_UA
End
Language uppersorbian
GuiName "Upper Sorbian"
BabelName uppersorbian
Encoding iso8859-2
LangCode hsb_DE
End
Language vietnamese
GuiName "Vietnamese"
BabelName vietnam
Encoding utf8
LangCode vi_VN
End
Language welsh
GuiName "Welsh"
BabelName welsh
Encoding iso8859-15
LangCode cy_GB
End

View File

@ -230,30 +230,23 @@ def qt4_l10n(input_files, output, base):
def languages_l10n(input_files, output, base): def languages_l10n(input_files, output, base):
'''Generate pot file from lib/language''' '''Generate pot file from lib/languages'''
output = open(output, 'w') out = open(output, 'w')
# assuming only one language file GuiName = re.compile(r'^[^#]*GuiName\s+(.*)')
reg = re.compile('[\w-]+\s+[\w"]+\s+"([\w \-\(\),]+)"\s+(true|false)\s+[\w-]+\s+[\w\-]+\s+"[^"]*"')
input = open(input_files[0]) for src in input_files:
for lineno, line in enumerate(input.readlines()): descStartLine = -1
if line[0] == '#': descLines = []
lineno = 0
for line in open(src).readlines():
lineno += 1
res = GuiName.search(line)
if res != None:
string = res.group(1)
writeString(out, src, base, lineno, string)
continue continue
# From:
# afrikaans afrikaans "Afrikaans" false iso8859-15 af_ZA "" out.close()
# To:
# #: lib/languages:2
# msgid "Afrikaans"
# msgstr ""
if reg.match(line):
print >> output, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
(relativePath(input_files[0], base), lineno+1, reg.match(line).groups()[0])
else:
print "Error: Unable to handle line:"
print line
# No need to abort if the parsing fails (e.g. "ignore" language has no encoding)
# sys.exit(1)
input.close()
output.close()
def external_l10n(input_files, output, base): def external_l10n(input_files, output, base):

View File

@ -1744,7 +1744,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|| features.isRequired("japanese") ) ) { || features.isRequired("japanese") ) ) {
// FIXME UNICODE // FIXME UNICODE
lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n'; lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
lyxpreamble += from_utf8(features.getBabelOptions()) + '\n'; lyxpreamble += from_utf8(features.getBabelPostsettings()) + '\n';
} }
// The optional packages; // The optional packages;
@ -1887,7 +1887,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
&& !features.isRequired("japanese")) { && !features.isRequired("japanese")) {
// FIXME UNICODE // FIXME UNICODE
lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n'; lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
lyxpreamble += from_utf8(features.getBabelOptions()) + '\n'; lyxpreamble += from_utf8(features.getBabelPostsettings()) + '\n';
} }
docstring const i18npreamble = features.getTClassI18nPreamble(use_babel); docstring const i18npreamble = features.getTClassI18nPreamble(use_babel);

View File

@ -947,17 +947,17 @@ docstring const LaTeXFeatures::getMacros() const
} }
string const LaTeXFeatures::getBabelOptions() const string const LaTeXFeatures::getBabelPostsettings() const
{ {
ostringstream tmp; ostringstream tmp;
LanguageList::const_iterator it = UsedLanguages_.begin(); LanguageList::const_iterator it = UsedLanguages_.begin();
LanguageList::const_iterator end = UsedLanguages_.end(); LanguageList::const_iterator end = UsedLanguages_.end();
for (; it != end; ++it) for (; it != end; ++it)
if (!(*it)->latex_options().empty()) if (!(*it)->babel_postsettings().empty())
tmp << (*it)->latex_options() << '\n'; tmp << (*it)->babel_postsettings() << '\n';
if (!params_.language->latex_options().empty()) if (!params_.language->babel_postsettings().empty())
tmp << params_.language->latex_options() << '\n'; tmp << params_.language->babel_postsettings() << '\n';
return tmp.str(); return tmp.str();
} }

View File

@ -53,7 +53,7 @@ public:
/// The macros definitions needed by the document /// The macros definitions needed by the document
docstring const getMacros() const; docstring const getMacros() const;
/// ///
std::string const getBabelOptions() const; std::string const getBabelPostsettings() const;
/// The definitions needed by the document's textclass /// The definitions needed by the document's textclass
docstring const getTClassPreamble() const; docstring const getTClassPreamble() const;
/// The language dependent definitions needed by the document's textclass /// The language dependent definitions needed by the document's textclass

View File

@ -37,20 +37,105 @@ Language const * latex_language = &latex_lang;
Language const * reset_language = 0; Language const * reset_language = 0;
bool Language::readLanguage(Lexer & lex)
{
enum LanguageTags {
LA_BABELNAME = 1,
LA_ENCODING,
LA_END,
LA_GUINAME,
LA_INTERNAL_ENC,
LA_LANG_CODE,
LA_LANG_VARIETY,
LA_POSTBABELPREAMBLE,
LA_RTL
};
// Keep these sorted alphabetically!
LexerKeyword languageTags[] = {
{ "babelname", LA_BABELNAME },
{ "encoding", LA_ENCODING },
{ "end", LA_END },
{ "guiname", LA_GUINAME },
{ "internalencoding", LA_INTERNAL_ENC },
{ "langcode", LA_LANG_CODE },
{ "langvariety", LA_LANG_VARIETY },
{ "postbabelpreamble", LA_POSTBABELPREAMBLE },
{ "rtl", LA_RTL }
};
bool error = false;
bool finished = false;
lex.pushTable(languageTags);
// parse style section
while (!finished && lex.isOK() && !error) {
int le = lex.lex();
// See comment in LyXRC.cpp.
switch (le) {
case Lexer::LEX_FEOF:
continue;
case Lexer::LEX_UNDEF: // parse error
lex.printError("Unknown language tag `$$Token'");
error = true;
continue;
default:
break;
}
switch (static_cast<LanguageTags>(le)) {
case LA_END: // end of structure
finished = true;
break;
case LA_BABELNAME:
lex >> babel_;
break;
case LA_ENCODING:
lex >> encodingStr_;
break;
case LA_GUINAME:
lex >> display_;
break;
case LA_INTERNAL_ENC:
lex >> internal_enc_;
break;
case LA_LANG_CODE:
lex >> code_;
break;
case LA_LANG_VARIETY:
lex >> variety_;
break;
case LA_POSTBABELPREAMBLE:
babel_postsettings_ =
lex.getLongString("EndPostBabelPreamble");
break;
case LA_RTL:
lex >> rightToLeft_;
break;
}
}
lex.popTable();
return finished && !error;
}
bool Language::read(Lexer & lex) bool Language::read(Lexer & lex)
{ {
encoding_ = 0; encoding_ = 0;
lex >> lang_; internal_enc_ = 0;
lex >> babel_; rightToLeft_ = 0;
lex >> display_;
lex >> rightToLeft_;
lex >> encodingStr_;
lex >> codeStr_;
lex >> latex_options_;
if (!lex)
return false;
variety_ = split(codeStr_, code_, '-'); if (!lex.next()) {
lex.printError("No name given for language: `$$Token'.");
return false;
}
lang_ = lex.getString();
LYXERR(Debug::INFO, "Reading language " << lang_);
if (!readLanguage(lex)) {
LYXERR0("Error parsing language `" << lang_ << '\'');
return false;
}
encoding_ = encodings.fromLyXName(encodingStr_); encoding_ = encodings.fromLyXName(encodingStr_);
if (!encoding_ && !encodingStr_.empty()) { if (!encoding_ && !encodingStr_.empty()) {
@ -60,28 +145,28 @@ bool Language::read(Lexer & lex)
return true; return true;
} }
bool Language::internalFontEncoding() const
{
// FIXME: list incomplete
// FIXME: instead of hardcoding, this
// should go to the languages file
return lang_ == "hebrew"
|| lang_ == "greek"
|| lang_ == "polutonikogreek";
}
void Languages::read(FileName const & filename) void Languages::read(FileName const & filename)
{ {
Lexer lex; Lexer lex;
lex.setFile(filename); lex.setFile(filename);
lex.setContext("Languages::read"); lex.setContext("Languages::read");
while (1) { while (lex.isOK()) {
int le = lex.lex();
switch (le) {
case Lexer::LEX_FEOF:
continue;
default:
break;
}
if (lex.getString() != "Language") {
lex.printError("Unknown Language tag `$$Token'");
continue;
}
Language l; Language l;
l.read(lex); l.read(lex);
if (!lex) if (!lex)
break; break;
LYXERR(Debug::INFO, "Reading language " << l.lang());
if (l.lang() == "latex") if (l.lang() == "latex")
latex_lang = l; latex_lang = l;
else if (l.lang() == "ignore") else if (l.lang() == "ignore")

View File

@ -52,11 +52,13 @@ public:
/// set variety (needed for rc.spellchecker_alt_lang) /// set variety (needed for rc.spellchecker_alt_lang)
void setVariety(std::string const v) { variety_ = v; } void setVariety(std::string const v) { variety_ = v; }
/// ///
std::string const & latex_options() const { return latex_options_; } std::string const & babel_postsettings() const { return babel_postsettings_; }
/// ///
bool internalFontEncoding() const; bool internalFontEncoding() const { return internal_enc_; }
/// ///
bool read(Lexer & lex); bool read(Lexer & lex);
///
bool readLanguage(Lexer & lex);
// for the use in std::map // for the use in std::map
friend bool operator<(Language const & p, Language const & q); friend bool operator<(Language const & p, Language const & q);
private: private:
@ -73,13 +75,13 @@ private:
/// ///
Encoding const * encoding_; Encoding const * encoding_;
/// ///
std::string codeStr_;
///
std::string code_; std::string code_;
/// ///
std::string variety_; std::string variety_;
/// ///
std::string latex_options_; std::string babel_postsettings_;
///
bool internal_enc_;
}; };