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