]> git.lyx.org Git - lyx.git/blob - README.localization
CMake: adapt to new location of Lexer
[lyx.git] / README.localization
1
2         Localization/Translation FAQ
3                 (2007-2018)
4
5     by Ran Rutenberg, Pavel Sanda, Michael Gerz
6
7
8 PART I - Interface translation
9 ------------------------------
10
11 This file is mainly intended for those who have no or little experience using
12 .po files, but want to contribute by translating the LyX interface (i.e. menu
13 and dialog items, console messages) into their native language.
14
15
16 1) WHERE DO I START?
17
18 The file you need to edit is an xx.po file where xx stands for your language's
19 two letter code. For a list of language codes look at:
20
21   https://www.gnu.org/software/gettext/manual/html_mono/gettext.html#Language-Codes
22
23 If you want to start from scratch then you should obtain a copy of the lyx.pot
24 and name it after your language. German would be for example de.po and Polish
25 pl.po. This file is generated in the "po" directory of the source tree during
26 the compilation.
27
28 There are basically two source trees you can start to work with - trunk
29 (development version) and branch (stable version). Unless the development
30 version is shortly before release it is better to start your translating
31 work on the stable version. If you have no idea how to get those trees you
32 can follow https://www.lyx.org/HowToUseGIT page.
33
34
35 2) HOW DO I EDIT PO FILES?
36
37 PO files can be edited with any text editor available for your system (e.g.
38 Vim, jEdit etc.). Yet another option is to use a specialized editor for .po
39 files. You can e.g. use the editor "Poedit", Linux users can
40 additionally use e.g. "Lokalize". Using these editors usually makes things easier
41 as they have many tools to assist the translator.
42 If you use Poedit, please uncheck in its settings the option to break lines after
43 80 characters.
44
45
46 3) WHAT DO I NEED TO TRANSLATE?
47
48 If you are using a simple text editor you should translate the strings that
49 appear in the msgid line and write the translation into the msgstr line. Note
50 that a "#, fuzzy" line is just a hint for translation from compiler - in order
51 to get the translation of the current item working you have to delete this
52 line. It is recommended that you take a look at another .po file - that way you
53 can get an idea of what to do. If you are using a specialized po editor
54 then you will see in it the untranslated strings and a place to write your
55 translation for them.
56
57
58 4) WHAT SHOULD I DO WITH THE '&', '|', '$, '%' {} AND [[]] CHARACTERS?
59
60 '&' stands for underlined characters (shortcut) in dialog boxes.
61 '|' stands for underlined characters in menus.
62
63 These chars should be somehow used in your translations, however you'll have to
64 invent your own working shortcuts for dialog and menu entries and resolve
65 possible conflicts of the same shortcut chars in one menu...
66
67 You will be informed about conflicts in the terminal if you try to access the
68 menu.
69
70 Note that, in the case of '|', if more than one character follows, this means
71 that LyX will try each of them in turn and use the first one that is not yet
72 used by another entry in the menu. That way, you can define alternative shortcuts
73 in the case one works in one context only, and another one only in another. You
74 can use this possibility also in translations, but please use it only if no
75 single shortcut that fits could be found.
76
77 Note also that there are already used global shortcuts (such as p k x c m s a)
78 and you should avoid using these characters for first-level menu shortcuts.
79
80 '$' and '%' are usually used as handlers for formatting or variables to be
81 inserted into the strings. Character sequences like %1$s or %1$d MUST also
82 appear in your translations! Please take them exactly as they are or you may
83 experience crashes when running LyX.
84
85 [[Context]] is used to distinguish otherwise identical strings, which could
86 have different translations depending on the Context. It can also be used to
87 indicate what is substituted for a placeholder. [[Context]] appears only in
88 msgid string and should not be repeated in the translated version.
89
90 {} refer to counters and must not be translated. An example would be:
91 msgid "Algorithm \\arabic{theorem}"
92 msgstr "Algoritmus \\arabic{theorem}"
93
94
95 5) WHAT IS pocheck.pl AND HOW DO I USE IT?
96
97 This is a small script located in the "po" directory of the source that helps
98 you find common errors in your translation. In order to use this script you
99 need the script language Perl installed.
100 Run ./pocheck.pl -h to see all possible switches.
101
102
103 6) HOW CAN I TEST MY TRANSLATION?
104
105 In order to test your translation you need to obtain the LyX sources
106 (from the git repository) and replace the existing .po with yours.
107 Afterwards, you should compile and optionally install LyX (check the
108 INSTALL file for your OS). Note that, as of LyX 2.1, it is not
109 necessary anymore to install anything.
110
111 In order to run LyX with your translation, change the current language
112 in Preferences dialog or use the appropriate LANG variable:
113
114   On Linux: LANG=xx_CC lyx
115   On Windows, you need to change the lyx.bat file and write: set LANG=xx_CC
116
117 xx stands for your language code. CC stands for your country code. So to get,
118 e.g., Czech, the code is "cs_CZ".
119
120 Another possibility is to use the Preferences dialog to set LyX UI to
121 use your language. Note that, as of LyX 2.2, a newly introduced
122 language will not appear in the languages combox unless it corresponds
123 to an entry of the lib/languages file that has a "HasGuiSupport true"
124 property. See this file for more details.
125
126 The most comfortable way to see your updated translation while
127 editing, is running (in linux) "make xx.gmo" in the po directory to
128 compile updated xx.po translation and then run LyX.
129
130 For advanced users - if you want to remerge your files against current source:
131
132 - on Linux: execute the command: make update-po
133 - on Windows: if you compile LyX in install mode, the po files are automatically
134         updated and output to the folder <compilation output folder>\po
135         Another option is to build the target "update-po" in MSVC.
136
137
138 7) HOW TO CONTRIBUTE MY WORK?
139
140 Send your edited xx.po file to po-updates@lyx.org.
141
142 Also you can check https://www.lyx.org/trac/browser/lyxgit/?rev=master to track
143 changes or watch updates.
144
145
146 8) SHALL ALL THE UNUSED STRINGS AT THE BOTTOM OF .PO FILE BE REMOVED,
147    OR SHALL THEY STAY?
148
149 As you wish. They can be reused for generating fuzzy hints when completely
150 new strings appear, no other function.
151
152
153 9) REFERENCES
154
155 For a basic idea of how the translation works, you can look at
156
157   https://en.wikipedia.org/wiki/Gettext
158
159 For detailed reference (including a full list of country and language codes),
160 have a look at
161
162   https://www.gnu.org/software/gettext/manual/gettext.html
163
164
165 Consider subscribing to the documentation list, lyx-docs@lists.lyx.org (rather
166 silent), or the developer's mailing list, lyx-devel@lists.lyx.org (high
167 volume).
168
169
170
171 PART II - Translation of Math environments and Floats in the final output
172 -------------------------------------------------------------------------
173
174 As of 2.0 LyX allows automatic translation in tex/dvi/ps/pdf output for math
175 environment strings (and some floats) which are not automatically translated via
176 babel package to the localized form.  For example the environment "Exercise"
177 becomes "Aufgabe" in the output of the documents with language set to German.
178
179 These translations are taken from the previously translated .po file before the
180 final major LyX release (e.g. 2.0.0) and are fixed for all next minor releases
181 (e.g. 2.0.x) in order to have fixed output of LyX documents.
182
183 The current translation for your language can be found in the file
184 lib/layouttranslations. An easy way to check many of the translations is to
185 simply load lib/examples/localization_test.lyx in LyX and read its
186 instructions.
187
188 The problematic strings can be then fixed in the .po file. For inspiration the
189 typical places in .po files, where to fix the translation, can be seen on the
190 following commit: https://www.lyx.org/trac/changeset/38169.
191
192 If you need to manually regenerate the layouttranslations file from .po files
193 - Under Linux: If using autotools, execute the command
194  `make ../lib/layouttranslations'
195  in the po directory. If using CMake, execute the command
196  `make layouttranslations1'
197  in the build directory.
198  The Python polib library is needed for building the output file.
199 - Under Windows:
200  1. install the Python extensions "polib". To do this,
201  1.1 open a commen line prompt in the folder where you find the file "pip.exe"
202      withing the python installation folder.
203  1.2 execute the command
204      pip install polib
205  2. close the command prompt and open the file "lyx.sln" with MSVC. You find
206     file in the compilation result folder you set for LyX
207  3. right click in MSVC on the target "layouttranslations1" and choose "Rebuild"
208
209 Optionally - to quickly check whether some new translatable strings appeared
210 for your language you can always check ../lib/layouttranslations.review.
211
212 Q: Running make ../lib/layouttranslations returns with just saying
213    ../lib/layouttranslations is up to date.
214 A: To force regerenation, use something like (XX is your language)
215    make -W XX.po ../lib/layouttranslations