Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | TRANSLATING VIM MESSAGES |
| 2 | |
| 3 | In this directory you will find xx.po files, where "xx" is a language code. |
| 4 | Each file contains the translation of English Vim messages for one language. |
| 5 | The files are in "po" format, used by the gettext package. Please refer to |
| 6 | the gettext documentation for more information. |
| 7 | |
| 8 | The GNU gettext library, starting with version 0.10.37, supports converting |
| 9 | messages from one encoding to another. This requires that it was compiled |
| 10 | with HAVE_ICONV. The result is that the messages may be in any encoding |
| 11 | supported by iconv and will be automatically converted to the currently used |
| 12 | encoding. |
| 13 | |
| 14 | The GNU gettext library, starting with version 0.10.36, uses a new format for |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 15 | some encodings. This follows the C99 standard for strings. It means that |
| 16 | when a multi-byte character includes the 0x5c byte, this is not recognized as |
| 17 | a backslash. Since this format is incompatible with Solaris, Vim uses the old |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 18 | format. This is done by setting the OLD_PO_FILE_OUTPUT and OLD_PO_FILE_INPUT |
| 19 | environment variables. When you use the Makefile in this directory that will |
| 20 | be done for you. This does NOT work with gettext 0.10.36. Don't use it, get |
| 21 | 0.10.37. |
| 22 | |
Bram Moolenaar | e1dc76f | 2022-06-25 18:01:32 +0100 | [diff] [blame] | 23 | Have a look at these helper scripts, they may be useful for you: |
| 24 | https://github.com/adaext/vim-menutrans-helper |
| 25 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 26 | |
| 27 | ON MS-WINDOWS |
| 28 | |
| 29 | The distributed files are generated on Unix, but this should also be possible |
| 30 | on MS-Windows. Download the gettext packages, for example from: |
| 31 | |
| 32 | http://sourceforge.net/projects/gettext |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 33 | or |
RestorerZ | e214692 | 2023-11-23 20:58:32 +0100 | [diff] [blame] | 34 | https://mlocati.github.io/articles/gettext-iconv-windows.html |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 35 | |
| 36 | You might have to do the commands manually. Example: |
| 37 | |
RestorerZ | e214692 | 2023-11-23 20:58:32 +0100 | [diff] [blame] | 38 | cd c:\vim\vim91 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 39 | mkdir runtime\lang\ja\LC_MESSAGES |
| 40 | msgfmt -o runtime\lang\ja\LC_MESSAGES\vim.mo src\po\ja.po |
| 41 | |
| 42 | |
| 43 | WHEN THERE IS A MISTAKE |
| 44 | |
| 45 | If you find there is a mistake in one of the translations, please report this |
Christian Brabandt | ee17b6f | 2023-09-09 11:23:50 +0200 | [diff] [blame] | 46 | to the maintainer of the translation. His/her e-mail address is in the |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 47 | comments at the start of the file. You can also see this with the ":messages" |
| 48 | command in Vim when the translation is being used. |
| 49 | |
| 50 | |
| 51 | CREATING A NEW PO FILE |
| 52 | |
| 53 | We will use "xx.po" as an example here, replace "xx" with the name of your |
| 54 | language. |
| 55 | |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 56 | - Edit Make_all.mak to add xx to LANGUAGES and xx.mo to MOFILES, xx.po to |
| 57 | POFILES and xx.ck to CHECKFILES. |
| 58 | - If the encoding of the translation text differs from the default UTF-8, add a |
| 59 | corresponding entry in MOCONVERTED, specifying the required encoding. |
Bram Moolenaar | d2f3a8b | 2018-06-19 14:35:59 +0200 | [diff] [blame] | 60 | - If you haven't done so already, run ./configure in the top vim directory |
| 61 | (i.e. go up two directories) and then come back here afterwards. |
| 62 | - Execute these commands: |
| 63 | % make vim.pot |
| 64 | % msginit -l xx |
| 65 | % rm vim.pot |
| 66 | The first command will generate a vim.pot file which is used by msginit to |
| 67 | generate a correct xx.po file. After that vim.pot is not needed. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 68 | - The remaining work is like updating, see the next section. |
| 69 | |
| 70 | |
| 71 | UPDATING A PO FILE |
| 72 | |
| 73 | If you are the maintainer of a .po file, this is how you update the file. We |
| 74 | will use "xx.po" as an example here, replace "xx" with the name of your |
| 75 | language. |
| 76 | |
| 77 | (1) Add new and changed messages from the Vim sources: |
| 78 | |
| 79 | make xx |
| 80 | |
| 81 | This will extract all the strings from Vim and merge them in with the |
Bram Moolenaar | 56b45b9 | 2013-06-24 22:22:18 +0200 | [diff] [blame] | 82 | existing translations. Requires the GNU gettext utilities. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 83 | Your original xx.po file will be copied to xx.po.orig |
| 84 | |
| 85 | -- After you do this, you MUST do the next three steps! -- |
| 86 | |
| 87 | (2) Translate |
| 88 | See the gettext documentation on how to do this. You can also find |
Bram Moolenaar | 0b39c3f | 2020-08-30 15:52:10 +0200 | [diff] [blame] | 89 | examples in the other po files. You can use "gF" on the file name to see |
| 90 | the context of the message. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 91 | Search the po file for items that require translation: |
| 92 | |
| 93 | /fuzzy\|^msgstr ""\(\n"\)\@! |
| 94 | |
| 95 | Remove the "#, fuzzy" line after adding the translation. |
| 96 | |
| 97 | There is one special message: |
Christian Brabandt | e978b45 | 2023-08-13 10:33:05 +0200 | [diff] [blame] | 98 | msgid "Messages maintainer: The Vim Project" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 99 | You should include your name and E-mail address instead, for example: |
| 100 | msgstr "Berichten übersetzt bei: John Doe <john@doe.org>" |
| 101 | |
Bram Moolenaar | aaef1ba | 2017-08-01 17:40:23 +0200 | [diff] [blame] | 102 | (3) Remove unused messages (optional) |
Bram Moolenaar | fa57335 | 2020-09-04 13:53:00 +0200 | [diff] [blame] | 103 | Remove messages that have been marked as obsolete. |
Bram Moolenaar | aaef1ba | 2017-08-01 17:40:23 +0200 | [diff] [blame] | 104 | Such messages start with "#~". |
| 105 | |
| 106 | The cleanup script will also do that (see next step). |
| 107 | |
| 108 | (4) Clean up |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 109 | This is very important to make sure the translation works on all systems. |
| 110 | Comment-out all non-translated strings. There are two types: |
| 111 | - items marked with "#, fuzzy" |
| 112 | - items with an empty msgstr |
| 113 | You can do this with the cleanup.vim script: |
| 114 | |
| 115 | :source cleanup.vim |
| 116 | |
| 117 | Background: on Solaris an empty msgstr results in an empty message; GNU |
| 118 | gettext ignores empty strings and items marked with "#, fuzzy". |
| 119 | |
Bram Moolenaar | 4be06f9 | 2005-07-29 22:36:03 +0000 | [diff] [blame] | 120 | This also removes the line numbers from the file, so that patches are not |
| 121 | messed up by changes in line numbers and show the actual changes in the |
| 122 | text. |
| 123 | |
Bram Moolenaar | f55e4c8 | 2017-08-01 20:44:53 +0200 | [diff] [blame] | 124 | (5) Check: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 125 | |
Bram Moolenaar | 74675a6 | 2017-07-15 13:53:23 +0200 | [diff] [blame] | 126 | While editing the .po file: |
| 127 | :source check.vim |
| 128 | |
| 129 | From the command line: |
Bram Moolenaar | 58d9823 | 2005-07-23 22:25:46 +0000 | [diff] [blame] | 130 | vim -S check.vim xx.po |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 131 | make xx.mo |
| 132 | |
| 133 | Look out for syntax errors and fix them. |
Bram Moolenaar | e6ae622 | 2013-05-21 21:01:10 +0200 | [diff] [blame] | 134 | |
Bram Moolenaar | 0b39c3f | 2020-08-30 15:52:10 +0200 | [diff] [blame] | 135 | (6) Local tryout: |
| 136 | Vim normally picks up the .mo files from: |
| 137 | $VIMRUNTIME/lang/{lang}/LC_MESSAGES/vim.mo |
| 138 | To try out the messages with Vim use: |
Bram Moolenaar | fa57335 | 2020-09-04 13:53:00 +0200 | [diff] [blame] | 139 | make tryoutinstall |
Bram Moolenaar | 0b39c3f | 2020-08-30 15:52:10 +0200 | [diff] [blame] | 140 | And run Vim with $VIMRUNTIME set to ../runtime |
| 141 | |
Bram Moolenaar | e6ae622 | 2013-05-21 21:01:10 +0200 | [diff] [blame] | 142 | |
| 143 | USING GETTEXT WITHOUT ICONV |
| 144 | |
| 145 | When using gettext which doesn't support iconv, the encoding of the .mo file |
| 146 | must match your active encoding. For that you must convert and change |
| 147 | encoding of *.po file in advance of generating the *.mo file. For example, to |
| 148 | convert ja.po to EUC-JP (supposed as your system encoding): |
| 149 | |
| 150 | (1) Convert the file encoding: |
| 151 | |
| 152 | mv ja.po ja.po.orig |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 153 | iconv -f UTF-8 -t EUC-JP ja.po.orig > ja.po |
Bram Moolenaar | e6ae622 | 2013-05-21 21:01:10 +0200 | [diff] [blame] | 154 | |
| 155 | (2) Rewrite charset declaration in the file: |
| 156 | |
| 157 | Open ja.po find this line: |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 158 | "Content-Type: text/plain; charset=UTF-8\n" |
Bram Moolenaar | e6ae622 | 2013-05-21 21:01:10 +0200 | [diff] [blame] | 159 | You should change "charset" like this: |
RestorerZ | 76ba724 | 2024-01-22 20:28:12 +0100 | [diff] [blame] | 160 | "Content-Type: text/plain; charset=EUC-JP\n" |
Bram Moolenaar | e6ae622 | 2013-05-21 21:01:10 +0200 | [diff] [blame] | 161 | |
| 162 | There are examples in the Makefile for the conversions already supported. |
RestorerZ | 9650910 | 2024-07-11 21:14:15 +0200 | [diff] [blame] | 163 | |
| 164 | |
| 165 | TRANSLATION OF VIM THE EDITOR PLUG-INS |
| 166 | |
| 167 | Vim supports displaying plugin messages for various native languages. |
| 168 | Translation is available both for plugins that are supplied as part of the Vim |
| 169 | editor (e.g. "optwin.vim") and for third-party plugin packages. |
| 170 | |
| 171 | To translate the plugins supplied with the Vim editor, you must specify a |
| 172 | gettext() function call for the strings you want to translate. |
| 173 | The translation of these strings will be retrieved by gettext() from the MO |
| 174 | file "vim.mo". |
| 175 | |
| 176 | For third-party plugins, it is necessary to specify a one-time call to the |
| 177 | bindtextdomain() function in scripts containing translation strings and for |
| 178 | all message strings to add a {package} argument to the gettext() function. For |
| 179 | more information, see ":help package-translation". |
Christian Brabandt | 80d72aa | 2024-12-18 20:13:46 +0100 | [diff] [blame^] | 180 | |
| 181 | COMMITTING CHANGES |
| 182 | |
| 183 | Before committing changes to the repo, make sure to run "make check" to verify |
| 184 | any changes here do not fail the test script (and therefore the CI) |