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