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