1" Vim tutor support file 2" Author: Eduardo F. Amatria <[email protected]> 3" Last Change: 2006 Mar 18 4 5" This small source file is used for detecting if a translation of the 6" tutor file exist, i.e., a tutor.xx file, where xx is the language. 7" If the translation does not exist, or no extension is given, 8" it defaults to the english version. 9 10" It is invoked by the vimtutor shell script. 11 12" 1. Build the extension of the file, if any: 13let s:ext = "" 14if strlen($xx) > 1 15 let s:ext = "." . $xx 16else 17 let s:lang = "" 18 " Check that a potential value has at least two letters. 19 " Ignore "1043" and "C". 20 if exists("v:lang") && v:lang =~ '\a\a' 21 let s:lang = v:lang 22 elseif $LC_ALL =~ '\a\a' 23 let s:lang = $LC_ALL 24 elseif $LANG =~ '\a\a' 25 let s:lang = $LANG 26 endif 27 if s:lang != "" 28 " Remove "@euro" (ignoring case), it may be at the end 29 let s:lang = substitute(s:lang, '\c@euro', '', '') 30 " On MS-Windows it may be German_Germany.1252 or Polish_Poland.1250. How 31 " about other languages? 32 if s:lang =~ "German" 33 let s:ext = ".de" 34 elseif s:lang =~ "Polish" 35 let s:ext = ".pl" 36 elseif s:lang =~ "Slovak" 37 let s:ext = ".sk" 38 elseif s:lang =~ "Dutch" 39 let s:ext = ".nl" 40 else 41 let s:ext = "." . strpart(s:lang, 0, 2) 42 endif 43 endif 44endif 45 46" The japanese tutor is available in two encodings, guess which one to use 47" The "sjis" one is actually "cp932", it doesn't matter for this text. 48if s:ext =~? '\.ja' 49 if &enc =~ "euc" 50 let s:ext = ".ja.euc" 51 elseif &enc =~ "utf-8$" 52 let s:ext = ".ja.utf-8" 53 else 54 let s:ext = ".ja.sjis" 55 endif 56endif 57 58" The korean tutor is available in two encodings, guess which one to use 59if s:ext =~? '\.ko' 60 if &enc =~ "utf-8$" 61 let s:ext = ".ko.utf-8" 62 else 63 let s:ext = ".ko.euc" 64 endif 65endif 66 67" The Chinese tutor is available in two encodings, guess which one to use 68" This segment is from the above lines and modified by 69" Mendel L Chan <[email protected]> for Chinese vim tutorial 70if s:ext =~? '\.zh' 71 if &enc =~ 'big5\|cp950' 72 let s:ext = ".zh.big5" 73 else 74 let s:ext = ".zh.euc" 75 endif 76endif 77 78" The Polish tutor is available in two encodings, guess which one to use. 79if s:ext =~? '\.pl' 80 if &enc =~ 1250 81 let s:ext = ".pl.cp1250" 82 elseif &enc =~ "utf-8$" 83 let s:ext = ".pl.utf-8" 84 endif 85endif 86 87" The Turkish tutor is available in two encodings, guess which one to use 88if s:ext =~? '\.tr' 89 if &enc == "utf-8" 90 let s:ext = ".tr.utf-8" 91 elseif &enc == "iso-8859-9" 92 let s:ext = ".tr.iso9" 93 endif 94endif 95 96" The Greek tutor is available in two encodings, guess which one to use 97if s:ext =~? '\.gr' && &enc =~ 737 98 let s:ext = ".gr.cp737" 99endif 100 101" The Slovak tutor is available in two encodings, guess which one to use 102if s:ext =~? '\.sk' && &enc =~ 1250 103 let s:ext = ".sk.cp1250" 104endif 105 106" The Russian tutor is available in two encodings, guess which one to use. 107" This segment is from the above lines and modified by 108" Alexey I. Froloff <[email protected]> for Russian vim tutorial 109if s:ext =~? '\.ru' && &enc =~ 1251 110 let s:ext = ".ru.cp1251" 111endif 112 113" Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch). 114if s:ext =~? '\.ge' 115 let s:ext = ".de" 116endif 117 118if s:ext =~? '\.en' 119 let s:ext = "" 120endif 121 122" 2. Build the name of the file: 123let s:tutorfile = "/tutor/tutor" 124let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext 125 126" 3. Finding the file: 127if filereadable(s:tutorxx) 128 let $TUTOR = s:tutorxx 129else 130 let $TUTOR = $VIMRUNTIME . s:tutorfile 131 echo "The file " . s:tutorxx . " does not exist.\n" 132 echo "Copying English version: " . $TUTOR 133 4sleep 134endif 135 136" 4. Making the copy and exiting Vim: 137e $TUTOR 138wq! $TUTORCOPY 139