From 227f80157c878377fe8e161be957bd71fd94e216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20St=C3=B6hr?= Date: Tue, 1 May 2007 17:48:04 +0000 Subject: [PATCH] file format change: support for Armenian git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18155 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 5 + .../installer/LyXWinInstaller/Updated.nsh | 5 +- development/scons/scons_manifest.py | 2 + lib/Makefile.am | 2 + lib/encodings | 4 + lib/examples/Armenian-article.lyx | 186 ++++++++++++++++++ lib/languages | 4 + lib/layouts/armenian-article.layout | 39 ++++ lib/lyx2lyx/LyX.py | 2 +- lib/lyx2lyx/lyx_1_5.py | 36 +++- src/Buffer.cpp | 2 +- src/BufferParams.cpp | 7 + 12 files changed, 289 insertions(+), 5 deletions(-) create mode 100644 lib/examples/Armenian-article.lyx create mode 100644 lib/layouts/armenian-article.layout diff --git a/development/FORMAT b/development/FORMAT index 7dca45b607..8104cac63f 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,11 @@ LyX file-format changes ----------------------- +2007-04-29 Uwe Stöhr + + * format incremented to 266: + Support for the Armenian language + 2007-04-26 Uwe Stöhr * format incremented to 265: fix LyX's table border line handling diff --git a/development/Win32/packaging/installer/LyXWinInstaller/Updated.nsh b/development/Win32/packaging/installer/LyXWinInstaller/Updated.nsh index b3880c0e84..b064a47eab 100644 --- a/development/Win32/packaging/installer/LyXWinInstaller/Updated.nsh +++ b/development/Win32/packaging/installer/LyXWinInstaller/Updated.nsh @@ -7,8 +7,9 @@ Function UpdateModifiedFiles File "${PRODUCT_SOURCEDIR}\bin\LyXLauncher.exe" File "${PRODUCT_SOURCEDIR}\bin\tex2lyx.exe" ; always here SetOutPath "$INSTDIR\Resources" - File "${PRODUCT_SOURCEDIR}\Resources\unicodesymbols" + File "${PRODUCT_SOURCEDIR}\Resources\encodings" File "${PRODUCT_SOURCEDIR}\Resources\languages" + File "${PRODUCT_SOURCEDIR}\Resources\unicodesymbols" File /r "${PRODUCT_SOURCEDIR}\Resources\locale" ; always here SetOutPath "$INSTDIR\Resources\bind" File "${PRODUCT_SOURCEDIR}\Resources\bind\sciword.bind" @@ -31,6 +32,7 @@ Function UpdateModifiedFiles SetOutPath "$INSTDIR\Resources\examples" File "${PRODUCT_SOURCEDIR}\Resources\examples\CV-image.eps" File "${PRODUCT_SOURCEDIR}\Resources\examples\CV-image.png" + File "${PRODUCT_SOURCEDIR}\Resources\examples\armenian-article.lyx" File "${PRODUCT_SOURCEDIR}\Resources\examples\europeCV.lyx" File "${PRODUCT_SOURCEDIR}\Resources\examples\modernCV.lyx" File "${PRODUCT_SOURCEDIR}\Resources\examples\simplecv.lyx" @@ -43,6 +45,7 @@ Function UpdateModifiedFiles SetOutPath "$INSTDIR\Resources\images\math" File "${PRODUCT_SOURCEDIR}\Resources\images\math\super.xpm" SetOutPath "$INSTDIR\Resources\layouts" + File "${PRODUCT_SOURCEDIR}\Resources\layouts\armenian-article.layout" File "${PRODUCT_SOURCEDIR}\Resources\layouts\simplecv.layout" SetOutPath "$INSTDIR\Resources\lyx2lyx" File "${PRODUCT_SOURCEDIR}\Resources\lyx2lyx\LyX.py" diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 3b2d947160..9c4f808d12 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -2379,6 +2379,7 @@ lib_examples_files = Split(''' aas_sample.lyx amsart-test.lyx amsbook-test.lyx + armenian-article.lyx beamer-g4-mask.jpg beamer-g4.jpg beamer-icsi-logo.pdf @@ -2595,6 +2596,7 @@ lib_layouts_files = Split(''' amsmaths.inc apa.layout arab-article.layout + armenian-article.layout article.layout beamer.layout book.layout diff --git a/lib/Makefile.am b/lib/Makefile.am index b078717191..49a20e6726 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -180,6 +180,7 @@ dist_examples_DATA = \ examples/aas_sample.lyx \ examples/amsart-test.lyx \ examples/amsbook-test.lyx \ + examples/armenian-article.lyx \ examples/beamer-g4.jpg \ examples/beamer-g4-mask.jpg \ examples/beamer-icsi-logo.pdf \ @@ -893,6 +894,7 @@ dist_layouts_DATA =\ layouts/amsmaths.inc \ layouts/apa.layout \ layouts/arab-article.layout \ + layouts/armenian-article.layout \ layouts/article.layout \ layouts/beamer.layout \ layouts/book.layout \ diff --git a/lib/encodings b/lib/encodings index b05138119f..866d5cb732 100644 --- a/lib/encodings +++ b/lib/encodings @@ -16,6 +16,10 @@ End Encoding utf8x utf8x UTF-8 End +# This encoding is used to typeset Armenian using the armtex package +Encoding armscii8 armscii8 ARMSCII-8 +End + Encoding iso8859-1 latin1 ISO-8859-1 End diff --git a/lib/examples/Armenian-article.lyx b/lib/examples/Armenian-article.lyx new file mode 100644 index 0000000000..66f20f007b --- /dev/null +++ b/lib/examples/Armenian-article.lyx @@ -0,0 +1,186 @@ +#LyX 1.5.0svn created this file. For more info see http://www.lyx.org/ +\lyxformat 265 +\begin_document +\begin_header +\textclass armenian-article +\language armenian +\inputencoding auto +\font_roman default +\font_sans default +\font_typewriter default +\font_default_family default +\font_sc false +\font_osf false +\font_sf_scale 100 +\font_tt_scale 100 +\graphics default +\paperfontsize default +\spacing single +\papersize default +\use_geometry false +\use_amsmath 1 +\use_esint 1 +\cite_engine basic +\use_bibtopic false +\paperorientation portrait +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation skip +\defskip medskip +\quotes_language english +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tracking_changes false +\output_changes false +\author "usti" +\end_header + +\begin_body + +\begin_layout Part +Test +\end_layout + +\begin_layout Standard +\begin_inset ERT +status collapsed + +\begin_layout Standard + + +\backslash +today +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +«Իսկ յայսմ ժամանակի (Մերուժանն Արծրունի եւ Վահանն Մամիկոնեան) աւերեցին զքաղաքսն, + եւ գերեցին զբնակեալսն անդ... + եւ զայլ գերութիւնս՝ գաւառաց գաւառաց, կողմանց +\series bold +կողմանց +\series default +, փորի փո +\backslash +-րի, զաշխարհի աշխարհի, ածին ժողովեցին ի քա +\backslash +-ղաքն Նախճուան, զի անդ էր զօրաժողով իւրեանց զօրացն»։ +\end_layout + +\begin_layout Standard +Մեկ Ազգ , Մեկ Մշակույթ +\end_layout + +\begin_layout LatinOn + +\end_layout + +\begin_layout Standard +All text between +\begin_inset Quotes eld +\end_inset + +Latin on +\begin_inset Quotes erd +\end_inset + + and +\begin_inset Quotes eld +\end_inset + +Latin off +\begin_inset Quotes erd +\end_inset + + is typeset in latin characters using a unofficial transliteration: +\end_layout + +\begin_layout Standard +Մերուժանն Արծրունի եւ Վահանն Մամիկոնեան +\end_layout + +\begin_layout Standard +Latin letters outside this environment are translated to Armenian letters. + To switch off Armenian inside a paragraph use the command +\end_layout + +\begin_layout Standard + +\series bold +{ +\backslash +aroff some text} +\end_layout + +\begin_layout Standard +where some text is your text that should not appear in Armenian, see the + example below. + (Don't forget the space behind +\series bold + +\backslash +aroff +\series default +). +\end_layout + +\begin_layout LatinOff + +\end_layout + +\begin_layout Standard +«Իսկ յայսմ ժամանակի +\begin_inset ERT +status collapsed + +\begin_layout Standard + +{ +\backslash +aroff +\end_layout + +\end_inset + +Test words. +\begin_inset ERT +status collapsed + +\begin_layout Standard + +} +\end_layout + +\end_inset + + աւերեցին զքաղաքսն, եւ գերեցին զբնակեալսն անդ... +\end_layout + +\begin_layout Standard +Latin letters are translated to Armenian letters when they are outside the + Latin environment. +\end_layout + +\begin_layout LatinOn + +\end_layout + +\begin_layout Standard +LyX uses the LaTeX-package ArmTeX to typeset Armenian. + For more informations about Armenian typesetting look at the documentation + of armTeX: +\newline +http://texcatalogue.sarovar.org/entries/armtex.html +\end_layout + +\begin_layout LatinOff + +\end_layout + +\end_body +\end_document diff --git a/lib/languages b/lib/languages index ef44e5736f..5a63b2a6d4 100644 --- a/lib/languages +++ b/lib/languages @@ -2,6 +2,10 @@ afrikaans afrikaans "Afrikaans" false iso8859-15 af_ZA "" american american "American" false iso8859-15 en_US "" arabic arabic "Arabic" true cp1256 ar_SA "" +# loading babel with the option "english" as armtex overwrites this later +# armtex provides the armscii8 encoding and translates words instead of babel +# the english option can later be omitted when the patch for bug 3043 is in. +armenian english "Armenian" false armscii8 hy_AM "" austrian austrian "Austrian" false iso8859-15 de_AT "" naustrian naustrian "Austrian (new spelling)" false iso8859-15 de_AT "" bahasa bahasa "Bahasa" false iso8859-15 in_ID "" diff --git a/lib/layouts/armenian-article.layout b/lib/layouts/armenian-article.layout new file mode 100644 index 0000000000..c6ba97b092 --- /dev/null +++ b/lib/layouts/armenian-article.layout @@ -0,0 +1,39 @@ +#% Do not delete the line below; configure depends on this +# \DeclareLaTeXClass[article]{article (Armenian)} +# Arabic article textclass definition file. +# Author: Uwe Stöhr (uwestoehr@web.de) + +Format 4 +Input article + +Style LatinOn + Margin Dynamic + LatexType Command + LatexName phantom{}{\aroff{} + KeepEmpty 1 + ParSkip 0.4 + Align Block + LabelSep xx + LabelType Static + LabelString "Latin on" + LabelFont + Series Bold + Color Blue + EndFont +End + +Style LatinOff + Margin Dynamic + LatexType Command + LatexName phantom{}} + KeepEmpty 1 + ParSkip 0.4 + Align Block + LabelSep xx + LabelType Static + LabelString "Latin off" + LabelFont + Series Bold + Color Green + EndFont +End diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index c975aa3724..8914029d57 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -74,7 +74,7 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)), ("1_2", [220], generate_minor_versions("1.2" , 4)), ("1_3", [221], generate_minor_versions("1.3" , 7)), ("1_4", range(222,246), generate_minor_versions("1.4" , 4)), - ("1_5", range(246,266), generate_minor_versions("1.5" , 0))] + ("1_5", range(246,267), generate_minor_versions("1.5" , 0))] def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_5.py b/lib/lyx2lyx/lyx_1_5.py index 9f1b1ff980..7333e652bc 100644 --- a/lib/lyx2lyx/lyx_1_5.py +++ b/lib/lyx2lyx/lyx_1_5.py @@ -1283,6 +1283,36 @@ def revert_tableborder(document): i = i + 1 +def revert_armenian(document): + # Set document language from armenian to english an + if document.language == "armenian": + document.language = "english" + i = find_token(document.header, "\\language", 0) + if i != -1: + document.header[i] = "\\language english" + # set inputencoding from armscii8 to auto + if document.inputencoding == "armscii8": + i = find_token(document.header, "\\inputencoding", 0) + if i != -1: + document.header[i] = "\\inputencoding auto" + # add the entry \usepackage{armtex} to the document preamble + # check if preamble exists, if not k is set to -1 + i = 0 + k = -1 + while i < len(document.preamble): + if k == -1: + k = document.preamble[i].find("\\", 0, len(document.preamble[i])) + if k == -1: + k = document.preamble[i].find("%", 0, len(document.preamble[i])) + i = i + 1 + # set the armtex entry as the first preamble line + if k != -1: + document.preamble[0] = "\\usepackage{armtex}" + "\r" + document.preamble[0][0:] + # create the preamble when it doesn't exist + else: + document.preamble.append('\\usepackage{armtex}') + + ## # Conversion hub # @@ -1307,9 +1337,11 @@ convert = [[246, []], [262, []], [263, [normalize_language_name]], [264, [convert_cv_textclass]], - [265, [convert_tableborder]]] + [265, [convert_tableborder]], + [266, []]] -revert = [[264, [revert_tableborder]], +revert = [[265, [revert_armenian]], + [264, [revert_tableborder]], [263, [revert_cv_textclass]], [262, [revert_language_name]], [261, [revert_ascii]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 2566006b90..850882d958 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -141,7 +141,7 @@ using std::string; namespace { -int const LYX_FORMAT = 265; +int const LYX_FORMAT = 266; } // namespace anon diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 809fa85f08..3ba80c50aa 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -923,6 +923,13 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, texrow.newline(); } + // The encoding "armscii8" is only available when the package "armtex" is loaded. + // armscii8 is used for Armenian. + if (language->encoding()->latexName() == "armscii8" || inputenc == "armscii8") { + os << "\\usepackage{armtex}\n"; + texrow.newline(); + } + if (use_geometry || nonstandard_papersize) { os << "\\usepackage{geometry}\n"; texrow.newline();