Skip to content

Commit 6db574a

Browse files
author
Alexander Smishlajev
committed
concise howtos
1 parent 4aeceed commit 6db574a

File tree

1 file changed

+122
-13
lines changed

1 file changed

+122
-13
lines changed

I18N_PROGRESS.txt

Lines changed: 122 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,131 @@
1-
This list has been generated using the MANIFEST file. We should be able to
2-
write a simple script to compare the two and make sure that all MANIFEST
3-
files appear in here.
1+
==================================
2+
Roundup Internationalization Notes
3+
==================================
4+
5+
:Version: $Revision: 1.7 $
6+
7+
FIXME: add introduction - what's l10n, i18n, po, mo, pot, gettext...
8+
9+
Used Tools
10+
----------
11+
12+
We use ``xpot`` utility from Francois Pinard free `PO utilities`_
13+
to build message template file. ``pygettext`` utility included
14+
with Python distribution is not used because it has several limitations:
15+
16+
- no way to mark strings translated elsewhere
17+
- does not detect translation done by an object method
18+
- source references put in the comments are not recognized
19+
by translation software.
20+
21+
Message translation can be done with `emacs`_ "po mode" provided
22+
by `PO utilities`_. (als: i didn't try that personally.)
23+
24+
Another tool for message translation (als: one that i use) is `poEdit`_
25+
by Vaclav Slavik.
26+
27+
.. _PO utilities: http://po-utils.progiciels-bpi.ca/
28+
.. _emacs: http://www.gnu.org/software/emacs/
29+
.. _poEdit: http://poedit.sourceforge.net/
30+
31+
Marking Strings for Translation
32+
-------------------------------
33+
34+
Strings that need translation must be marked in the source code.
35+
36+
Command Line Interfaces
37+
~~~~~~~~~~~~~~~~~~~~~~~
38+
39+
Scripts and routines run from the command line use "static" language
40+
defined by environment variables recognized by ``gettext`` module
41+
from Python library (``LANGUAGE``, ``LC_ALL``, ``LC_MESSAGES``, and
42+
``LANG``). Primarilly, these are ``roundup-admin`` script and
43+
``admin.py`` module, but also help texts and startup error messages
44+
in other scripts and their supporting modules.
45+
46+
For these interfaces, Python ``gettext`` engine must be initialized
47+
to use Roundup message catalogs. This is normally done by including
48+
the following line in the module imports::
49+
50+
from i18n import _
51+
52+
Simple translations are automatically marked by calls to builtin
53+
message translation function ``_()``::
454

5-
To generate a messages.pot file, use this command:
55+
print _("This message is translated")
656

7-
python tools/pygettext.py roundup roundup-* cgi-bin/roundup.cgi
57+
*(not tested)* Translations for messages whose grammatical depends
58+
on a number must be done by ``ngettext()`` function::
859

9-
"messages.pot" then contains a positive list of files using _(), which can
10-
be extracted by;
60+
print ngettext("Nuked %i file", "Nuked %i files", number_of_files_nuked)
1161

12-
grep "#: " messages.pot | tr ":#0123456789 " "\012" | sort | uniq
62+
*Discussion:* make ``i18n._()`` with the same interface as in ``config._()``?
1363

14-
Of course, this does not check whether a file is fully translated, only
15-
whether there is at least one use of "_()".
64+
User Interfaces
65+
~~~~~~~~~~~~~~~
66+
67+
*(not yet)*
68+
69+
This includes Mail Gateway and Web User Interfaces, where translation
70+
depends on the language of current Roundup User. These translations
71+
will be done by the tracker configuration object. Translatable strings
72+
will be automatically marked by calls to the ``_()`` method of that
73+
object::
74+
75+
self.config._("This message is translated")
76+
self.config._("Nuked %i file", "Nuked %i files", number_of_files_nuked)
77+
78+
Deferred Translations
79+
~~~~~~~~~~~~~~~~~~~~~
80+
81+
Sometimes translatable strings appear in the source code in untranslated
82+
form and must be translated elsewhere. Example::
83+
84+
for meal in ("spam", "egg", "beacon"):
85+
print _(meal)
86+
87+
In such cases, strings must be marked for translation without actual
88+
call to the translating function. To mark these strings, we use Python
89+
feature of automatical concatenation of adjacent strings and different
90+
types of string quotes::
91+
92+
strings_to_translate = (
93+
''"This string will be translated",
94+
""'me too',
95+
''r"\raw string",
96+
''"""
97+
multiline string"""
98+
)
99+
100+
Building Message Catalog Template
101+
---------------------------------
102+
103+
Message catalog template ``roundup.pot`` is kept in `Roundup CVS`_
104+
and distributed with `Roundup Source`_. If you wish to rebuild
105+
the template yourself, you will need ``xpot`` utility by Francois
106+
Pinard, included in `PO utilities`_ distribution.
107+
108+
To rebuild the template file, just run ``gmake`` (or ``make``, if you
109+
are on a `GNU`_ system like `linux`_ or `cygwin`_) in the 'locale'
110+
directory.
111+
112+
.. Roundup CVS: http://sourceforge.net/cvs/?group_id=31577
113+
.. Roundup Source: http://sourceforge.net/project/showfiles.php?group_id=31577
114+
.. GNU: http://www.gnu.org/
115+
.. linux: http://www.linux.org/
116+
.. cygwin: http://www.cygwin.com/
117+
118+
I18 Status
119+
----------
120+
121+
This list has been generated using the MANIFEST file. We should be able to
122+
write a simple script to compare the two and make sure that all MANIFEST
123+
files appear in here.
16124

125+
This list was last updated Sat Jan 5 02:35:10 2002 UTC.
17126

18127
THESE FILES DO NOT USE _()
19-
==========================
128+
~~~~~~~~~~~~~~~~~~~~~~~~~~
20129
roundup/hyperdb.py
21130
roundup/i18n.py
22131
roundup/init.py
@@ -41,7 +150,7 @@ roundup/templates/classic/detectors/nosyreaction.py
41150

42151

43152
THESE FILES DO USE _()
44-
======================
153+
~~~~~~~~~~~~~~~~~~~~~~
45154
roundup-admin
46155
roundup-mailgw
47156
roundup-server
@@ -53,7 +162,7 @@ roundup/cgi/cgitb.py
53162

54163

55164
WE DON'T CARE ABOUT THESE FILES
56-
===============================
165+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57166
BUILD.txt
58167
CHANGES.txt
59168
INSTALL.txt

0 commit comments

Comments
 (0)