0
|
1 " Vim tutor support file
|
|
2 " Author: Eduardo F. Amatria <eferna1@platea.pntic.mec.es>
|
|
3 " Last Change: 2007 Mar 01
|
|
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:
|
|
13 let s:ext = ""
|
|
14 if strlen($xx) > 1
|
|
15 let s:ext = "." . $xx
|
|
16 else
|
|
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 =~ "Czech"
|
|
39 let s:ext = ".cs"
|
|
40 elseif s:lang =~ "Dutch"
|
|
41 let s:ext = ".nl"
|
|
42 else
|
|
43 let s:ext = "." . strpart(s:lang, 0, 2)
|
|
44 endif
|
|
45 endif
|
|
46 endif
|
|
47
|
|
48 " The japanese tutor is available in two encodings, guess which one to use
|
|
49 " The "sjis" one is actually "cp932", it doesn't matter for this text.
|
|
50 if s:ext =~? '\.ja'
|
|
51 if &enc =~ "euc"
|
|
52 let s:ext = ".ja.euc"
|
|
53 elseif &enc =~ "utf-8$"
|
|
54 let s:ext = ".ja.utf-8"
|
|
55 else
|
|
56 let s:ext = ".ja.sjis"
|
|
57 endif
|
|
58 endif
|
|
59
|
|
60 " The korean tutor is available in two encodings, guess which one to use
|
|
61 if s:ext =~? '\.ko'
|
|
62 if &enc =~ "utf-8$"
|
|
63 let s:ext = ".ko.utf-8"
|
|
64 else
|
|
65 let s:ext = ".ko.euc"
|
|
66 endif
|
|
67 endif
|
|
68
|
|
69 " The Chinese tutor is available in two encodings, guess which one to use
|
|
70 " This segment is from the above lines and modified by
|
|
71 " Mendel L Chan <beos@turbolinux.com.cn> for Chinese vim tutorial
|
|
72 if s:ext =~? '\.zh'
|
|
73 if &enc =~ 'big5\|cp950'
|
|
74 let s:ext = ".zh.big5"
|
|
75 else
|
|
76 let s:ext = ".zh.euc"
|
|
77 endif
|
|
78 endif
|
|
79
|
|
80 " The Polish tutor is available in two encodings, guess which one to use.
|
|
81 if s:ext =~? '\.pl'
|
|
82 if &enc =~ 1250
|
|
83 let s:ext = ".pl.cp1250"
|
|
84 elseif &enc =~ "utf-8$"
|
|
85 let s:ext = ".pl.utf-8"
|
|
86 endif
|
|
87 endif
|
|
88
|
|
89 " The Turkish tutor is available in two encodings, guess which one to use
|
|
90 if s:ext =~? '\.tr'
|
|
91 if &enc == "utf-8"
|
|
92 let s:ext = ".tr.utf-8"
|
|
93 elseif &enc == "iso-8859-9"
|
|
94 let s:ext = ".tr.iso9"
|
|
95 endif
|
|
96 endif
|
|
97
|
|
98 " The Greek tutor is available in three encodings, guess what to use.
|
|
99 " We used ".gr" (Greece) instead of ".el" (Greek); accept both.
|
|
100 if s:ext =~? '\.gr\|\.el'
|
|
101 if &enc == "iso-8859-7"
|
|
102 let s:ext = ".gr"
|
|
103 elseif &enc == "utf-8"
|
|
104 let s:ext = ".gr.utf-8"
|
|
105 elseif &enc =~ 737
|
|
106 let s:ext = ".gr.cp737"
|
|
107 endif
|
|
108 endif
|
|
109
|
|
110 " The Slovak tutor is available in three encodings, guess which one to use
|
|
111 if s:ext =~? '\.sk'
|
|
112 if &enc == 'utf-8'
|
|
113 let s:ext = ".sk.utf-8"
|
|
114 elseif &enc =~ 1250
|
|
115 let s:ext = ".sk.cp1250"
|
|
116 endif
|
|
117 endif
|
|
118
|
|
119 " The Czech tutor is available in three encodings, guess which one to use
|
|
120 if s:ext =~? '\.cs'
|
|
121 if &enc == 'utf-8'
|
|
122 let s:ext = ".cs.utf-8"
|
|
123 elseif &enc =~ 1250
|
|
124 let s:ext = ".cs.cp1250"
|
|
125 endif
|
|
126 endif
|
|
127
|
|
128 " The Russian tutor is available in three encodings, guess which one to use.
|
|
129 if s:ext =~? '\.ru'
|
|
130 if &enc == 'utf-8'
|
|
131 let s:ext = '.ru.utf-8'
|
|
132 elseif &enc =~ '1251'
|
|
133 let s:ext = '.ru.cp1251'
|
|
134 elseif &enc =~ 'koi8'
|
|
135 let s:ext = '.ru'
|
|
136 endif
|
|
137 endif
|
|
138
|
|
139 " The Hungarian tutor is available in two encodings, guess which one to use.
|
|
140 if s:ext =~? '\.hu'
|
|
141 if &enc == 'utf-8'
|
|
142 let s:ext = '.hu.utf-8'
|
|
143 elseif &enc =~ 'iso-8859-2'
|
|
144 let s:ext = '.hu'
|
|
145 endif
|
|
146 endif
|
|
147
|
|
148 " Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch).
|
|
149 if s:ext =~? '\.ge'
|
|
150 let s:ext = ".de"
|
|
151 endif
|
|
152
|
|
153 if s:ext =~? '\.en'
|
|
154 let s:ext = ""
|
|
155 endif
|
|
156
|
|
157 " 2. Build the name of the file:
|
|
158 let s:tutorfile = "/tutor/tutor"
|
|
159 let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext
|
|
160
|
|
161 " 3. Finding the file:
|
|
162 if filereadable(s:tutorxx)
|
|
163 let $TUTOR = s:tutorxx
|
|
164 else
|
|
165 let $TUTOR = $VIMRUNTIME . s:tutorfile
|
|
166 echo "The file " . s:tutorxx . " does not exist.\n"
|
|
167 echo "Copying English version: " . $TUTOR
|
|
168 4sleep
|
|
169 endif
|
|
170
|
|
171 " 4. Making the copy and exiting Vim:
|
|
172 e $TUTOR
|
|
173 wq! $TUTORCOPY
|