Mercurial > vim
annotate runtime/doc/mlang.txt @ 15759:fa2b1f8d6203
Added tag v8.1.0886 for changeset 675dd5d7afb3a4ba19035a6469e0206da70635d7
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 Feb 2019 22:00:08 +0100 |
parents | 35aff6b8a2c7 |
children | 0e473e9e70c2 |
rev | line source |
---|---|
13963 | 1 *mlang.txt* For Vim version 8.1. Last change: 2018 May 06 |
7 | 2 |
3 | |
4 VIM REFERENCE MANUAL by Bram Moolenaar | |
5 | |
6 | |
7 Multi-language features *multilang* *multi-lang* | |
8 | |
9 This is about using messages and menus in various languages. For editing | |
10 multi-byte text see |multibyte|. | |
11 | |
12 The basics are explained in the user manual: |usr_45.txt|. | |
13 | |
14 1. Messages |multilang-messages| | |
15 2. Menus |multilang-menus| | |
16 3. Scripts |multilang-scripts| | |
17 | |
18 Also see |help-translated| for multi-language help. | |
19 | |
20 {Vi does not have any of these features} | |
21 {not available when compiled without the |+multi_lang| feature} | |
22 | |
23 ============================================================================== | |
24 1. Messages *multilang-messages* | |
25 | |
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. | |
28 | |
29 To see a list of supported locale names on your system, look in one of these | |
30 directories (for Unix): | |
31 /usr/lib/locale ~ | |
32 /usr/share/locale ~ | |
33 Unfortunately, upper/lowercase differences matter. Also watch out for the | |
34 use of "-" and "_". | |
35 | |
36 *:lan* *:lang* *:language* *E197* | |
37 :lan[guage] | |
38 :lan[guage] mes[sages] | |
39 :lan[guage] cty[pe] | |
40 :lan[guage] tim[e] | |
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. | |
52 | |
53 :lan[guage] {name} | |
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 | |
2348
8878a9f8db87
Rename w_p_conceal to w_p_conc for consistency.
Bram Moolenaar <bram@vim.org>
parents:
2345
diff
changeset
|
61 like "en_US.ISO_8859-1". On Unix systems you can use |
3281 | 62 this command to see what locales are supported: > |
2348
8878a9f8db87
Rename w_p_conceal to w_p_conc for consistency.
Bram Moolenaar <bram@vim.org>
parents:
2345
diff
changeset
|
63 :!locale -a |
8878a9f8db87
Rename w_p_conceal to w_p_conc for consistency.
Bram Moolenaar <bram@vim.org>
parents:
2345
diff
changeset
|
64 < With the "messages" argument the language used for |
7 | 65 messages is set. This can be different when you want, |
66 for example, English messages while editing Japanese | |
67 text. This sets $LC_MESSAGES. | |
68 With the "ctype" argument the language used for | |
69 character encoding is set. This affects the libraries | |
70 that Vim was linked with. It's unusual to set this to | |
2681 | 71 a different value from 'encoding' or "C". This sets |
7 | 72 $LC_CTYPE. |
73 With the "time" argument the language used for time | |
74 and date messages is set. This affects strftime(). | |
75 This sets $LC_TIME. | |
76 Without an argument both are set, and additionally | |
77 $LANG is set. | |
1619 | 78 When compiled with the |+float| feature the LC_NUMERIC |
79 value will always be set to "C", so that floating | |
80 point numbers use '.' as the decimal point. | |
7 | 81 This will make a difference for items that depend on |
82 the language (some messages, time and date format). | |
83 Not fully supported on all systems | |
84 If this fails there will be an error message. If it | |
85 succeeds there is no message. Example: > | |
86 :language | |
87 Current language: C | |
88 :language de_DE.ISO_8859-1 | |
89 :language mes | |
90 Current messages language: de_DE.ISO_8859-1 | |
91 :lang mes en | |
92 < | |
93 | |
94 MS-WINDOWS MESSAGE TRANSLATIONS *win32-gettext* | |
95 | |
96 If you used the self-installing .exe file, message translations should work | |
97 already. Otherwise get the libintl.dll file if you don't have it yet: | |
98 | |
99 http://sourceforge.net/projects/gettext | |
7659
07f11de5efca
commit https://github.com/vim/vim/commit/85084ef1e999dcf50e8d466106a33bac24a0febb
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
100 Or: |
07f11de5efca
commit https://github.com/vim/vim/commit/85084ef1e999dcf50e8d466106a33bac24a0febb
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
101 https://mlocati.github.io/gettext-iconv-windows/ |
7 | 102 |
103 This also contains tools xgettext, msgformat and others. | |
104 | |
14881
35aff6b8a2c7
patch 8.1.0452: MS-Windows: not finding intl.dll
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
105 libintl.dll should be placed in same directory as (g)vim.exe, or one of the |
35aff6b8a2c7
patch 8.1.0452: MS-Windows: not finding intl.dll
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
106 directories listed in the PATH environment value. Vim also looks for the |
35aff6b8a2c7
patch 8.1.0452: MS-Windows: not finding intl.dll
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
107 alternate names "libintl-8.dll" and "intl.dll". |
35aff6b8a2c7
patch 8.1.0452: MS-Windows: not finding intl.dll
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
108 |
7659
07f11de5efca
commit https://github.com/vim/vim/commit/85084ef1e999dcf50e8d466106a33bac24a0febb
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
109 Message files (vim.mo) have to be placed in "$VIMRUNTIME/lang/xx/LC_MESSAGES", |
07f11de5efca
commit https://github.com/vim/vim/commit/85084ef1e999dcf50e8d466106a33bac24a0febb
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
110 where "xx" is the abbreviation of the language (mostly two letters). |
7 | 111 |
112 If you write your own translations you need to generate the .po file and | |
113 convert it to a .mo file. You need to get the source distribution and read | |
114 the file "src/po/README.txt". | |
115 | |
116 To overrule the automatic choice of the language, set the $LANG variable to | |
117 the language of your choice. use "en" to disable translations. > | |
118 | |
119 :let $LANG = 'ja' | |
120 | |
121 (text for Windows by Muraoka Taro) | |
122 | |
123 ============================================================================== | |
124 2. Menus *multilang-menus* | |
125 | |
1121 | 126 See |45.2| for the basics, esp. using 'langmenu'. |
7 | 127 |
128 Note that if changes have been made to the menus after the translation was | |
129 done, some of the menus may be shown in English. Please try contacting the | |
130 maintainer of the translation and ask him to update it. You can find the | |
131 name and e-mail address of the translator in | |
132 "$VIMRUNTIME/lang/menu_<lang>.vim". | |
133 | |
134 To set the font (or fontset) to use for the menus, use the |:highlight| | |
135 command. Example: > | |
136 | |
137 :highlight Menu font=k12,r12 | |
138 | |
139 | |
140 ALIAS LOCALE NAMES | |
141 | |
142 Unfortunately, the locale names are different on various systems, even though | |
143 they are for the same language and encoding. If you do not get the menu | |
144 translations you expected, check the output of this command: > | |
145 | |
146 echo v:lang | |
147 | |
148 Now check the "$VIMRUNTIME/lang" directory for menu translation files that use | |
149 a similar language. A difference in a "-" being a "_" already causes a file | |
150 not to be found! Another common difference to watch out for is "iso8859-1" | |
151 versus "iso_8859-1". Fortunately Vim makes all names lowercase, thus you | |
152 don't have to worry about case differences. Spaces are changed to | |
153 underscores, to avoid having to escape them. | |
154 | |
155 If you find a menu translation file for your language with a different name, | |
156 create a file in your own runtime directory to load that one. The name of | |
157 that file could be: > | |
158 | |
159 ~/.vim/lang/menu_<v:lang>.vim | |
160 | |
161 Check the 'runtimepath' option for directories which are searched. In that | |
162 file put a command to load the menu file with the other name: > | |
163 | |
164 runtime lang/menu_<other_lang>.vim | |
165 | |
166 | |
167 TRANSLATING MENUS | |
168 | |
169 If you want to do your own translations, you can use the |:menutrans| command, | |
170 explained below. It is recommended to put the translations for one language | |
171 in a Vim script. For a language that has no translation yet, please consider | |
172 becoming the maintainer and make your translations available to all Vim users. | |
173 Send an e-mail to the Vim maintainer <maintainer@vim.org>. | |
174 | |
175 *:menut* *:menutrans* *:menutranslate* | |
176 :menut[ranslate] clear | |
177 Clear all menu translations. | |
178 | |
179 :menut[ranslate] {english} {mylang} | |
180 Translate menu name {english} to {mylang}. All | |
181 special characters like "&" and "<Tab>" need to be | |
182 included. Spaces and dots need to be escaped with a | |
183 backslash, just like in other |:menu| commands. | |
11062 | 184 Case in {english} is ignored. |
7 | 185 |
186 See the $VIMRUNTIME/lang directory for examples. | |
187 | |
188 To try out your translations you first have to remove all menus. This is how | |
189 you can do it without restarting Vim: > | |
190 :source $VIMRUNTIME/delmenu.vim | |
191 :source <your-new-menu-file> | |
192 :source $VIMRUNTIME/menu.vim | |
193 | |
194 Each part of a menu path is translated separately. The result is that when | |
13857 | 195 "Help" is translated to "Hilfe" and "Overview" to "Überblick" then |
196 "Help.Overview" will be translated to "Hilfe.Überblick". | |
7 | 197 |
198 ============================================================================== | |
199 3. Scripts *multilang-scripts* | |
200 | |
201 In Vim scripts you can use the |v:lang| variable to get the current language | |
202 (locale). The default value is "C" or comes from the $LANG environment | |
203 variable. | |
204 | |
205 The following example shows how this variable is used in a simple way, to make | |
206 a message adapt to language preferences of the user, > | |
207 | |
208 :if v:lang =~ "de_DE" | |
209 : echo "Guten Morgen" | |
210 :else | |
211 : echo "Good morning" | |
212 :endif | |
213 < | |
214 | |
14421 | 215 vim:tw=78:sw=4:ts=8:noet:ft=help:norl: |