0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/tutor/tutor.vim

87 lines
2.4 KiB
VimL
Raw Normal View History

2004-06-13 20:20:40 +00:00
" Vim tutor support file
" Author: Eduardo F. Amatria <eferna1@platea.pntic.mec.es>
" Maintainer: The·Vim·Project·<https://github.com/vim/vim>
" Last Change: 2025 Jun 20
2004-06-13 20:20:40 +00:00
2008-08-06 17:06:04 +00:00
" This Vim script is used for detecting if a translation of the
2004-06-13 20:20:40 +00:00
" 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,
2018-04-20 22:36:41 +02:00
" it defaults to the English version.
2004-06-13 20:20:40 +00:00
" 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
2004-06-13 20:20:40 +00:00
else
let s:lang = ""
2006-03-18 21:40:56 +00:00
" Check that a potential value has at least two letters.
" Ignore "1043" and "C".
if exists("v:lang") && v:lang =~ '\a\a'
2004-06-13 20:20:40 +00:00
let s:lang = v:lang
2006-03-18 21:40:56 +00:00
elseif $LC_ALL =~ '\a\a'
2005-03-15 22:43:58 +00:00
let s:lang = $LC_ALL
elseif $LC_MESSAGES =~ '\a\a' || $LC_MESSAGES ==# "C"
" LC_MESSAGES=C can be used to explicitly ask for English messages while
" keeping LANG non-English; don't set s:lang then.
if $LC_MESSAGES =~ '\a\a'
let s:lang = $LC_MESSAGES
endif
2006-03-18 21:40:56 +00:00
elseif $LANG =~ '\a\a'
2004-06-13 20:20:40 +00:00
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"
2014-06-25 18:50:27 +02:00
elseif s:lang =~ "Serbian"
let s:ext = ".sr"
2007-05-06 13:26:41 +00:00
elseif s:lang =~ "Czech"
let s:ext = ".cs"
2006-03-18 21:40:56 +00:00
elseif s:lang =~ "Dutch"
let s:ext = ".nl"
2016-07-17 13:35:14 +02:00
elseif s:lang =~ "Bulgarian"
let s:ext = ".bg"
2004-06-13 20:20:40 +00:00
else
let s:ext = "." .. strpart(s:lang, 0, 2)
2004-06-13 20:20:40 +00:00
endif
endif
endif
2008-06-24 21:56:24 +00:00
" 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 and chapter
let s:chapter = exists("$CHAPTER") ? $CHAPTER : 1
let s:tutorfile = "/tutor/tutor" .. s:chapter
let s:tutorxx = $VIMRUNTIME .. s:tutorfile .. s:ext
2004-06-13 20:20:40 +00:00
" 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
2004-06-13 20:20:40 +00:00
4sleep
endif
" 4. Making the copy and exiting Vim:
e $TUTOR
wq! $TUTORCOPY