blob: e5fd85e2ecbe98d0234ca50edb334478e6f25100 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001TRANSLATING VIM MESSAGES
2
Bram Moolenaar41317732010-08-02 21:43:29 +02003This file explains how to create and maintain po files using a number of
4GnuWin packages. You will need gettext, libiconv and libexpat. As of
RestorerZ76ba7242024-01-22 20:28:12 +01005January 2024 the versions known to work are gettext 0.14.4, libiconv 1.9.2-1
6and expat 2.5.0. Gettext and libiconv can be found at:
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
Bram Moolenaar41317732010-08-02 21:43:29 +02008 http://gnuwin32.sourceforge.net/
9
10expat can be found at:
11
12 http://sourceforge.net/projects/expat/
RestorerZ76ba7242024-01-22 20:28:12 +010013or
14 https://github.com/libexpat/libexpat
Bram Moolenaar41317732010-08-02 21:43:29 +020015
16expat will install into its own directory. You should copy libexpat.dll into
17the bin directory created from the gettext/libiconv packages.
RestorerZe2146922023-11-23 20:58:32 +010018Or Michele Locati kindly provides precompiled binaries gettext 0.21 and
19iconv 1.16 for Windows on his site:
20
21 https://mlocati.github.io/articles/gettext-iconv-windows.html
22
Bram Moolenaar071d4272004-06-13 20:20:40 +000023First read the README.txt file in this directory for general remarks on
24translating Vim messages.
25
26
27SETUP
28
Bram Moolenaar9964e462007-05-05 17:54:07 +000029Set the environment variable LANGUAGE to the language code for the language
30you are translating Vim messages to. Language codes are typically two
31characters and you can find a list of them at:
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
RestorerZ76ba7242024-01-22 20:28:12 +010033 https://www.loc.gov/standards/iso639-2/php/code_list.php
34 https://www.science.co.il/language/Codes.php
35 https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
Bram Moolenaar071d4272004-06-13 20:20:40 +000036
RestorerZ76ba7242024-01-22 20:28:12 +010037Another possibility is to use the GnuWin32 port of gettext. This is
38recommended especially if you use already GnuWin32 tools to gunzip, bunzip,
39patch etc. these files. You find the GnuWin32 version of gettext here:
Bram Moolenaar9964e462007-05-05 17:54:07 +000040
41 http://gnuwin32.sourceforge.net/packages/gettext.htm
42
43Yet another very strait forward way is to get the sources of gettext from
44
45 http://www.gnu.org/software/gettext/gettext.html
46
RestorerZ76ba7242024-01-22 20:28:12 +010047and build your own version of these tools. The documentation states that this
Bram Moolenaar9964e462007-05-05 17:54:07 +000048should be possible with MSVC4.0, MSVC5.0, MSVC6.0 or MSVC7.0, but you can
49build it even successfully with MSVC8.0.
50
Bram Moolenaar071d4272004-06-13 20:20:40 +000051The LANGUAGE environment variable can be set from the command line, by adding
52a line to your autoexec.bat file, or by defining a user variable from the
RestorerZ76ba7242024-01-22 20:28:12 +010053Advanced tab in the System control panel. If the LANGUAGE environment
54variable has not been set in any of the above ways, the value of this variable
55will be set automatically according to the language used in the OS. This
56value will be valid until the "nmake.exe" program terminates.
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
58Next, edit Make_mvc.mak so that GETTEXT_PATH points the binary directory of
Bram Moolenaar9964e462007-05-05 17:54:07 +000059the installation.
Bram Moolenaar071d4272004-06-13 20:20:40 +000060
61
62CREATING A NEW TRANSLATION
63
64When creating a new translation you must add your language code to the
RestorerZ76ba7242024-01-22 20:28:12 +010065Make_all.mak file in the lines defining LANGUAGES and MOFILES, POFILES and
66CHECKFILES. If the encoding of the translation text differs from the default
67UTF-8, add a corresponding entry in MOCONVERTED, specifying the required
68encoding.
69To create the initial .po file for your language you must use the command:
Bram Moolenaar071d4272004-06-13 20:20:40 +000070
RestorerZ76ba7242024-01-22 20:28:12 +010071 nmake.exe -f Make_mvc.mak first_time
Bram Moolenaar071d4272004-06-13 20:20:40 +000072
73Note: You need to be in the po directory when using this makefile.
74
75Once you have your new .po file load it into Vim and source cleanup.vim, this
76will convert untranslated messages to comments. If you have syntax
77highlighting turned on then untranslated messages will stand out more easily.
78
79You will also need to edit the file names in the comments in the .po file.
80You need to remove the absolute directory specification (which has the form
RestorerZe2146922023-11-23 20:58:32 +010081c:\vim91\src\). You can do this in Vim with the following command with the
Bram Moolenaar9964e462007-05-05 17:54:07 +000082appropriate directory specification for where you have installed the Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000083source:
84
RestorerZe2146922023-11-23 20:58:32 +010085 %s/c:\\vim91\\src\\//g
Bram Moolenaar071d4272004-06-13 20:20:40 +000086
87
88UPDATING A TRANSLATION
89
90If there are new or changed messages in Vim that need translating, then the
91first thing to do is merge them into the existing translations. This is done
92with the following command:
93
RestorerZ76ba7242024-01-22 20:28:12 +010094 nmake.exe -f Make_mvc.mak xx
Bram Moolenaar071d4272004-06-13 20:20:40 +000095
Bram Moolenaar9964e462007-05-05 17:54:07 +000096where xx is the language code for the language needing translations. The
Bram Moolenaar071d4272004-06-13 20:20:40 +000097original .po file is copied to xx.po.orig.
98
99
100DOING THE TRANSLATION
101
102Now that you have a .po file you can do the translations for all messages that
103need it. See README.txt for specific instructions.
104
105Once you have finished translating the messages you should make sure all
106non-translated strings are commented out. This can be done by sourcing
107cleanup.vim once again.
108
109
110CHECKING THE TRANSLATION
111
112Check the translation with the following command:
113
RestorerZ76ba7242024-01-22 20:28:12 +0100114 nmake.exe -f Make_mvc.mak xx.ck
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115
RestorerZ76ba7242024-01-22 20:28:12 +0100116Correct any errors reported. When there are no more errors, the translation
117is ready to be installed.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000118
119
120INSTALLING THE TRANSLATION
121
122Install your translation with the following command:
123
RestorerZ76ba7242024-01-22 20:28:12 +0100124 nmake.exe -f Make_mvc.mak install
Bram Moolenaar071d4272004-06-13 20:20:40 +0000125
126This will create the xx\LC_MESSAGES directory in runtime\lang if it does not
127already exist.
Bram Moolenaar01380622015-12-29 16:04:42 +0100128You can also use the following command to install all languages:
129
RestorerZ76ba7242024-01-22 20:28:12 +0100130 nmake.exe -f Make_mvc.mak install-all
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131
132
RestorerZ76ba7242024-01-22 20:28:12 +0100133AFTER ALL OF THESE STEPS
134
135Clean the "po" directory of all temporary and unnecessary files. Execute the
136command:
137
138 nmake.exe -f Make_mvc.mak clean
139
RestorerZ96509102024-07-11 21:14:15 +0200140
141TRANSLATION OF VIM THE EDITOR PLUG-INS
142
143Vim supports displaying plugin messages for various native languages.
144Translation is available both for plugins that are supplied as part of the Vim
145editor (e.g. "optwin.vim") and for third-party plugin packages.
146
147To translate the plugins supplied with the Vim editor, you must specify a
148gettext() function call for the strings you want to translate.
149The translation of these strings will be retrieved by gettext() from the MO
150file "vim.mo".
151
152For third-party plugins, it is necessary to specify a one-time call to the
153bindtextdomain() function in scripts containing translation strings and for
154all message strings to add a {package} argument to the gettext() function. For
155more information, see ":help package-translation".
156
157
Bram Moolenaar071d4272004-06-13 20:20:40 +0000158vim:tw=78: