Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | TRANSLATING VIM MESSAGES |
| 2 | |
Bram Moolenaar | 4131773 | 2010-08-02 21:43:29 +0200 | [diff] [blame] | 3 | This file explains how to create and maintain po files using a number of |
| 4 | GnuWin packages. You will need gettext, libiconv and libexpat. As of |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 5 | January 2024 the versions known to work are gettext 0.14.4, libiconv 1.9.2-1 |
| 6 | and expat 2.5.0. Gettext and libiconv can be found at: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7 | |
Bram Moolenaar | 4131773 | 2010-08-02 21:43:29 +0200 | [diff] [blame] | 8 | http://gnuwin32.sourceforge.net/ |
| 9 | |
| 10 | expat can be found at: |
| 11 | |
| 12 | http://sourceforge.net/projects/expat/ |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 13 | or |
| 14 | https://github.com/libexpat/libexpat |
Bram Moolenaar | 4131773 | 2010-08-02 21:43:29 +0200 | [diff] [blame] | 15 | |
| 16 | expat will install into its own directory. You should copy libexpat.dll into |
| 17 | the bin directory created from the gettext/libiconv packages. |
RestorerZ | e214692 | 2023-11-23 20:58:32 +0100 | [diff] [blame] | 18 | Or Michele Locati kindly provides precompiled binaries gettext 0.21 and |
| 19 | iconv 1.16 for Windows on his site: |
| 20 | |
| 21 | https://mlocati.github.io/articles/gettext-iconv-windows.html |
| 22 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 23 | First read the README.txt file in this directory for general remarks on |
| 24 | translating Vim messages. |
| 25 | |
| 26 | |
| 27 | SETUP |
| 28 | |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 29 | Set the environment variable LANGUAGE to the language code for the language |
| 30 | you are translating Vim messages to. Language codes are typically two |
| 31 | characters and you can find a list of them at: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 32 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 33 | 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 36 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 37 | Another possibility is to use the GnuWin32 port of gettext. This is |
| 38 | recommended especially if you use already GnuWin32 tools to gunzip, bunzip, |
| 39 | patch etc. these files. You find the GnuWin32 version of gettext here: |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 40 | |
| 41 | http://gnuwin32.sourceforge.net/packages/gettext.htm |
| 42 | |
| 43 | Yet another very strait forward way is to get the sources of gettext from |
| 44 | |
| 45 | http://www.gnu.org/software/gettext/gettext.html |
| 46 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 47 | and build your own version of these tools. The documentation states that this |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 48 | should be possible with MSVC4.0, MSVC5.0, MSVC6.0 or MSVC7.0, but you can |
| 49 | build it even successfully with MSVC8.0. |
| 50 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 51 | The LANGUAGE environment variable can be set from the command line, by adding |
| 52 | a line to your autoexec.bat file, or by defining a user variable from the |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 53 | Advanced tab in the System control panel. If the LANGUAGE environment |
| 54 | variable has not been set in any of the above ways, the value of this variable |
| 55 | will be set automatically according to the language used in the OS. This |
| 56 | value will be valid until the "nmake.exe" program terminates. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 57 | |
| 58 | Next, edit Make_mvc.mak so that GETTEXT_PATH points the binary directory of |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 59 | the installation. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 60 | |
| 61 | |
| 62 | CREATING A NEW TRANSLATION |
| 63 | |
| 64 | When creating a new translation you must add your language code to the |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 65 | Make_all.mak file in the lines defining LANGUAGES and MOFILES, POFILES and |
| 66 | CHECKFILES. If the encoding of the translation text differs from the default |
| 67 | UTF-8, add a corresponding entry in MOCONVERTED, specifying the required |
| 68 | encoding. |
| 69 | To create the initial .po file for your language you must use the command: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 70 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 71 | nmake.exe -f Make_mvc.mak first_time |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 72 | |
| 73 | Note: You need to be in the po directory when using this makefile. |
| 74 | |
| 75 | Once you have your new .po file load it into Vim and source cleanup.vim, this |
| 76 | will convert untranslated messages to comments. If you have syntax |
| 77 | highlighting turned on then untranslated messages will stand out more easily. |
| 78 | |
| 79 | You will also need to edit the file names in the comments in the .po file. |
| 80 | You need to remove the absolute directory specification (which has the form |
RestorerZ | e214692 | 2023-11-23 20:58:32 +0100 | [diff] [blame] | 81 | c:\vim91\src\). You can do this in Vim with the following command with the |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 82 | appropriate directory specification for where you have installed the Vim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 83 | source: |
| 84 | |
RestorerZ | e214692 | 2023-11-23 20:58:32 +0100 | [diff] [blame] | 85 | %s/c:\\vim91\\src\\//g |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 86 | |
| 87 | |
| 88 | UPDATING A TRANSLATION |
| 89 | |
| 90 | If there are new or changed messages in Vim that need translating, then the |
| 91 | first thing to do is merge them into the existing translations. This is done |
| 92 | with the following command: |
| 93 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 94 | nmake.exe -f Make_mvc.mak xx |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 95 | |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 96 | where xx is the language code for the language needing translations. The |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 97 | original .po file is copied to xx.po.orig. |
| 98 | |
| 99 | |
| 100 | DOING THE TRANSLATION |
| 101 | |
| 102 | Now that you have a .po file you can do the translations for all messages that |
| 103 | need it. See README.txt for specific instructions. |
| 104 | |
| 105 | Once you have finished translating the messages you should make sure all |
| 106 | non-translated strings are commented out. This can be done by sourcing |
| 107 | cleanup.vim once again. |
| 108 | |
| 109 | |
| 110 | CHECKING THE TRANSLATION |
| 111 | |
| 112 | Check the translation with the following command: |
| 113 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 114 | nmake.exe -f Make_mvc.mak xx.ck |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 115 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 116 | Correct any errors reported. When there are no more errors, the translation |
| 117 | is ready to be installed. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 118 | |
| 119 | |
| 120 | INSTALLING THE TRANSLATION |
| 121 | |
| 122 | Install your translation with the following command: |
| 123 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 124 | nmake.exe -f Make_mvc.mak install |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 125 | |
| 126 | This will create the xx\LC_MESSAGES directory in runtime\lang if it does not |
| 127 | already exist. |
Bram Moolenaar | 0138062 | 2015-12-29 16:04:42 +0100 | [diff] [blame] | 128 | You can also use the following command to install all languages: |
| 129 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 130 | nmake.exe -f Make_mvc.mak install-all |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 131 | |
| 132 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 133 | AFTER ALL OF THESE STEPS |
| 134 | |
| 135 | Clean the "po" directory of all temporary and unnecessary files. Execute the |
| 136 | command: |
| 137 | |
| 138 | nmake.exe -f Make_mvc.mak clean |
| 139 | |
RestorerZ | 9650910 | 2024-07-11 21:14:15 +0200 | [diff] [blame^] | 140 | |
| 141 | TRANSLATION OF VIM THE EDITOR PLUG-INS |
| 142 | |
| 143 | Vim supports displaying plugin messages for various native languages. |
| 144 | Translation is available both for plugins that are supplied as part of the Vim |
| 145 | editor (e.g. "optwin.vim") and for third-party plugin packages. |
| 146 | |
| 147 | To translate the plugins supplied with the Vim editor, you must specify a |
| 148 | gettext() function call for the strings you want to translate. |
| 149 | The translation of these strings will be retrieved by gettext() from the MO |
| 150 | file "vim.mo". |
| 151 | |
| 152 | For third-party plugins, it is necessary to specify a one-time call to the |
| 153 | bindtextdomain() function in scripts containing translation strings and for |
| 154 | all message strings to add a {package} argument to the gettext() function. For |
| 155 | more information, see ":help package-translation". |
| 156 | |
| 157 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 158 | vim:tw=78: |