blob: 754f3c0e9cd8acc7cc5b66894832e477169889b8 [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>
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003" Last Change: 2004 Sep 06
Bram Moolenaar071d4272004-06-13 20:20:40 +00004
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.
Bram Moolenaarc0197e22004-09-13 20:26:32 +000073if s:ext =~? '\.pl'
74 if &enc =~ 1250
75 let s:ext = ".pl.cp1250"
76 elseif &enc =~ "utf-8$"
77 let s:ext = ".pl.utf-8"
78 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000079endif
80
81" The Greek tutor is available in two encodings, guess which one to use
82if s:ext =~? '\.gr' && &enc =~ 737
83 let s:ext = ".gr.cp737"
84endif
85
86" The Slovak tutor is available in two encodings, guess which one to use
87if s:ext =~? '\.sk' && &enc =~ 1250
88 let s:ext = ".sk.cp1250"
89endif
90
91" The Russian tutor is available in two encodings, guess which one to use.
92" This segment is from the above lines and modified by
93" Alexey I. Froloff <raorn@altlinux.org> for Russian vim tutorial
94if s:ext =~? '\.ru' && &enc =~ 1251
95 let s:ext = ".ru.cp1251"
96endif
97
98" Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch).
99if s:ext =~? '\.ge'
100 let s:ext = ".de"
101endif
102
103if s:ext =~? '\.en'
104 let s:ext = ""
105endif
106
107" 2. Build the name of the file:
108let s:tutorfile = "/tutor/tutor"
109let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext
110
111" 3. Finding the file:
112if filereadable(s:tutorxx)
113 let $TUTOR = s:tutorxx
114else
115 let $TUTOR = $VIMRUNTIME . s:tutorfile
116 echo "The file " . s:tutorxx . " does not exist.\n"
117 echo "Copying English version: " . $TUTOR
118 4sleep
119endif
120
121" 4. Making the copy and exiting Vim:
122e $TUTOR
123wq! $TUTORCOPY