blob: 5a09d1f543e67006c1bb8e8ff5a7c878ff9f834b [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001TRANSLATING VIM MESSAGES
2
3In this directory you will find xx.po files, where "xx" is a language code.
4Each file contains the translation of English Vim messages for one language.
5The files are in "po" format, used by the gettext package. Please refer to
6the gettext documentation for more information.
7
8The GNU gettext library, starting with version 0.10.37, supports converting
9messages from one encoding to another. This requires that it was compiled
10with HAVE_ICONV. The result is that the messages may be in any encoding
11supported by iconv and will be automatically converted to the currently used
12encoding.
13
14The GNU gettext library, starting with version 0.10.36, uses a new format for
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000015some encodings. This follows the C99 standard for strings. It means that
16when a multi-byte character includes the 0x5c byte, this is not recognized as
17a backslash. Since this format is incompatible with Solaris, Vim uses the old
Bram Moolenaar071d4272004-06-13 20:20:40 +000018format. This is done by setting the OLD_PO_FILE_OUTPUT and OLD_PO_FILE_INPUT
19environment variables. When you use the Makefile in this directory that will
20be done for you. This does NOT work with gettext 0.10.36. Don't use it, get
210.10.37.
22
Bram Moolenaare1dc76f2022-06-25 18:01:32 +010023Have a look at these helper scripts, they may be useful for you:
24https://github.com/adaext/vim-menutrans-helper
25
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
27ON MS-WINDOWS
28
29The distributed files are generated on Unix, but this should also be possible
30on MS-Windows. Download the gettext packages, for example from:
31
32 http://sourceforge.net/projects/gettext
RestorerZe2146922023-11-23 20:58:32 +010033 or
34 https://mlocati.github.io/articles/gettext-iconv-windows.html
Bram Moolenaar071d4272004-06-13 20:20:40 +000035
36You might have to do the commands manually. Example:
37
RestorerZe2146922023-11-23 20:58:32 +010038 cd c:\vim\vim91
Bram Moolenaar071d4272004-06-13 20:20:40 +000039 mkdir runtime\lang\ja\LC_MESSAGES
40 msgfmt -o runtime\lang\ja\LC_MESSAGES\vim.mo src\po\ja.po
41
42
43WHEN THERE IS A MISTAKE
44
45If you find there is a mistake in one of the translations, please report this
Christian Brabandtee17b6f2023-09-09 11:23:50 +020046to the maintainer of the translation. His/her e-mail address is in the
Bram Moolenaar071d4272004-06-13 20:20:40 +000047comments at the start of the file. You can also see this with the ":messages"
48command in Vim when the translation is being used.
49
50
51CREATING A NEW PO FILE
52
53We will use "xx.po" as an example here, replace "xx" with the name of your
54language.
55
RestorerZe2146922023-11-23 20:58:32 +010056- Edit Make_all.mak to add xx to LANGUAGES and xx.mo to MOFILES.
Bram Moolenaard2f3a8b2018-06-19 14:35:59 +020057- If you haven't done so already, run ./configure in the top vim directory
58 (i.e. go up two directories) and then come back here afterwards.
59- Execute these commands:
60 % make vim.pot
61 % msginit -l xx
62 % rm vim.pot
63 The first command will generate a vim.pot file which is used by msginit to
64 generate a correct xx.po file. After that vim.pot is not needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000065- The remaining work is like updating, see the next section.
66
67
68UPDATING A PO FILE
69
70If you are the maintainer of a .po file, this is how you update the file. We
71will use "xx.po" as an example here, replace "xx" with the name of your
72language.
73
74(1) Add new and changed messages from the Vim sources:
75
76 make xx
77
78 This will extract all the strings from Vim and merge them in with the
Bram Moolenaar56b45b92013-06-24 22:22:18 +020079 existing translations. Requires the GNU gettext utilities.
Bram Moolenaar071d4272004-06-13 20:20:40 +000080 Your original xx.po file will be copied to xx.po.orig
81
82 -- After you do this, you MUST do the next three steps! --
83
84(2) Translate
85 See the gettext documentation on how to do this. You can also find
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +020086 examples in the other po files. You can use "gF" on the file name to see
87 the context of the message.
Bram Moolenaar071d4272004-06-13 20:20:40 +000088 Search the po file for items that require translation:
89
90 /fuzzy\|^msgstr ""\(\n"\)\@!
91
92 Remove the "#, fuzzy" line after adding the translation.
93
94 There is one special message:
Christian Brabandte978b452023-08-13 10:33:05 +020095 msgid "Messages maintainer: The Vim Project"
Bram Moolenaar071d4272004-06-13 20:20:40 +000096 You should include your name and E-mail address instead, for example:
97 msgstr "Berichten übersetzt bei: John Doe <john@doe.org>"
98
Bram Moolenaaraaef1ba2017-08-01 17:40:23 +020099(3) Remove unused messages (optional)
Bram Moolenaarfa573352020-09-04 13:53:00 +0200100 Remove messages that have been marked as obsolete.
Bram Moolenaaraaef1ba2017-08-01 17:40:23 +0200101 Such messages start with "#~".
102
103 The cleanup script will also do that (see next step).
104
105(4) Clean up
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106 This is very important to make sure the translation works on all systems.
107 Comment-out all non-translated strings. There are two types:
108 - items marked with "#, fuzzy"
109 - items with an empty msgstr
110 You can do this with the cleanup.vim script:
111
112 :source cleanup.vim
113
114 Background: on Solaris an empty msgstr results in an empty message; GNU
115 gettext ignores empty strings and items marked with "#, fuzzy".
116
Bram Moolenaar4be06f92005-07-29 22:36:03 +0000117 This also removes the line numbers from the file, so that patches are not
118 messed up by changes in line numbers and show the actual changes in the
119 text.
120
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200121(5) Check:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000122
Bram Moolenaar74675a62017-07-15 13:53:23 +0200123 While editing the .po file:
124 :source check.vim
125
126 From the command line:
Bram Moolenaar58d98232005-07-23 22:25:46 +0000127 vim -S check.vim xx.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128 make xx.mo
129
130 Look out for syntax errors and fix them.
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200131
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +0200132(6) Local tryout:
133 Vim normally picks up the .mo files from:
134 $VIMRUNTIME/lang/{lang}/LC_MESSAGES/vim.mo
135 To try out the messages with Vim use:
Bram Moolenaarfa573352020-09-04 13:53:00 +0200136 make tryoutinstall
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +0200137 And run Vim with $VIMRUNTIME set to ../runtime
138
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200139
140USING GETTEXT WITHOUT ICONV
141
142When using gettext which doesn't support iconv, the encoding of the .mo file
143must match your active encoding. For that you must convert and change
144encoding of *.po file in advance of generating the *.mo file. For example, to
145convert ja.po to EUC-JP (supposed as your system encoding):
146
147(1) Convert the file encoding:
148
149 mv ja.po ja.po.orig
150 iconv -f utf-8 -t euc-jp ja.po.orig > ja.po
151
152(2) Rewrite charset declaration in the file:
153
154 Open ja.po find this line:
155 "Content-Type: text/plain; charset=utf-8\n"
156 You should change "charset" like this:
157 "Content-Type: text/plain; charset=euc-jp\n"
158
159There are examples in the Makefile for the conversions already supported.