1 *mlang.txt* For Vim version 7.1. Last change: 2006 Jul 12
4 VIM REFERENCE MANUAL by Bram Moolenaar
7 Multi-language features *multilang* *multi-lang*
9 This is about using messages and menus in various languages. For editing
10 multi-byte text see |multibyte|.
12 The basics are explained in the user manual: |usr_45.txt|.
14 1. Messages |multilang-messages|
15 2. Menus |multilang-menus|
16 3. Scripts |multilang-scripts|
18 Also see |help-translated| for multi-language help.
20 {Vi does not have any of these features}
21 {not available when compiled without the |+multi_lang| feature}
23 ==============================================================================
24 1. Messages *multilang-messages*
26 Vim picks up the locale from the environment. In most cases this means Vim
27 will use the language that you prefer, unless it's not available.
29 To see a list of supported locale names on your system, look in one of these
30 directories (for Unix):
33 Unfortunately, upper/lowercase differences matter. Also watch out for the
36 *:lan* *:lang* *:language* *E197*
38 :lan[guage] mes[sages]
41 Print the current language (aka locale).
42 With the "messages" argument the language used for
43 messages is printed. Technical: LC_MESSAGES.
44 With the "ctype" argument the language used for
45 character encoding is printed. Technical: LC_CTYPE.
46 With the "time" argument the language used for
47 strftime() is printed. Technical: LC_TIME.
48 Without argument all parts of the locale are printed
49 (this is system dependent).
50 The current language can also be obtained with the
51 |v:lang|, |v:ctype| and |v:lc_time| variables.
54 :lan[guage] mes[sages] {name}
55 :lan[guage] cty[pe] {name}
56 :lan[guage] tim[e] {name}
57 Set the current language (aka locale) to {name}.
58 The locale {name} must be a valid locale on your
59 system. Some systems accept aliases like "en" or
60 "en_US", but some only accept the full specification
61 like "en_US.ISO_8859-1".
62 With the "messages" argument the language used for
63 messages is set. This can be different when you want,
64 for example, English messages while editing Japanese
65 text. This sets $LC_MESSAGES.
66 With the "ctype" argument the language used for
67 character encoding is set. This affects the libraries
68 that Vim was linked with. It's unusual to set this to
69 a different value from 'encoding'. This sets
71 With the "time" argument the language used for time
72 and date messages is set. This affects strftime().
74 Without an argument both are set, and additionally
76 This will make a difference for items that depend on
77 the language (some messages, time and date format).
78 Not fully supported on all systems
79 If this fails there will be an error message. If it
80 succeeds there is no message. Example: >
83 :language de_DE.ISO_8859-1
85 Current messages language: de_DE.ISO_8859-1
89 MS-WINDOWS MESSAGE TRANSLATIONS *win32-gettext*
91 If you used the self-installing .exe file, message translations should work
92 already. Otherwise get the libintl.dll file if you don't have it yet:
94 http://sourceforge.net/projects/gettext
96 This also contains tools xgettext, msgformat and others.
98 libintl.dll should be placed in same directory with (g)vim.exe, or some
99 place where PATH environment value describe. Message files (vim.mo)
100 have to be placed in "$VIMRUNTIME/lang/xx/LC_MESSAGES", where "xx" is the
101 abbreviation of the language (mostly two letters).
103 If you write your own translations you need to generate the .po file and
104 convert it to a .mo file. You need to get the source distribution and read
105 the file "src/po/README.txt".
107 To overrule the automatic choice of the language, set the $LANG variable to
108 the language of your choice. use "en" to disable translations. >
112 (text for Windows by Muraoka Taro)
114 ==============================================================================
115 2. Menus *multilang-menus*
117 See |45.2| for the basics, esp. using 'langmenu'.
119 Note that if changes have been made to the menus after the translation was
120 done, some of the menus may be shown in English. Please try contacting the
121 maintainer of the translation and ask him to update it. You can find the
122 name and e-mail address of the translator in
123 "$VIMRUNTIME/lang/menu_<lang>.vim".
125 To set the font (or fontset) to use for the menus, use the |:highlight|
128 :highlight Menu font=k12,r12
133 Unfortunately, the locale names are different on various systems, even though
134 they are for the same language and encoding. If you do not get the menu
135 translations you expected, check the output of this command: >
139 Now check the "$VIMRUNTIME/lang" directory for menu translation files that use
140 a similar language. A difference in a "-" being a "_" already causes a file
141 not to be found! Another common difference to watch out for is "iso8859-1"
142 versus "iso_8859-1". Fortunately Vim makes all names lowercase, thus you
143 don't have to worry about case differences. Spaces are changed to
144 underscores, to avoid having to escape them.
146 If you find a menu translation file for your language with a different name,
147 create a file in your own runtime directory to load that one. The name of
148 that file could be: >
150 ~/.vim/lang/menu_<v:lang>.vim
152 Check the 'runtimepath' option for directories which are searched. In that
153 file put a command to load the menu file with the other name: >
155 runtime lang/menu_<other_lang>.vim
160 If you want to do your own translations, you can use the |:menutrans| command,
161 explained below. It is recommended to put the translations for one language
162 in a Vim script. For a language that has no translation yet, please consider
163 becoming the maintainer and make your translations available to all Vim users.
164 Send an e-mail to the Vim maintainer <maintainer@vim.org>.
166 *:menut* *:menutrans* *:menutranslate*
167 :menut[ranslate] clear
168 Clear all menu translations.
170 :menut[ranslate] {english} {mylang}
171 Translate menu name {english} to {mylang}. All
172 special characters like "&" and "<Tab>" need to be
173 included. Spaces and dots need to be escaped with a
174 backslash, just like in other |:menu| commands.
176 See the $VIMRUNTIME/lang directory for examples.
178 To try out your translations you first have to remove all menus. This is how
179 you can do it without restarting Vim: >
180 :source $VIMRUNTIME/delmenu.vim
181 :source <your-new-menu-file>
182 :source $VIMRUNTIME/menu.vim
184 Each part of a menu path is translated separately. The result is that when
185 "Help" is translated to "Hilfe" and "Overview" to "Überblick" then
186 "Help.Overview" will be translated to "Hilfe.Überblick".
188 ==============================================================================
189 3. Scripts *multilang-scripts*
191 In Vim scripts you can use the |v:lang| variable to get the current language
192 (locale). The default value is "C" or comes from the $LANG environment
195 The following example shows how this variable is used in a simple way, to make
196 a message adapt to language preferences of the user, >
198 :if v:lang =~ "de_DE"
199 : echo "Guten Morgen"
201 : echo "Good morning"
205 vim:tw=78:sw=4:ts=8:ft=help:norl: