annotate runtime/tutor/tutor.vim @ 216:da182deebec7

updated for version 7.0061
author vimboss
date Fri, 18 Mar 2005 20:25:31 +0000
parents d292c40ca788
children 862863033fdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim tutor support file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Author: Eduardo F. Amatria <eferna1@platea.pntic.mec.es>
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
3 " Last Change: 2005 Mar 15
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " This small source file is used for detecting if a translation of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " tutor file exist, i.e., a tutor.xx file, where xx is the language.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " If the translation does not exist, or no extension is given,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " it defaults to the english version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " It is invoked by the vimtutor shell script.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " 1. Build the extension of the file, if any:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 let s:ext = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 if strlen($xx) > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 let s:ext = "." . $xx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 let s:lang = ""
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
18 if exists("v:lang")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 let s:lang = v:lang
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
20 elseif strlen($LC_ALL) > 0
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
21 let s:lang = $LC_ALL
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
22 elseif strlen($LANG) > 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 let s:lang = $LANG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 endif
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
25 if s:lang == "C"
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
26 let s:lang = ""
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
27 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if s:lang != ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Remove "@euro" (ignoring case), it may be at the end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let s:lang = substitute(s:lang, '\c@euro', '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " On MS-Windows it may be German_Germany.1252 or Polish_Poland.1250. How
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " about other languages?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if s:lang =~ "German"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let s:ext = ".de"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 elseif s:lang =~ "Polish"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let s:ext = ".pl"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 elseif s:lang =~ "Slovak"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let s:ext = ".sk"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let s:ext = "." . strpart(s:lang, 0, 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " The japanese tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " The "sjis" one is actually "cp932", it doesn't matter for this text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if s:ext =~? '\.ja'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if &enc =~ "euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 let s:ext = ".ja.euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 elseif &enc =~ "utf-8$"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 let s:ext = ".ja.utf-8"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 let s:ext = ".ja.sjis"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 " The korean tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 if s:ext =~? '\.ko'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 if &enc =~ "utf-8$"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 let s:ext = ".ko.utf-8"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let s:ext = ".ko.euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " The Chinese tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 " This segment is from the above lines and modified by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " Mendel L Chan <beos@turbolinux.com.cn> for Chinese vim tutorial
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if s:ext =~? '\.zh'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 if &enc =~ 'big5\|cp950'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 let s:ext = ".zh.big5"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 let s:ext = ".zh.euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " The Polish tutor is available in two encodings, guess which one to use.
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
78 if s:ext =~? '\.pl'
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
79 if &enc =~ 1250
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
80 let s:ext = ".pl.cp1250"
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
81 elseif &enc =~ "utf-8$"
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
82 let s:ext = ".pl.utf-8"
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
83 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 " The Greek tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 if s:ext =~? '\.gr' && &enc =~ 737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 let s:ext = ".gr.cp737"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 " The Slovak tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 if s:ext =~? '\.sk' && &enc =~ 1250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 let s:ext = ".sk.cp1250"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 " The Russian tutor is available in two encodings, guess which one to use.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 " This segment is from the above lines and modified by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 " Alexey I. Froloff <raorn@altlinux.org> for Russian vim tutorial
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 if s:ext =~? '\.ru' && &enc =~ 1251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 let s:ext = ".ru.cp1251"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 " Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 if s:ext =~? '\.ge'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 let s:ext = ".de"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 if s:ext =~? '\.en'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 let s:ext = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 " 2. Build the name of the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 let s:tutorfile = "/tutor/tutor"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 " 3. Finding the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 if filereadable(s:tutorxx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 let $TUTOR = s:tutorxx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 let $TUTOR = $VIMRUNTIME . s:tutorfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 echo "The file " . s:tutorxx . " does not exist.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 echo "Copying English version: " . $TUTOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 4sleep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 " 4. Making the copy and exiting Vim:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 e $TUTOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 wq! $TUTORCOPY