1 " Vim tutor support file
2 " Author: Eduardo F. Amatria <eferna1@platea.pntic.mec.es>
3 " Last Change: 2008 Jun 21
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.
10 " It is invoked by the vimtutor shell script.
12 " 1. Build the extension of the file, if any:
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'
22 elseif $LC_ALL =~ '\a\a'
24 elseif $LANG =~ '\a\a'
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?
34 elseif s:lang =~ "Polish"
36 elseif s:lang =~ "Slovak"
38 elseif s:lang =~ "Czech"
40 elseif s:lang =~ "Dutch"
43 let s:ext = "." . strpart(s:lang, 0, 2)
48 " Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch).
57 " The japanese tutor is available in two encodings, guess which one to use
58 " The "sjis" one is actually "cp932", it doesn't matter for this text.
62 elseif &enc != "utf-8"
63 let s:ext = ".ja.sjis"
67 " The korean tutor is available in two encodings, guess which one to use
74 " The Chinese tutor is available in two encodings, guess which one to use
75 " This segment is from the above lines and modified by
76 " Mendel L Chan <beos@turbolinux.com.cn> for Chinese vim tutorial
78 if &enc =~ 'big5\|cp950'
79 let s:ext = ".zh.big5"
80 elseif &enc != 'utf-8'
85 " The Polish tutor is available in two encodings, guess which one to use.
88 let s:ext = ".pl.cp1250"
92 " The Turkish tutor is available in two encodings, guess which one to use
94 if &enc == "iso-8859-9"
95 let s:ext = ".tr.iso9"
99 " The Greek tutor is available in three encodings, guess what to use.
100 " We used ".gr" (Greece) instead of ".el" (Greek); accept both.
101 if s:ext =~? '\.gr\|\.el'
102 if &enc == "iso-8859-7"
104 elseif &enc == "utf-8"
105 let s:ext = ".el.utf-8"
107 let s:ext = ".el.cp737"
111 " The Slovak tutor is available in three encodings, guess which one to use
114 let s:ext = ".sk.cp1250"
118 " The Czech tutor is available in three encodings, guess which one to use
121 let s:ext = ".cs.cp1250"
125 " The Russian tutor is available in three encodings, guess which one to use.
128 let s:ext = '.ru.cp1251'
129 elseif &enc =~ 'koi8'
134 " The Hungarian tutor is available in three encodings, guess which one to use.
137 let s:ext = ".hu.cp1250"
138 elseif &enc =~ 'iso-8859-2'
143 " The Croatian tutor is available in three encodings, guess which one to use.
146 let s:ext = ".hr.cp1250"
147 elseif &enc =~ 'iso-8859-2'
152 " Esperanto is only available in utf-8
154 let s:ext = ".eo.utf-8"
156 " Vietnamese is only available in utf-8
158 let s:ext = ".vi.utf-8"
161 " If 'encoding' is utf-8 s:ext must end in utf-8.
162 if &enc == 'utf-8' && s:ext !~ '\.utf-8'
166 " 2. Build the name of the file:
167 let s:tutorfile = "/tutor/tutor"
168 let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext
170 " 3. Finding the file:
171 if filereadable(s:tutorxx)
172 let $TUTOR = s:tutorxx
174 let $TUTOR = $VIMRUNTIME . s:tutorfile
175 echo "The file " . s:tutorxx . " does not exist.\n"
176 echo "Copying English version: " . $TUTOR
180 " 4. Making the copy and exiting Vim: