Jürgen Spitzmüller wrote:
> I'll post a polished patch later, where I resolved the remaining issues.

Here it comes. Includes some harmonization of tag spelling and the necessary 
lyx_pot.py changes.

Jürgen
Index: lib/languages
===================================================================
--- lib/languages	(Revision 36280)
+++ lib/languages	(Arbeitskopie)
@@ -1,89 +1,677 @@
-# name      babel name	GUI name	RTL?   encoding	  code	latex options
-# LyX internal languages
-ignore      ignore	"Ignore"	false  iso8859-1  ignore	 ""
-latex       ""		"LaTeX"		false  iso8859-1  latex	 ""
-# Real languages now
-afrikaans   afrikaans	"Afrikaans"	false  iso8859-15 af_ZA	 ""
-albanian    albanian	"Albanian"	false  iso8859-2  sq_AL	 ""
-american    american	"English (USA)"	false  iso8859-15 en_US	 ""
-# FIXME: dummy babel language for arabic_arabtex to be able to switch the language the way of the ArabTeX-package
-arabic_arabtex arabtex	"Arabic (ArabTeX)" true  cp1256   ar_SA	 ""
-arabic_arabi arabic	"Arabic (Arabi)"   true  cp1256   ar_SA	 ""
-armenian    ""		"Armenian"	false  armscii8   hy_AM	 ""
-austrian    austrian	"German (Austria, old spelling)"	false  iso8859-15 de_AT	 ""
-naustrian   naustrian	"German (Austria)"	false  iso8859-15  de_AT	 ""
-bahasa      bahasa	"Indonesian"	false  iso8859-15 id_ID	 ""
-bahasam     bahasam	"Malay"		false  iso8859-15 ms_MY	 ""
-basque      basque	"Basque"	false  iso8859-15 eu_ES	 ""
-belarusian  belarusian	"Belarusian"	false  cp1251     be_BY	 ""
-brazilian   brazil	"Portuguese (Brazil)"	false  iso8859-15  pt_BR	 ""
-breton      breton	"Breton"	false  iso8859-15 br_FR	 ""
-british     british	"English (UK)"	false  iso8859-15 en_GB	 ""
-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	 ""
-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	 ""
-danish      danish	"Danish"	false  iso8859-15 da_DK	 ""
-dutch       dutch	"Dutch"		false  iso8859-15 nl_NL	 ""
-english     english	"English"	false  iso8859-15 en_US	 ""
+########################################################################
+#
+# Languages supported by LyX.
+#
+# Syntax:
+#
+# Language <lyxname>
+#	GuiName          "<Gui Name>"
+#	BabelName         <babelname>
+#	Encoding          <encoding>
+#	InternalEncoding  <true|false>
+#	RTL               <true|false>
+#	LangCode          <language_code>
+#       LangVariety       <language_variety>
+#	BabelPreamble
+#         <extra latex code for babel>
+#	EndBabelPreamble
+# End
+#
+# Omitted elements will be treated as empty
+# (omitted RTL and InternalEncoding as "false")
+#
+########################################################################
+
+#
+# LyX-internal languages
+#
+
+Language ignore
+	GuiName         "Ignore"
+	BabelName       ignore
+	Encoding        iso8859-1
+	RTL             false
+	LangCode        ignore
+End
+
+Language latex
+	GuiName         "LaTeX"
+	Encoding        iso8859-1
+	RTL             false
+	LangCode        latex
+End
+
+#
+# Real languages
+#
+
+Language afrikaans
+	GuiName         "Afrikaans"
+	BabelName       afrikaans
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        af_ZA
+End
+
+Language albanian
+	GuiName         "Albanian"
+	BabelName       albanian
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        sq_AL
+End
+
+Language american
+	GuiName         "English (USA)"
+	BabelName       american
+	Encoding        iso8859-15
+	RTL             false
+	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
+	RTL             false
+	LangCode        hy_AM
+End
+
+Language austrian
+	GuiName         "German (Austria, old spelling)"
+	BabelName       austrian
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        de_AT
+End
+
+Language naustrian
+	GuiName         "German (Austria)"
+	BabelName       naustrian
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        de_AT
+End
+
+Language bahasa
+	GuiName         "Indonesian"
+	BabelName       bahasa
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        id_ID
+End
+
+Language bahasam
+	GuiName         "Malay"
+	BabelName       bahasam
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        ms_MY
+End
+
+Language basque
+	GuiName         "Basque"
+	BabelName       basque
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        eu_ES
+End
+
+Language belarusian
+	GuiName         "Belarusian"
+	BabelName       belarusian
+	Encoding        cp1251
+	RTL             false
+	LangCode        be_BY
+End
+
+Language brazilian
+	GuiName         "Portuguese (Brazil)"
+	BabelName       brazil
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        pt_BR
+End
+
+Language breton
+	GuiName         "Breton"
+	BabelName       breton
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        br_FR
+End
+
+Language british
+	GuiName         "English (UK)"
+	BabelName       british
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        en_GB
+End
+
+Language bulgarian
+	GuiName         "Bulgarian"
+	BabelName       bulgarian
+	Encoding        cp1251
+	RTL             false
+	LangCode        bg_BG
+End
+
+Language canadian
+	GuiName         "English (Canada)"
+	BabelName       canadian
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        en_CA
+End
+
+Language canadien
+	GuiName         "French (Canada)"
+	BabelName       canadien
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        fr_CA
+End
+
+Language catalan
+	GuiName         "Catalan"
+	BabelName       catalan
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        ca_ES
+End
+
+Language chinese-simplified
+	GuiName         "Chinese (simplified)"
+	Encoding        euc-cn
+	RTL             false
+	LangCode        zh_CN
+End
+
+Language chinese-traditional
+	GuiName         "Chinese (traditional)"
+	Encoding        utf8-cjk
+	RTL             false
+	LangCode        zh_CN
+End
+
+Language croatian
+	GuiName         "Croatian"
+	BabelName       croatian
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        hr_HR
+End
+
+Language czech
+	GuiName         "Czech"
+	BabelName       czech
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        cs_CZ
+End
+
+Language danish
+	GuiName         "Danish"
+	BabelName       danish
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        da_DK
+End
+
+Language dutch
+	GuiName         "Dutch"
+	BabelName       dutch
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        nl_NL
+End
+
+Language english
+	GuiName         "English"
+	BabelName       english
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        en_US
+End
+
 # Esperanto has no country code because it is an auxiliary language
-esperanto   esperanto	"Esperanto"	false  iso8859-3  eo	 ""
-estonian    estonian	"Estonian"	false  iso8859-15 et_EE	 ""
-# the definitions are only used due to bugs in the arabi-package - remove them if they become unnecessary!
-farsi       farsi	"Farsi"		true   utf8       fa_IR	 "\DeclareTextSymbol{\guillemotright}{LFE}{62}\DeclareTextSymbol{\guillemotleft}{LFE}{60}"
-finnish     finnish	"Finnish"	false  iso8859-15 fi_FI	 ""
+Language esperanto
+	GuiName         "Esperanto"
+	BabelName       esperanto
+	Encoding        iso8859-3
+	RTL             false
+	LangCode        eo
+End
+
+Language estonian
+	GuiName         "Estonian"
+	BabelName       estonian
+	Encoding        iso8859-15
+	RTL             false
+	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
+	BabelPreamble
+	  \DeclareTextSymbol{\guillemotright}{LFE}{62}
+	  \DeclareTextSymbol{\guillemotleft}{LFE}{60}
+	EndBabelPreamble
+End
+
+Language finnish
+	GuiName         "Finnish"
+	BabelName       finnish
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        fi_FI
+End
+
 # 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>\...@\unskip\fi~\frqq}}"
-galician    galician	"Galician"	false  iso8859-15 gl_ES	 ""
-german      german	"German (old spelling)"	false  iso8859-15 de-alt	 ""
-ngerman     ngerman	"German"	false  iso8859-15 de_DE	 ""
-german-ch   ngerman	"German (Switzerland)"	false  iso8859-15 de_CH	 ""
-greek       greek	"Greek"		false  iso8859-7  el_GR	 ""
-polutonikogreek polutonikogreek	"Greek (polytonic)"	false  iso8859-7  el_GR	 ""
-hebrew      hebrew	"Hebrew"	true   cp1255     he_IL	 ""
+Language french
+	GuiName         "French"
+	BabelName       french
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        fr_FR
+	BabelPreamble
+	  \addto\extrasfrench{%
+	       \providecommand{\og}{\leavevmode\flqq~}
+	       \providecommand{\fg}{\ifdim\lastskip>\...@\unskip\fi~\frqq}
+	  }
+	EndBabelPreamble
+End
+
+Language galician
+	GuiName         "Galician"
+	BabelName       galician
+	Encoding        iso8859-15
+	RTL             false
+	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
+	RTL             false
+	LangCode        de
+	LangVariety     alt
+End
+
+Language ngerman
+	GuiName         "German"
+	BabelName       ngerman
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        de_DE
+End
+
+Language german-ch
+	GuiName         "German (Switzerland)"
+	BabelName       ngerman
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        de_CH
+End
+
+Language greek
+	GuiName          "Greek"
+	BabelName        greek
+	Encoding         iso8859-7
+	InternalEncoding true
+	RTL              false
+	LangCode         el_GR
+End
+
+Language polutonikogreek
+	GuiName          "Greek (polytonic)"
+	BabelName        polutonikogreek
+	Encoding         iso8859-7
+	InternalEncoding true
+	RTL              false
+	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" might be used for special purposes, see http://www.math.bme.hu/latex/magyar_pre_tug2004.pdf
-#hungarian   hungarian	"Hungarian"	false  iso8859-2  hu_HU	 ""
-icelandic   icelandic	"Icelandic"	false  iso8859-15 is_IS	 ""
+# "hungarian" might be used for special purposes,
+# see http://www.math.bme.hu/latex/magyar_pre_tug2004.pdf
+#Language hungarian
+#	GuiName         "Hungarian"
+#	BabelName       hungarian
+#	Encoding        iso8859-2
+#	RTL             false
+#	LangCode        hu_HU
+#End
+
+Language icelandic
+	GuiName         "Icelandic"
+	BabelName       icelandic
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        is_IS
+End
+
 # Interlingua has no country code because it is an auxiliary language
-interlingua   interlingua	"Interlingua"	false  iso8859-15 ia	 ""
-irish       irish	"Irish"		false  iso8859-15 ga_IE	 ""
-italian     italian	"Italian"	false  iso8859-15 it_IT	 ""
-japanese    japanese	"Japanese"	false  jis-plain     ja_JP	 ""
-japanese-cjk ""		"Japanese (CJK)"	false  euc-jp     ja_JP	 ""
-kazakh	    kazakh	"Kazakh"	false  pt154      kk_KZ	 ""
+Language interlingua
+	GuiName         "Interlingua"
+	BabelName       interlingua
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        ia
+End
+
+Language irish
+	GuiName         "Irish"
+	BabelName       irish
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        ga_IE
+End
+
+Language italian
+	GuiName         "Italian"
+	BabelName       italian
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        it_IT
+End
+
+Language japanese
+	GuiName         "Japanese"
+	BabelName       japanese
+	Encoding        jis-plain
+	RTL             false
+	LangCode        ja_JP
+End
+
+Language japanese-cjk
+	GuiName         "Japanese (CJK)"
+	Encoding        euc-jp
+	RTL             false
+	LangCode        ja_JP
+End
+
+Language kazakh
+	GuiName         "Kazakh"
+	BabelName       kazakh
+	Encoding        pt154
+	RTL             false
+	LangCode        kk_KZ
+End
+
 # 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
+	RTL             false
+	LangCode        ko
+End
+
 # there is no country code for Latin because it is a dead language
-latin       latin	"Latin"		false  iso8859-15 la	 ""
-latvian     latvian	"Latvian"	false  iso8859-4  lv_LV	 ""
-lithuanian  lithuanian	"Lithuanian"	false  iso8859-13 lt_LT	 ""
-lowersorbian    lowersorbian	"Lower Sorbian"	false  iso8859-2  dsb_DE	 ""
-magyar      magyar	"Hungarian"	false  iso8859-2  hu_HU	 ""
-mongolian   mongolian	"Mongolian"	false  utf8       mn_MN	 ""
-norsk       norsk	"Norsk"		false  iso8859-15 nb_NO	 ""
-nynorsk     nynorsk	"Nynorsk"	false  iso8859-15 nn_NO	 ""
-polish      polish	"Polish"	false  iso8859-2  pl_PL	 ""
-portuguese  portuges	"Portuguese"	false  iso8859-15 pt_PT	 ""
-romanian    romanian	"Romanian"	false  iso8859-2  ro_RO	 ""
-russian     russian	"Russian"	false  koi8       ru_RU	 ""
-samin       samin	"North Sami"	false  iso8859-15 se_NO	 ""
-scottish    scottish	"Scottish"	false  iso8859-15 gd_GB	 ""
-serbian     serbian	"Serbian"	false  iso8859-5  sr_RS	 ""
-serbian-latin     serbian	"Serbian (Latin)"	false  iso8859-2  sr_RS	 ""
-slovak      slovak	"Slovak"	false  iso8859-2  sk_SK	 ""
-slovene     slovene	"Slovene"	false  iso8859-2  sl_SI	 ""
-spanish     spanish	"Spanish"	false  iso8859-15 es_ES	 "\addto\shorthandsspanish{\spanishdeactivate{~<>}}"
-spanish-mexico     spanish	"Spanish (Mexico)"	false  iso8859-15 es_MX	 "\addto\shorthandsspanish{\spanishdeactivate{~<>.}}"
-swedish     swedish	"Swedish"	false  iso8859-15 sv_SE	 ""
-thai        thai	"Thai"		false  tis620-0   th_TH	 "\usepackage{thswitch}"
-turkish     turkish	"Turkish"	false  iso8859-9  tr_TR	 ""
-turkmen     turkmen	"Turkmen"	false  utf8       tk_TM	 ""
-ukrainian   ukrainian	"Ukrainian"	false  koi8-u     uk_UA	 ""
-uppersorbian    uppersorbian	"Upper Sorbian"	false  iso8859-2  hsb_DE	 ""
-vietnamese  vietnam	"Vietnamese"	false  utf8       vi_VN	 ""
-welsh       welsh	"Welsh"		false  iso8859-15 cy_GB	 ""
+Language latin
+	GuiName         "Latin"
+	BabelName       latin
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        la
+End
+
+Language latvian
+	GuiName         "Latvian"
+	BabelName       latvian
+	Encoding        iso8859-4
+	RTL             false
+	LangCode        lv_LV
+End
+
+Language lithuanian
+	GuiName         "Lithuanian"
+	BabelName       lithuanian
+	Encoding        iso8859-13
+	RTL             false
+	LangCode        lt_LT
+End
+
+Language lowersorbian
+	GuiName         "Lower Sorbian"
+	BabelName       lowersorbian
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        dsb_DE
+End
+
+Language magyar
+	GuiName         "Hungarian"
+	BabelName       magyar
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        hu_HU
+End
+
+Language mongolian
+	GuiName         "Mongolian"
+	BabelName       mongolian
+	Encoding        utf8
+	RTL             false
+	LangCode        mn_MN
+End
+
+Language norsk
+	GuiName         "Norsk"
+	BabelName       norsk
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        nb_NO
+End
+
+Language nynorsk
+	GuiName         "Nynorsk"
+	BabelName       nynorsk
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        nn_NO
+End
+
+Language polish
+	GuiName         "Polish"
+	BabelName       polish
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        pl_PL
+End
+
+Language portuguese
+	GuiName         "Portuguese"
+	BabelName       portuges
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        pt_PT
+End
+
+Language romanian
+	GuiName         "Romanian"
+	BabelName       romanian
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        ro_RO
+End
+
+Language russian
+	GuiName         "Russian"
+	BabelName       russian
+	Encoding        koi8
+	RTL             false
+	LangCode        ru_RU
+End
+
+Language samin
+	GuiName         "North Sami"
+	BabelName       samin
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        se_NO
+End
+
+Language scottish
+	GuiName         "Scottish"
+	BabelName       scottish
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        gd_GB
+End
+
+Language serbian
+	GuiName         "Serbian"
+	BabelName       serbian
+	Encoding        iso8859-5
+	RTL             false
+	LangCode        sr_RS
+End
+
+Language serbian-latin
+	GuiName         "Serbian (Latin)"
+	BabelName       serbian
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        sr_RS
+End
+
+Language slovak
+	GuiName         "Slovak"
+	BabelName       slovak
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        sk_SK
+End
+
+Language slovene
+	GuiName         "Slovene"
+	BabelName       slovene
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        sl_SI
+End
+
+Language spanish
+	GuiName         "Spanish"
+	BabelName       spanish
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        es_ES
+	BabelPreamble
+	  \addto\shorthandsspanish{\spanishdeactivate{~<>}}
+	EndBabelPreamble
+End
+
+Language spanish-mexico
+	GuiName         "Spanish (Mexico)"
+	BabelName       spanish
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        es_MX
+	BabelPreamble
+	  \addto\shorthandsspanish{\spanishdeactivate{~<>.}}
+	EndBabelPreamble
+End
+
+Language swedish
+	GuiName         "Swedish"
+	BabelName       swedish
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        sv_SE
+End
+
+Language thai
+	GuiName         "Thai"
+	BabelName       thai
+	Encoding        tis620-0
+	RTL             false
+	LangCode        th_TH
+	BabelPreamble
+	  \usepackage{thswitch}
+	EndBabelPreamble
+End
+
+Language turkish
+	GuiName         "Turkish"
+	BabelName       turkish
+	Encoding        iso8859-9
+	RTL             false
+	LangCode        tr_TR
+End
+
+Language turkmen
+	GuiName         "Turkmen"
+	BabelName       turkmen
+	Encoding        utf8
+	RTL             false
+	LangCode        tk_TM
+End
+
+Language ukrainian
+	GuiName         "Ukrainian"
+	BabelName       ukrainian
+	Encoding        koi8-u
+	RTL             false
+	LangCode        uk_UA
+End
+
+Language uppersorbian
+	GuiName         "Upper Sorbian"
+	BabelName       uppersorbian
+	Encoding        iso8859-2
+	RTL             false
+	LangCode        hsb_DE
+End
+
+Language vietnamese
+	GuiName         "Vietnamese"
+	BabelName       vietnam
+	Encoding        utf8
+	RTL             false
+	LangCode        vi_VN
+End
+
+Language welsh
+	GuiName         "Welsh"
+	BabelName       welsh
+	Encoding        iso8859-15
+	RTL             false
+	LangCode        cy_GB
+End
Index: src/Language.cpp
===================================================================
--- src/Language.cpp	(Revision 36280)
+++ src/Language.cpp	(Arbeitskopie)
@@ -37,20 +37,104 @@
 Language const * reset_language = 0;
 
 
+bool Language::readLanguage(Lexer & lex)
+{
+	enum LanguageTags {
+		LA_BABELNAME = 1,
+		LA_BABELPREAMBLE,
+		LA_ENCODING,
+		LA_END,
+		LA_GUINAME,
+		LA_INTERNAL_ENC,
+		LA_LANG_CODE,
+		LA_LANG_VARIETY,
+		LA_RTL
+	};
+
+
+	LexerKeyword languageTags[] = {
+		{ "babelname",            LA_BABELNAME },
+		{ "babelpreamble",        LA_BABELPREAMBLE },
+		{ "encoding",             LA_ENCODING },
+		{ "end",                  LA_END },
+		{ "guiname",              LA_GUINAME },
+		{ "internalencoding",     LA_INTERNAL_ENC },
+		{ "langcode",             LA_LANG_CODE },
+		{ "langvariety",          LA_LANG_VARIETY },
+		{ "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_BABELPREAMBLE:
+			latex_options_ = lex.getLongString("EndBabelPreamble");
+			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_RTL:
+			lex >> rightToLeft_;
+			break;
+		}
+	}
+	lex.popTable();
+	return finished && !error;
+}
+
+
 bool Language::read(Lexer & lex)
 {
 	encoding_ = 0;
-	lex >> lang_;
-	lex >> babel_;
-	lex >> display_;
-	lex >> rightToLeft_;
-	lex >> encodingStr_;
-	lex >> codeStr_;
-	lex >> latex_options_;
-	if (!lex)
+	internal_enc_ = 0;
+	rightToLeft_ = 0;
+
+	if (!lex.next()) {
+		lex.printError("No name given for language: `$$Token'.");
 		return false;
+	}
 
-	variety_ = split(codeStr_, code_, '-');
+	lang_ = lex.getString();
+	LYXERR(Debug::INFO, "Reading language " << lang_);
+	if (!readLanguage(lex)) {
+		LYXERR0("Error parsing language `" << lang_ << '\'');
+		return false;
+	}
 
 	encoding_ = encodings.fromLyXName(encodingStr_);
 	if (!encoding_ && !encodingStr_.empty()) {
@@ -60,28 +144,28 @@
 	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)
 {
 	Lexer lex;
 	lex.setFile(filename);
 	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;
 		l.read(lex);
 		if (!lex)
 			break;
-		LYXERR(Debug::INFO, "Reading language " << l.lang());
 		if (l.lang() == "latex")
 			latex_lang = l;
 		else if (l.lang() == "ignore")
Index: src/Language.h
===================================================================
--- src/Language.h	(Revision 36280)
+++ src/Language.h	(Arbeitskopie)
@@ -54,9 +54,11 @@
 	///
 	std::string const & latex_options() const { return latex_options_; }
 	///
-	bool internalFontEncoding() const;
+	bool internalFontEncoding() const { return internal_enc_; }
 	///
 	bool read(Lexer & lex);
+	///
+	bool readLanguage(Lexer & lex);
 	// for the use in std::map
 	friend bool operator<(Language const & p, Language const & q);
 private:
@@ -73,13 +75,13 @@
 	///
 	Encoding const * encoding_;
 	///
-	std::string codeStr_;
-	///
 	std::string code_;
 	///
 	std::string variety_;
 	///
 	std::string latex_options_;
+	///
+	bool internal_enc_;
 };
 
 
Index: po/lyx_pot.py
===================================================================
--- po/lyx_pot.py	(Revision 36280)
+++ po/lyx_pot.py	(Arbeitskopie)
@@ -230,30 +230,23 @@
 
 
 def languages_l10n(input_files, output, base):
-    '''Generate pot file from lib/language'''
-    output = open(output, 'w')
-    # assuming only one language file
-    reg = re.compile('[\w-]+\s+[\w"]+\s+"([\w \-\(\),]+)"\s+(true|false)\s+[\w-]+\s+[\w\-]+\s+"[^"]*"')
-    input = open(input_files[0])
-    for lineno, line in enumerate(input.readlines()):
-        if line[0] == '#':
-            continue
-        # From:
-        #   afrikaans   afrikaans	"Afrikaans"	false  iso8859-15 af_ZA	 ""
-        # 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()
+    '''Generate pot file from lib/languages'''
+    out = open(output, 'w')
+    GuiName = re.compile(r'\s*GuiName\s+(.*)')
+    
+    for src in input_files:
+        descStartLine = -1
+        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
+               
+    out.close()
 
 
 def external_l10n(input_files, output, base):

Reply via email to