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