Introduce PolyglossiaName and PolyglossiaOpts.

Not yet functional.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36312 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-11-16 11:07:43 +00:00
parent f7ff9abf99
commit 1aa5a0d1f1
3 changed files with 537 additions and 313 deletions

View File

@ -1,4 +1,4 @@
########################################################################
##########################################################################
#
# Languages supported by LyX.
#
@ -7,6 +7,8 @@
# Language <lyxname>
# GuiName "<Gui Name>"
# BabelName <babelname>
# PolyglossiaName <polyglossianame>
# PolyglossiaOpts "<language-specific options>"
# Encoding <encoding>
# InternalEncoding <true|false>
# RTL <true|false>
@ -21,10 +23,35 @@
# EndPostBabelPreamble
# End
#
# Omitted elements will be treated as empty
# (omitted AsBabelOptions, RTL and InternalEncoding as "false")
#
########################################################################
# NOTE:
#
# * Omitted elements will be treated as empty (if string) or "false"
# (if boolean).
# * Encoding is not relevant for XeTeX (which is utf8 always), and if
# Document > Settings > Language > Encoding is not set to "Language
# Default"
# * InternalEncoding is used to tell LyX that babel internally sets a font
# encoding (such as hebrew to LHE). See bug #5091.
# * AsBabelOptions advices LyX to pass the languages locally to babel, not
# globally to the class. Some languages (basically those not directly
# supported by babel) need this.
# FIXME: in this case, we might still need to pass the other languages
# globally, for the use of other packages (such as varioref).
# * LangCode is also used for spellchecking and thesaurus, where the
# dictionaries are named accordingly. Thus, check this when intoducing/
# changing language codes (especially aspell, thesaurus).
# TODO: maybe use Best Current Practice (BCP 47) codes for LangCode
# http://www.rfc-editor.org/rfc/bcp/bcp47.txt
# http://www.w3.org/International/articles/language-tags/
# http://www.iana.org/assignments/language-subtag-registry
# * LangVariety is used by the aspell spellchecker to differentiate
# dictionaries for different varieties of a given language (e.g. German
# pre-1998 and post-1998 spelling). The aspell dictionaries are named
# language[_REGION][-variety].multi, e.g. de-alt.multi for "German (old
# spelling)" (see http://aspell.net/man-html/Dictionary-Naming.html)
#
##########################################################################
#
# LyX-internal languages
@ -33,6 +60,7 @@
Language ignore
GuiName "Ignore"
BabelName ignore
PolyglossiaName ignore
Encoding iso8859-1
LangCode ignore
End
@ -57,6 +85,7 @@ End
Language albanian
GuiName "Albanian"
BabelName albanian
PolyglossiaName albanian
Encoding iso8859-2
LangCode sq_AL
End
@ -64,10 +93,20 @@ End
Language american
GuiName "English (USA)"
BabelName american
PolyglossiaName english
PolyglossiaOpts "variant=american"
Encoding iso8859-15
LangCode en_US
End
# Currently not supported (file format change!)
# Language ancientgreek
# GuiName "Greek (ancient)"
# PolyglossiaName greek
# PolyglossiaOpts variant=ancient
# LangCode grc
# End
# FIXME: dummy babel language for arabic_arabtex to be able
# to switch the language the way of the ArabTeX-package
Language arabic_arabtex
@ -78,9 +117,11 @@ Language arabic_arabtex
LangCode ar_SA
End
# polyglossia uses "Arabic" for the lang environment
Language arabic_arabi
GuiName "Arabic (Arabi)"
BabelName arabic
PolyglossiaName arabic
Encoding cp1256
RTL true
LangCode ar_SA
@ -88,6 +129,7 @@ End
Language armenian
GuiName "Armenian"
PolyglossiaName armenian
Encoding armscii8
LangCode hy_AM
End
@ -109,6 +151,7 @@ End
Language bahasa
GuiName "Indonesian"
BabelName bahasa
PolyglossiaName bahasai
Encoding iso8859-15
LangCode id_ID
End
@ -116,6 +159,7 @@ End
Language bahasam
GuiName "Malay"
BabelName bahasam
PolyglossiaName bahasam
Encoding iso8859-15
LangCode ms_MY
End
@ -123,6 +167,7 @@ End
Language basque
GuiName "Basque"
BabelName basque
PolyglossiaName basque
Encoding iso8859-15
LangCode eu_ES
End
@ -137,6 +182,7 @@ End
Language brazilian
GuiName "Portuguese (Brazil)"
BabelName brazil
PolyglossiaName brazil
Encoding iso8859-15
LangCode pt_BR
End
@ -144,6 +190,7 @@ End
Language breton
GuiName "Breton"
BabelName breton
PolyglossiaName breton
Encoding iso8859-15
LangCode br_FR
End
@ -151,6 +198,8 @@ End
Language british
GuiName "English (UK)"
BabelName british
PolyglossiaName english
PolyglossiaOpts "variant=british"
Encoding iso8859-15
LangCode en_GB
End
@ -158,20 +207,27 @@ End
Language bulgarian
GuiName "Bulgarian"
BabelName bulgarian
PolyglossiaName bulgarian
Encoding cp1251
LangCode bg_BG
End
# not yet supported by polyglossia
Language canadian
GuiName "English (Canada)"
BabelName canadian
# PolyglossiaName english
# PolyglossiaOpts "variant=canadian"
Encoding iso8859-15
LangCode en_CA
End
# not yet supported by polyglossia
Language canadien
GuiName "French (Canada)"
BabelName canadien
# PolyglossiaName french
# PolyglossiaOpts "variant=canadien"
Encoding iso8859-15
LangCode fr_CA
End
@ -179,25 +235,37 @@ End
Language catalan
GuiName "Catalan"
BabelName catalan
PolyglossiaName catalan
PolyglossiaOpts "babelshorthands=true"
Encoding iso8859-15
LangCode ca_ES
End
# uses CJK package
Language chinese-simplified
GuiName "Chinese (simplified)"
Encoding euc-cn
LangCode zh_CN
End
# uses CJK package
Language chinese-traditional
GuiName "Chinese (traditional)"
Encoding utf8-cjk
LangCode zh_CN
End
# Currently not supported (file format change!)
# Language coptic
# GuiName "Coptic"
# PolyglossiaName coptic
# LangCode cop
# End
Language croatian
GuiName "Croatian"
BabelName croatian
PolyglossiaName croatian
Encoding iso8859-2
LangCode hr_HR
End
@ -205,6 +273,7 @@ End
Language czech
GuiName "Czech"
BabelName czech
PolyglossiaName czech
Encoding iso8859-2
LangCode cs_CZ
End
@ -212,13 +281,23 @@ End
Language danish
GuiName "Danish"
BabelName danish
PolyglossiaName danish
Encoding iso8859-15
LangCode da_DK
End
# Currently not supported (file format change!)
# Language divehi
# GuiName "Divehi (Maldivian)"
# PolyglossiaName divehi
# LangCode dv
# End
Language dutch
GuiName "Dutch"
BabelName dutch
PolyglossiaName dutch
PolyglossiaOpts "babelshorthands=true"
Encoding iso8859-15
LangCode nl_NL
End
@ -226,6 +305,7 @@ End
Language english
GuiName "English"
BabelName english
PolyglossiaName english
Encoding iso8859-15
LangCode en_US
End
@ -234,6 +314,7 @@ End
Language esperanto
GuiName "Esperanto"
BabelName esperanto
PolyglossiaName esperanto
Encoding iso8859-3
LangCode eo
End
@ -241,6 +322,7 @@ End
Language estonian
GuiName "Estonian"
BabelName estonian
PolyglossiaName estonian
Encoding iso8859-15
LangCode et_EE
End
@ -250,6 +332,7 @@ End
Language farsi
GuiName "Farsi"
BabelName farsi
PolyglossiaName farsi
Encoding utf8
RTL true
LangCode fa_IR
@ -262,6 +345,7 @@ End
Language finnish
GuiName "Finnish"
BabelName finnish
PolyglossiaName finnish
Encoding iso8859-15
LangCode fi_FI
End
@ -270,6 +354,7 @@ End
Language french
GuiName "French"
BabelName french
PolyglossiaName french
Encoding iso8859-15
LangCode fr_FR
PostBabelPreamble
@ -283,6 +368,7 @@ End
Language galician
GuiName "Galician"
BabelName galician
PolyglossiaName galician
Encoding iso8859-15
LangCode gl_ES
End
@ -291,6 +377,8 @@ End
Language german
GuiName "German (old spelling)"
BabelName german
PolyglossiaName german
PolyglossiaOpts "spelling=old,babelshorthands=true"
Encoding iso8859-15
LangCode de
LangVariety alt
@ -299,13 +387,19 @@ End
Language ngerman
GuiName "German"
BabelName ngerman
PolyglossiaName german
PolyglossiaOpts "babelshorthands=true"
Encoding iso8859-15
LangCode de_DE
End
# Swiss German is not supported by babel and polyglossia yet
# We use ngerman for now (spellchecking is supported though!)
Language german-ch
GuiName "German (Switzerland)"
BabelName ngerman
PolyglossiaName german
PolyglossiaOpts "babelshorthands=true"
Encoding iso8859-15
LangCode de_CH
End
@ -313,6 +407,7 @@ End
Language greek
GuiName "Greek"
BabelName greek
PolyglossiaName greek
Encoding iso8859-7
InternalEncoding true
LangCode el_GR
@ -321,6 +416,8 @@ End
Language polutonikogreek
GuiName "Greek (polytonic)"
BabelName polutonikogreek
PolyglossiaName greek
PolyglossiaOpts "variant=polytonic"
Encoding iso8859-7
InternalEncoding true
LangCode el_GR
@ -329,12 +426,21 @@ End
Language hebrew
GuiName "Hebrew"
BabelName hebrew
PolyglossiaName hebrew
Encoding cp1255
InternalEncoding true
RTL true
LangCode he_IL
End
# Currently not supported (file format change!)
# Language hindi
# GuiName "Hindi"
# PolyglossiaName hindi
# LangCode hi
# End
# Currently not supported (file format change!)
# "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
@ -342,12 +448,13 @@ End
# GuiName "Hungarian"
# BabelName hungarian
# Encoding iso8859-2
## LangCode hu_HU
# LangCode hu_HU
#End
Language icelandic
GuiName "Icelandic"
BabelName icelandic
PolyglossiaName icelandic
Encoding iso8859-15
LangCode is_IS
End
@ -356,6 +463,7 @@ End
Language interlingua
GuiName "Interlingua"
BabelName interlingua
PolyglossiaName interlingua
Encoding iso8859-15
LangCode ia
End
@ -363,6 +471,7 @@ End
Language irish
GuiName "Irish"
BabelName irish
PolyglossiaName irish
Encoding iso8859-15
LangCode ga_IE
End
@ -370,6 +479,7 @@ End
Language italian
GuiName "Italian"
BabelName italian
PolyglossiaName italian
Encoding iso8859-15
LangCode it_IT
End
@ -385,6 +495,7 @@ Language japanese
AsBabelOptions true
End
# uses CJK package
Language japanese-cjk
GuiName "Japanese (CJK)"
Encoding euc-jp
@ -405,10 +516,18 @@ Language korean
LangCode ko
End
# Currently not supported (file format change!)
# Language lao
# GuiName "Lao"
# PolyglossiaName lao
# LangCode lo
# End
# there is no country code for Latin because it is a dead language
Language latin
GuiName "Latin"
BabelName latin
PolyglossiaName latin
Encoding iso8859-15
LangCode la
End
@ -418,6 +537,7 @@ End
Language latvian
GuiName "Latvian"
BabelName latvian
PolyglossiaName latvian
Encoding iso8859-4
LangCode lv_LV
AsBabelOptions true
@ -428,6 +548,7 @@ End
Language lithuanian
GuiName "Lithuanian"
BabelName lithuanian
PolyglossiaName lithuanian
Encoding iso8859-13
LangCode lt_LT
AsBabelOptions true
@ -436,6 +557,7 @@ End
Language lowersorbian
GuiName "Lower Sorbian"
BabelName lowersorbian
PolyglossiaName lsorbian
Encoding iso8859-2
LangCode dsb_DE
End
@ -443,10 +565,18 @@ End
Language magyar
GuiName "Hungarian"
BabelName magyar
PolyglossiaName magyar
Encoding iso8859-2
LangCode hu_HU
End
# Currently not supported (file format change!)
# Language marathi
# GuiName "Marathi"
# PolyglossiaName marathi
# LangCode mr
# End
# mongolian must be loaded locally with babel options,
# not globally via class options
Language mongolian
@ -460,6 +590,7 @@ End
Language norsk
GuiName "Norsk"
BabelName norsk
PolyglossiaName norsk
Encoding iso8859-15
LangCode nb_NO
End
@ -467,13 +598,32 @@ End
Language nynorsk
GuiName "Nynorsk"
BabelName nynorsk
PolyglossiaName nynorsk
Encoding iso8859-15
LangCode nn_NO
End
# Currently not supported (file format change!)
# Language occitan
# GuiName "Occitan"
# PolyglossiaName occitan
# LangCode oc
# End
# Currently not supported (file format change!)
# Russian orthography from the Petrine orthographic reforms of
# 1708 to the 1917 orthographic reform
# Language oldrussian
# GuiName "Russian (Petrine orthography)"
# PolyglossiaName russian
# PolyglossiaOpts spelling=old
# LangCode ru_petr1708
# End
Language polish
GuiName "Polish"
BabelName polish
PolyglossiaName polish
Encoding iso8859-2
LangCode pl_PL
End
@ -481,6 +631,7 @@ End
Language portuguese
GuiName "Portuguese"
BabelName portuges
PolyglossiaName portuges
Encoding iso8859-15
LangCode pt_PT
End
@ -488,6 +639,7 @@ End
Language romanian
GuiName "Romanian"
BabelName romanian
PolyglossiaName romanian
Encoding iso8859-2
LangCode ro_RO
End
@ -495,6 +647,7 @@ End
Language russian
GuiName "Russian"
BabelName russian
PolyglossiaName russian
Encoding koi8
LangCode ru_RU
End
@ -502,13 +655,22 @@ End
Language samin
GuiName "North Sami"
BabelName samin
PolyglossiaName samin
Encoding iso8859-15
LangCode se_NO
End
# Currently not supported (file format change!)
# Language sanskrit
# GuiName "Sanskrit"
# PolyglossiaName sanskrit
# LangCode sa
# End
Language scottish
GuiName "Scottish"
BabelName scottish
PolyglossiaName scottish
Encoding iso8859-15
LangCode gd_GB
End
@ -516,6 +678,7 @@ End
Language serbian
GuiName "Serbian"
BabelName serbian
PolyglossiaName serbian
Encoding iso8859-5
LangCode sr_RS
End
@ -523,6 +686,8 @@ End
Language serbian-latin
GuiName "Serbian (Latin)"
BabelName serbian
PolyglossiaName serbian
PolyglossiaOpts "script=latin"
Encoding iso8859-2
LangCode sr_RS
End
@ -530,6 +695,7 @@ End
Language slovak
GuiName "Slovak"
BabelName slovak
PolyglossiaName slovak
Encoding iso8859-2
LangCode sk_SK
End
@ -537,6 +703,7 @@ End
Language slovene
GuiName "Slovene"
BabelName slovene
PolyglossiaName slovenian
Encoding iso8859-2
LangCode sl_SI
End
@ -544,6 +711,7 @@ End
Language spanish
GuiName "Spanish"
BabelName spanish
PolyglossiaName spanish
Encoding iso8859-15
LangCode es_ES
PostBabelPreamble
@ -551,9 +719,11 @@ Language spanish
EndPostBabelPreamble
End
# there are no spanish shorthands in polyglossia
Language spanish-mexico
GuiName "Spanish (Mexico)"
BabelName spanish
PolyglossiaName spanish
Encoding iso8859-15
LangCode es_MX
PostBabelPreamble
@ -564,13 +734,36 @@ End
Language swedish
GuiName "Swedish"
BabelName swedish
PolyglossiaName swedish
Encoding iso8859-15
LangCode sv_SE
End
# Currently not supported (file format change!)
# Language syriac
# GuiName "Syriac"
# PolyglossiaName syriac
# LangCode syr
# End
# Currently not supported (file format change!)
# Language tamil
# GuiName "Tamil"
# PolyglossiaName tamil
# LangCode Taml
# End
# Currently not supported (file format change!)
# Language telugu
# GuiName "Telugu"
# PolyglossiaName telugu
# LangCode te
# End
Language thai
GuiName "Thai"
BabelName thai
PolyglossiaName thai
Encoding tis620-0
LangCode th_TH
PostBabelPreamble
@ -581,6 +774,7 @@ End
Language turkish
GuiName "Turkish"
BabelName turkish
PolyglossiaName turkish
Encoding iso8859-9
LangCode tr_TR
End
@ -590,6 +784,7 @@ End
Language turkmen
GuiName "Turkmen"
BabelName turkmen
PolyglossiaName turkmen
Encoding utf8
LangCode tk_TM
AsBabelOptions true
@ -598,6 +793,7 @@ End
Language ukrainian
GuiName "Ukrainian"
BabelName ukrainian
PolyglossiaName ukrainian
Encoding koi8-u
LangCode uk_UA
End
@ -605,16 +801,25 @@ End
Language uppersorbian
GuiName "Upper Sorbian"
BabelName uppersorbian
PolyglossiaName usorbian
Encoding iso8859-2
LangCode hsb_DE
End
# Currently not supported (file format change!)
# Language urdu
# GuiName "Urdu"
# PolyglossiaName urdu
# LangCode ur
# End
# vietnam must be loaded locally with babel options,
# not globally via class options, see
# http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
Language vietnamese
GuiName "Vietnamese"
BabelName vietnam
PolyglossiaName vietnamese
Encoding utf8
LangCode vi_VN
AsBabelOptions true
@ -623,6 +828,7 @@ End
Language welsh
GuiName "Welsh"
BabelName welsh
PolyglossiaName welsh
Encoding iso8859-15
LangCode cy_GB
End

View File

@ -49,6 +49,8 @@ bool Language::readLanguage(Lexer & lex)
LA_INTERNAL_ENC,
LA_LANG_CODE,
LA_LANG_VARIETY,
LA_POLYGLOSSIANAME,
LA_POLYGLOSSIAOPTS,
LA_POSTBABELPREAMBLE,
LA_PREBABELPREAMBLE,
LA_RTL
@ -64,6 +66,8 @@ bool Language::readLanguage(Lexer & lex)
{ "internalencoding", LA_INTERNAL_ENC },
{ "langcode", LA_LANG_CODE },
{ "langvariety", LA_LANG_VARIETY },
{ "polyglossianame", LA_POLYGLOSSIANAME },
{ "polyglossiaopts", LA_POLYGLOSSIAOPTS },
{ "postbabelpreamble", LA_POSTBABELPREAMBLE },
{ "prebabelpreamble", LA_PREBABELPREAMBLE },
{ "rtl", LA_RTL }
@ -98,6 +102,12 @@ bool Language::readLanguage(Lexer & lex)
case LA_BABELNAME:
lex >> babel_;
break;
case LA_POLYGLOSSIANAME:
lex >> polyglossia_name_;
break;
case LA_POLYGLOSSIAOPTS:
lex >> polyglossia_opts_;
break;
case LA_ENCODING:
lex >> encodingStr_;
break;

View File

@ -31,29 +31,33 @@ class Language {
public:
///
Language() : rightToLeft_(false) {}
///
/// LyX language name
std::string const & lang() const { return lang_; }
///
/// Babel language name
std::string const & babel() const { return babel_; }
///
/// polyglossia language name
std::string const & polyglossia() const { return polyglossia_name_; }
/// polyglossia language options
std::string const & polyglossiaOpts() const { return polyglossia_opts_; }
/// translatable GUI name
std::string const & display() const { return display_; }
///
/// is this a RTL language?
bool rightToLeft() const { return rightToLeft_; }
///
/// default encoding
Encoding const * encoding() const { return encoding_; }
///
std::string const & encodingStr() const { return encodingStr_; }
///
/// language code
std::string const & code() const { return code_; }
/// set code (needed for rc.spellchecker_alt_lang)
void setCode(std::string const c) { code_ = c; }
///
/// language variety (needed by aspell checker)
std::string const & variety() const { return variety_; }
/// set variety (needed for rc.spellchecker_alt_lang)
void setVariety(std::string const v) { variety_ = v; }
///
/// preamble settings after babel was called
std::string const & babel_postsettings() const { return babel_postsettings_; }
///
/// preamble settings before babel is called
std::string const & babel_presettings() const { return babel_presettings_; }
/// This language internally sets a font encoding
bool internalFontEncoding() const { return internal_enc_; }
@ -71,6 +75,10 @@ private:
///
std::string babel_;
///
std::string polyglossia_name_;
///
std::string polyglossia_opts_;
///
std::string display_;
///
bool rightToLeft_;