doc: do not install translated man pages if the language was not enabled in LINGUAS
[wmaker-crm.git] / doc / build / Translations.texi
blobb2faa43706222d38b0f382b3fb6ce842482026f8
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename wmaker_i18n.info
4 @settitle Window Maker Internationalisation 1.0
5 @c %**end of header
7 @c This documentation is written in Texinfo format:
8 @c   https://www.gnu.org/software/texinfo/manual/texinfo/
9 @c
10 @c The reference checker is the GNU texi2any tool, which can be invoked like this:
11 @c   texi2any --plaintext --no-split --verbose Translations.texi
13 @c If you modify this file, you may want to spell-check it with:
14 @c    aspell --lang=en_GB --mode=texinfo check Translations.texi
16 @c The length of lines in this file is set to 100 because it tends to keep sentences together
17 @c despite the embedded @commands{};
19 @c It is generally considered good practice for Tex and Texinfo formats to keep sentences on
20 @c different lines, using the fact that in the end they will be merged in paragraph anyway, because
21 @c it makes the patchs clearer about where the changes actually are.
23 @finalout
25 @c If the version was not given to texi2any with -D, assume we are being run
26 @c on the git dev branch
27 @ifclear version
28 @set version git#next
29 @end ifclear
31 @c We provide the ability to change the email address for support from the
32 @c command line
33 @ifclear emailsupport
34 @set emailsupport @email{wmaker-dev@@lists.windowmaker.org}
35 @end ifclear
37 @c ---------------------------------------------------------------------------------- Title Page ---
39 @copying
40 @noindent
41 This manual is for @sc{Window Maker} window manager, version @value{version}.
43 @noindent Copyright @copyright{} 2015 The Window Maker Team.
45 @quotation
46 This program is free software; you can redistribute it and/or modify
47 it under the terms of the GNU General Public License as published by
48 the Free Software Foundation; either version 2 of the License, or
49 (at your option) any later version.
51 This program is distributed in the hope that it will be useful,
52 but WITHOUT ANY WARRANTY; without even the implied warranty of
53 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
54 GNU General Public License for more details.
56 You should have received a copy of the GNU General Public License along
57 with this program, see file COPYING for details.
58 @end quotation
59 @end copying
61 @titlepage
62 @title Window Maker Internationalisation
63 @subtitle A guide to enable support for language translations
64 @subtitle in @sc{Window Maker} and to the contributors
65 @subtitle who want to help translating.
66 @author Christophe CURIS
68 @page
69 @vskip 0pt plus 1filll
70 @insertcopying
72 @sp 1
73 Published by The Window Maker team on @today{}.
74 @end titlepage
76 @c ---------------------------------------------------------------------------- Table of Content ---
77 @node Top
78 @ifnottex
79 @top Window Maker Internationalisation
81 @ifclear cctexi2txt
82 A guide to enable support for language translations
83 in @sc{Window Maker} and to the contributors
84 who want to help translating.
85 @end ifclear
86 @end ifnottex
88 @contents
90 @ifnottex
91 @ifclear cctexi2txt
92 @sp 1
93 This manual is for Window Maker, version @value{version}.
94 @end ifclear
95 @end ifnottex
97 @menu
98 * Enabling Languages support::  How to compile Window Maker with i18n support
99 * Choosing the Language::       When installed, how to run wmaker with your language
100 * Troubleshooting::             Some points to check if you have problems
101 * Contribute to Translations::  What to do if you want to help translating
102 @end menu
105 @c ------------------------------------------------------------------ Enabling Languages support ---
107 @node Enabling Languages support
108 @chapter Enabling Languages support
110 @sc{Window Maker} has the possibility to be translated in many languages, but by default none of
111 them will be installed, and the support for translation will not be compiled.
113 To enable the translation capabilities, you have to specify which language(s) you want to be
114 installed: this is done with the variable @env{LINGUAS} when running the @command{configure} script.
115 This variable should contain the space-separated list of languages you want to install.
117 You could for instance enable both French (@code{fr}) and Dutch (@code{nl}) with this:
119 @example
120 ./configure LINGUAS="fr nl"
121 @end example
123 You can of course add any other option that you want to the @command{configure} command.
124 From the moment you specify the variable, the @command{configure} script will check that you have
125 the appropriate dependencies for this (basically the @code{gettext} function and the @code{libintl}
126 library); when you run @command{make} to compile the project, it will also compile the translation
127 (@code{mo} files) for the language(s) you asked (if available, of course), and during
128 @command{make install} it will install them in the usual directory.
130 The installation directory can be changed with the standard option @option{--localedir} to the
131 @command{configure} script, the default path being
132 @file{@emph{<prefix>}/share/locale/@emph{<lang>}/LC_MESSAGES}).
135 @c ----------------------------------------------------------------- List of supported Languages ---
136 @section Getting the list of supported languages
138 The naming convention for the languages follows the @cite{ISO 639-1} standard,
139 for which you can find a summary list in the
140 @uref{https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html, GNU gettext manual}.
142 But as @sc{Window Maker} does not support all of them, the @command{configure} script will print a
143 warning for each language you specify that it does not know, and sum up at the end the list of
144 enabled languages that will be installed.
146 There is a non-standard possibility to set @env{LINGUAS} to @code{list}, in which case the
147 @command{configure} script will provide you the list of languages it supports, and stop:
149 @example
150 ./configure LINGUAS="list"
151 @end example
153 There is also another non-standard possibility to enable all the languages that @sc{Window Maker}
154 supports by setting @env{LINGUAS} to @code{*}.
155 This is an internal trick implemented so the development team can have the command
156 @command{make distcheck} include some checks on translations:
158 @example
159 ./configure LINGUAS='*'
160 @end example
163 @c ---------------------------------------------------------------------- Translations for Menus ---
164 @section Translations for Menus
166 In order to propose an @emph{Application Menu} (also called @emph{Root Menu}) that is also
167 translated in the language of the interface, @sc{Window Maker} implements two complementary
168 mechanisms:
170 The first, always enabled when i18n support is enabled, is to look for the menu file containing the
171 name of the locale.
172 For example, if the file is called @file{menu} and the language is set as @env{LANG=fr_FR.utf-8},
173 then @sc{Window Maker} will search for, and use the first match found:
175 @itemize
176 @item @code{menu.fr_FR.utf-8}
177 @item @code{menu.fr_FR}
178 @item @code{menu.fr}
179 @item @code{menu}
180 @end itemize
182 The second possibility, which is not enabled by default, is to be able to use a custom @file{po}
183 file which contains the translations for the text of the menu.
184 This feature is enabled at compile time, using the option @option{--with-menu-textdomain} to the
185 @command{configure} script. For example, if you specify:
187 @example
188 ./configure --with-menu-textdomain=WMMenu
189 @end example
191 @noindent then the translations for the menu will be searched in the file @file{WMMenu.mo} located
192 at the standard location, the default path being
193 @file{@emph{<prefix>}/share/locale/@emph{<lang>}/LC_MESSAGES/@emph{WMMenu}.mo}.
195 If you do not enable the feature (the default behaviour, or with an explicit
196 @option{--without-menu-textdomain}), then @sc{Window Maker} will @b{not} try to translate the
197 strings, even using its own domain file (@file{WindowMaker.mo}).
200 @c --------------------------------------------------------------------- LINGUAS at system level ---
201 @section Setting @env{LINGUAS} at system level
203 As the variable @env{LINGUAS} is quite standard, you also have the possibility to set its value in
204 the @file{config.site} file for @sc{Autoconf}.
205 This file can be placed in one of these paths:
207 @itemize @bullet
208 @item @file{@emph{<prefix>}/share/config.site}
209 @item @file{@emph{<prefix>}/etc/config.site}
210 @end itemize
212 This way, the same language list will be used for all the programs that use @sc{Autoconf} that you
213 would compile.
214 Please note that if you also specify a value on the command line, it will have precedence over the
215 value in that file.
218 @c ----------------------------------------------------------------------- Choosing the Language ---
219 @node Choosing the Language
220 @chapter Choosing the Language
222 If you have compiled and installed @sc{Window Maker} with support for your language,
223 the effective translation is done is the very same way as any other application on an @sc{Unix}
224 system, you just have to set the shell variable @env{LANG} to your language before @command{wmaker}
225 is started.
226 In @command{sh} type of shell (@sc{sh}, @sc{ksh}, @sc{bash}, ...), this is done for example with
227 (@code{fr} is for French):
229 @example
230 export LANG=fr
231 @end example
234 There is also a command line option @option{--locale} for @sc{Window Maker} which may be used to set
235 the language:
237 @example
238 wmaker --locale fr
239 @end example
241 When using this option, @sc{Window Maker} will use the locale you specified, redefining the
242 @env{LANG} environment variable to this value so all program started from @sc{Window Maker} will
243 inherit its value.
246 If your system is using @sc{systemd}, you can also configure the locale at system level using the
247 command:
249 @example
250 localectl set-locale LANG=fr
251 @end example
254 You can check if the current value is properly supported with the command:
256 @example
257 locale
258 @end example
260 If this does not work, you may need first to activate the support for your locale in the system;
261 you can get the list of currently enabled locales with the command:
263 @example
264 locale -a
265 @end example
267 You should be able to enable a new language support by editing the file @file{/etc/locale.gen} to
268 uncomment the locale(s) you need (by removing the @code{#} character and space(s) in front of it,
269 and by running the command @command{locale-gen} as root.
271 For further information, you may wish to read dedicated documentation, for example from
272 @uref{http://tldp.org/HOWTO/HOWTO-INDEX/other-lang.html, the Linux Documentation Project}
273 or through pages like
274 @uref{http://www.shellhacks.com/en/HowTo-Change-Locale-Language-and-Character-Set-in-Linux,Shell Hacks' note on Changing Locale}.
277 @c ----------------------------------------------------------------------------- Troubleshooting ---
278 @node Troubleshooting
279 @chapter Troubleshooting
281 If I18N support does not work for you, check these:
283 @itemize @minus
284 @item
285 the @env{LANG} environment variable is set to your locale, and
286 the locale is supported by your OS's locale or X's locale
287 emulation. you can display all supported locales by
288 executing "@command{locale -a}" command if it is available; you
289 can check if your locale is supported by X's locale emulation,
290 see @file{/usr/share/X11/locale/locale.alias}
292 @item
293 check if you are using an appropriate fonts for the locale you
294 chose. If you're using a font set that has a different
295 encoding than the one used by @sc{Xlib} or @sc{libc}, bad things can
296 happen. Try specifically putting the encoding in the @env{LANG}
297 variable, like @code{ru_RU.KOI8-R}. Again, see
298 @file{/usr/share/X11/locale/locale.alias}
300 @item
301 the fonts you're using support your locale. if your font
302 setting on @file{$HOME/GNUstep/Defaults/WindowMaker} is like...
304 @example
305    WindowTitleFont = "Trebuchet MS:bold:pixelsize=12";
306    MenuTitleFont   = "Trebuchet MS:bold:pixelsize=12";
307 @end example
309 then you can't display Asian languages (@code{ja}, @code{ko}, @code{ch}, ...) characters using
310 @code{Trebuchet MS}. A font that is guaranteed to work for any language is
311 @code{sans} (or @code{sans-serif}). @code{sans} is not a font itself, but an alias which
312 points to multiple fonts and will load the first in that list that
313 has the ability to show glyphs in your language. If you don't know
314 a font that is suited for your language you can always set all your
315 fonts to something like:
317 @example
318    "sans:pixelsize=12"
319 @end example
321 However, please note that if your font is something like:
323 @example
324    "Trebuchet MS,sans serif:pixelsize=12"
325 @end example
327 this will not be able to display Asian languages if any of the
328 previous fonts before sans are installed. This is because unlike
329 the proper font pickup that @code{sans} guarantees for your language,
330 this construct only allows a font fallback mechanism, which tries
331 all the fonts in the list in order, until it finds one that is
332 available, even if it doesn't support your language.
334 Also you need to change font settings in style files in
335 the @file{$HOME/Library/WindowMaker/Style} directory.
337 @item
338 the @env{LC_CTYPE} environment variable is unset or it has the correct
339 value. If you don't know what is the correct value, unset it.
341 @end itemize
344 @c ------------------------------------------------------------------ Contribute to Translations ---
345 @node Contribute to Translations
346 @chapter Contribute to Translations
348 You may have noticed that many translations are not up to date, because the code has evolved but the
349 persons who initially contributed may not have had the time to continue, so any help is welcome.
351 Since @sc{Window Maker} 0.95.7 there are some targets to @command{make} that can help you in that
352 task.
355 @c ------------------------------------------------------------------ Install the latest sources ---
356 @section Install the latest sources
358 If you want to contribute, the first step is get the development branch of the code;
359 this is done using @command{git}.
360 If you do not feel confident at all with using @command{git}, you may also try to ask for a
361 @emph{snapshot} on the developer's mailing list @value{emailsupport}.
362 With @command{git} the procedure is:
364 @example
365 # Get your working copy of the sources
366 git clone git://repo.or.cz/wmaker-crm.git
368 # Go into that newly created directory
369 cd wmaker-crm
371 # Switch to the branch where everything happens
372 git checkout next
374 # Generate the configuration script
375 ./autogen.sh
376 @end example
378 Now you should have an up-to-date working copy ready to be compiled;
379 you will not need to go the full way but you should run the @command{configure} script, so it will
380 create the @file{Makefile}s, and you may want to compile the code once so it will not do it again
381 automatically later while you are doing something else:
383 @example
384 # Setup the build, enabling at least the language you want to work on
385 ./configure LINGUAS="<list of iso 639 country code>"
387 # Compile the code once
388 make
389 @end example
392 @c ------------------------------------------------------------------- Updating the Translations ---
393 @section Updating the Translations
395 The typical process for translating one program is:
397 @itemize @bullet
398 @item
399 generate a POT file (PO Template):
400 this is done with @command{xgettext} which searches for all the strings from the sources that can be
401 translated;
403 @item
404 update the PO file for your language:
405 this is done with @command{msgmerge} which compares the PO file and aligns it to the latest
406 template;
408 @item
409 edit the new PO file:
410 this is done by you with your favourite editor, to add the missing @code{msgstr}, review the
411 possible @emph{fuzzy matches}, ...
413 @item
414 check the PO file:
415 unfortunately there is no definitive method for this;
417 @item
418 submit your contribution to the project:
419 this is done with @command{git}.
420 @end itemize
422 In @sc{Window Maker}, you have actually 4 @code{po} files to take care of:
424 @itemize @minus
425 @item @file{po/@emph{<lang>}.po}: for @sc{Window Maker} itself
426 @item @file{WPrefs.app/po/@emph{<lang>}.po}: for the Preference Editor program
427 @item @file{WINGs/po/@emph{<lang>}.po}: for the graphic toolkit library
428 @item @file{util/po/@emph{<lang>}.po}: for the command-line tools of @sc{Window Maker}
429 @end itemize
431 As stated previously, there is a @command{make} target that can help you to automatically generate
432 the POT and update the PO for these 4 cases:
434 @example
435 make update-lang PO=<lang>
436 @end example
438 Once run, it will have updated as needed the 4 @code{po} files against the latest source code.
439 You may wish to use the command @command{git gui} to view the changes;
440 you can now edit the files to complete the translation, correct them, remove deprecated stuff, ...
441 Please note that the encoding should be set to @emph{UTF-8} as this is now the standard.
443 If you think an error message is too obscure, just ask on the developer mailing list
444 @value{emailsupport}: in addition to clarifications there's even a chance for the original message
445 to be improved!
447 You may find some information on working with @code{po} file in the
448 @uref{https://www.gnu.org/software/gettext/manual/html_node/Editing.html,GNU gettext documentation}.
451 @c --------------------------------------------------------------------- Translate the Man Pages ---
452 @section Translate the Man Pages
454 You may want to extend the translation to the documentation that is provided to users in the form
455 of Unix @i{man pages}.
456 The sources of the man pages are located in the @file{doc/} directory;
457 the translation should be placed in the directory @file{doc/@i{lang}/} with the same file name.
459 The directory will also need a file @file{Makefile.am} which provides the list of man pages to be
460 included in the distribution package and to be installed.
461 You can probably get inspiration from an existing one from another language;
462 if you do not feel confident about it do not hesitate to ask on the project's mailing list
463 (@value{emailsupport}), either for help or to ask someone to make it for you.
465 Please note that although most man pages sources are directly in man page format
466 (@emph{nroff}, the file extension being a number), a few of them are processed by a script
467 (those with the @file{.in} extension, like @file{wmaker.in}).
468 This is done because in some case we want the man page to reflect the actual compilation options.
470 You may not want to bother with this hassle, in which case you can simply name your translation
471 file with the @file{.1} and remove the special @code{@@keyword@@} marks.
472 If you are sure you want to keep that processing but do not feel confident about hacking the
473 @file{Makefile.am} do not hesitate to ask on the project's mailing list (@value{emailsupport}).
476 @c ------------------------------------------------------------------------- Checking the Result ---
477 @section Checking the Result
479 In the @sc{Window Maker} build tree you also have another target that can help you, it is
480 @command{make check}.
482 At current time, it does not check much, but if during the @command{make update-lang} new @code{po}
483 file have been created you may get some errors, because you have to add these new files to the
484 variable @var{EXTRA_DIST} in the corresponding @file{Makefile}.
486 If you do not feel confident about doing it, do not worry, just tell about it when you submit your
487 work, and some developer on the mailing list will just be happy to do it for you when integrating
488 your valuable contribution (we always like when someone helps making @sc{Window Maker} better).
491 @c ---------------------------------------------------------------- Submitting your Contribution ---
492 @section Submitting your Contribution
494 @emph{Preliminary Remark}: if the update process made changes in a @code{po} file but you did not
495 change any @code{msgstr} content, it is probably a good idea to not submit the changes to that
496 @code{po} file because it would just add noise.
498 When you feel ready to send your changes, the first step is to prepare them.
499 This is done with @command{git}: if you have not run the @command{git gui} previously then it is a
500 good time to do it now.
501 This window offers you the possibility to show your changes and to decide what you want to send.
503 The window is divided in 4 panes:
504 @itemize @bullet
505 @item
506 top-right show the current changes you have selected, for review
507 (and also for cherry-picking stuff if you want to select precisely)
509 @item
510 top-left ("Unstaged Changes") the list of files with changes to be send,
511  you can click on the name of the file to see the changes,
512  you can click on the icon of the file if you want to send all the changes in this file;
513 an icon in blue shows a file that have been changed and an icon in black shows a file that is new
515 @item
516 bottom-left ("Staged Changes") the list of files with changes that you have chosen to send so far,
517  you can click on the file name to view these changes,
518  you can click on the icon if you want to remove the changes from this file from the list to send
520 @item
521 bottom-right ("Commit Message") the message you want to attach to your changes when you submit them
522 to the development team
523 @end itemize
525 The idea here is to pick your changes to the @code{po} files;
526 for the @emph{commit message} you may wish to stuck to a simple, single line:
528 @quotation
529 "Updated translations for @emph{<lang>}"
530 @end quotation
532 The penultimate step is to click on the button @key{Sign Off} (it will add a line in the commit
533 message), and then click on the button @key{Commit}.
534 From this time, the commit message will clear itself and the "Staged Changes" also, showing that
535 your action was done.
537 You may now quit the @command{git gui}, the final step begins by running this command:
539 @example
540 git format-patch HEAD^
541 @end example
543 This will generate a file named like @file{0001-@emph{updated-translations-for-XX}.patch}
544 which contains your changes, ready for sending.
545 The goal will now be to email this file to @value{emailsupport}.
546 If you feel confident in having @command{git} send it for you, you may want to read the file
547 @file{The-perfect-Window-Maker-patch.txt} to see how to configure @command{git} for mailing, so you
548 can run:
550 @example
551 git send-email 0001-@emph{updated-translations-for-XX}.patch
552 @end example
555 @c ------------------------------------------------------------------------------------- The End ---
556 @bye