7
|
1 " Vim tutor support file
|
|
2 " Author: Eduardo F. Amatria <eferna1@platea.pntic.mec.es>
|
205
|
3 " Last Change: 2005 Mar 15
|
7
|
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 = ""
|
205
|
18 if exists("v:lang")
|
7
|
19 let s:lang = v:lang
|
205
|
20 elseif strlen($LC_ALL) > 0
|
|
21 let s:lang = $LC_ALL
|
|
22 elseif strlen($LANG) > 0
|
7
|
23 let s:lang = $LANG
|
|
24 endif
|
205
|
25 if s:lang == "C"
|
|
26 let s:lang = ""
|
|
27 endif
|
7
|
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
|
|
43 endif
|
|
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.
|
|
47 if 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
|
|
55 endif
|
|
56
|
|
57 " The korean tutor is available in two encodings, guess which one to use
|
|
58 if 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
|
|
64 endif
|
|
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 <beos@turbolinux.com.cn> for Chinese vim tutorial
|
|
69 if s:ext =~? '\.zh'
|
|
70 if &enc =~ 'big5\|cp950'
|
|
71 let s:ext = ".zh.big5"
|
|
72 else
|
|
73 let s:ext = ".zh.euc"
|
|
74 endif
|
|
75 endif
|
|
76
|
|
77 " The Polish tutor is available in two encodings, guess which one to use.
|
24
|
78 if 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
|
7
|
84 endif
|
|
85
|
|
86 " The Greek tutor is available in two encodings, guess which one to use
|
|
87 if s:ext =~? '\.gr' && &enc =~ 737
|
|
88 let s:ext = ".gr.cp737"
|
|
89 endif
|
|
90
|
|
91 " The Slovak tutor is available in two encodings, guess which one to use
|
|
92 if s:ext =~? '\.sk' && &enc =~ 1250
|
|
93 let s:ext = ".sk.cp1250"
|
|
94 endif
|
|
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 <raorn@altlinux.org> for Russian vim tutorial
|
|
99 if s:ext =~? '\.ru' && &enc =~ 1251
|
|
100 let s:ext = ".ru.cp1251"
|
|
101 endif
|
|
102
|
|
103 " Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch).
|
|
104 if s:ext =~? '\.ge'
|
|
105 let s:ext = ".de"
|
|
106 endif
|
|
107
|
|
108 if s:ext =~? '\.en'
|
|
109 let s:ext = ""
|
|
110 endif
|
|
111
|
|
112 " 2. Build the name of the file:
|
|
113 let s:tutorfile = "/tutor/tutor"
|
|
114 let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext
|
|
115
|
|
116 " 3. Finding the file:
|
|
117 if filereadable(s:tutorxx)
|
|
118 let $TUTOR = s:tutorxx
|
|
119 else
|
|
120 let $TUTOR = $VIMRUNTIME . s:tutorfile
|
|
121 echo "The file " . s:tutorxx . " does not exist.\n"
|
|
122 echo "Copying English version: " . $TUTOR
|
|
123 4sleep
|
|
124 endif
|
|
125
|
|
126 " 4. Making the copy and exiting Vim:
|
|
127 e $TUTOR
|
|
128 wq! $TUTORCOPY
|