]> git.lyx.org Git - features.git/commitdiff
support for the Vietnamese languages
authorUwe Stöhr <uwestoehr@web.de>
Thu, 4 Oct 2007 23:20:39 +0000 (23:20 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Thu, 4 Oct 2007 23:20:39 +0000 (23:20 +0000)
fileformat increased to 291

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20738 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/languages
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_6.py
src/Buffer.cpp
src/BufferParams.cpp

index 92ebad8e53f789afdf4af2270e4c5083c56a1fcd..21563b9c794dfe8ea34d2e8326ee00fee56af727 100644 (file)
@@ -1,9 +1,12 @@
 LyX file-format changes
 -----------------------
 
+2007-10-04 Uwe Stöhr Uwe Stöhr <uwestoehr@web.de>
+       * Format incremented to 291: Support for Vietnamese.
+
 2007-10-03 Uwe Stöhr Uwe Stöhr <uwestoehr@web.de>
        * Format incremented to 290: Add table wrap floats.
-       
+
 2007-10-03 Martin Vermeer <martin.vermeer@tkk.fi>
        * Format incremented to 289: make Index a collapsable inset.
 
index 2635c05f934635403ec6747eee1d48fd36fc95dc..7ab09b7515f4e15ce4a105ce9b0b4df9208696d4 100644 (file)
@@ -66,4 +66,5 @@ thai        thai      "Thai"          false  tis620-0   th_TH  "\usepackage{thswitch}"
 turkish     turkish    "Turkish"       false  iso8859-9  tr_TR  ""
 ukrainian   ukrainian  "Ukrainian"     false  koi8-u     uk_UA  ""
 usorbian    usorbian   "Upper Sorbian" false  iso8859-2  hsb_DE         ""
+vietnamese  vietnam    "Vietnamese"    false  utf8       vi_VN  ""
 welsh       welsh      "Welsh"         false  iso8859-15 cy_GB  ""
index 97b3f19823741abc84ec714c8d0186733e75345b..cbb863467d363727e3ac6478962df7ba19d4acc7 100644 (file)
@@ -80,7 +80,7 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_3",     [221], minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), minor_versions("1.4" , 5)),
                    ("1_5", range(246,277), minor_versions("1.5" , 1)),
-                   ("1_6", range(277,291), minor_versions("1.6" , 0))] # Uwe Stöhr, wrap table
+                   ("1_6", range(277,292), minor_versions("1.6" , 0))] # Uwe Stöhr, Vietnamese
 
 
 def formats_list():
index ed064869de7cd6b5ed7f4571e328cb13babf9b61..866c65d11c6883711706513924ad9d87eab899b7 100644 (file)
@@ -402,6 +402,24 @@ def revert_wraptable(document):
         i = i + 1
 
 
+def revert_vietnamese(document):
+    "Set language Vietnamese to English"
+    # Set document language from Vietnamese to English
+    i = 0
+    if document.language == "vietnamese":
+        document.language = "english"
+        i = find_token(document.header, "\\language", 0)
+        if i != -1:
+            document.header[i] = "\\language english"
+    j = 0
+    while True:
+        j = find_token(document.body, "\\lang vietnamese", j)
+        if j == -1:
+            return
+        document.body[j] = document.body[j].replace("\\lang vietnamese", "\\lang english")
+        j = j + 1
+
+
 ##
 # Conversion hub
 #
@@ -420,10 +438,12 @@ convert = [[277, [fix_wrong_tables]],
            [287, [convert_wrapfig_options]],
            [288, [convert_inset_command]],
            [289, [convert_latexcommand_index]],
-           [290, []]
+           [290, []],
+           [291, []]
           ]
 
-revert =  [[289, [revert_wraptable]],
+revert =  [[290, [revert_vietnamese]],
+           [289, [revert_wraptable]],
            [288, [revert_latexcommand_index]],
            [287, [revert_inset_command]],
            [286, [revert_wrapfig_options]],
index d467215e307e64b6935c278aea2f8203d58c8856..4d24cf9c047b832c9625daaee02f9780f36e28b6 100644 (file)
@@ -154,7 +154,7 @@ namespace fs = boost::filesystem;
 
 namespace {
 
-int const LYX_FORMAT = 290; //Uwe Stöhr, wrap table
+int const LYX_FORMAT = 291; //Uwe Stöhr, Vietnamese
 
 } // namespace anon
 
index 88115e5e2469d441c6d0aa91ae89f2c9922a9a2c..40aba23a00d9c39545914461fc9a300ff78ff471 100644 (file)
@@ -54,6 +54,7 @@
 
 using std::count;
 using std::endl;
+using std::find;
 using std::string;
 using std::istringstream;
 using std::ostream;
@@ -899,7 +900,12 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                                language_options << ',';
                        language_options << language->babel();
                }
-               if (lyxrc.language_global_options && !language_options.str().empty())
+               // when Vietnamese is used, babel must directly be loaded with the
+               // language options, not in the class options
+               int viet = language_options.str().find("vietnam");
+               // viet = string::npos when not found
+               if (lyxrc.language_global_options && !language_options.str().empty()
+                       && viet == string::npos)
                        clsoptions << language_options.str() << ',';
        }
 
@@ -1548,7 +1554,11 @@ string const BufferParams::babelCall(string const & lang_opts) const
        // other languages are used (lang_opts is then empty)
        if (lang_opts.empty())
                return string();
-       if (!lyxrc.language_global_options)
+       // when Vietnamese is used, babel must directly be loaded with the
+       // language options
+       int viet = lang_opts.find("vietnam");
+       // viet = string::npos when not found
+       if (!lyxrc.language_global_options || viet != string::npos)
                return "\\usepackage[" + lang_opts + "]{babel}";
        return lang_pack;
 }