comparison doc/developers.txt @ 5332:d0689aaa83db

Applied patch 0038 from issue2550960 to upgrade code examples in documentation to be compatible with both python 2 and 3. Patch supplied by Joseph Myers.
author John Rouillard <rouilj@ieee.org>
date Tue, 12 Jun 2018 20:27:04 -0400
parents 132801e38324
children 979390afb001
comparison
equal deleted inserted replaced
5331:57caeefb2f81 5332:d0689aaa83db
211 from i18n import _, ngettext 211 from i18n import _, ngettext
212 212
213 Simple translations are automatically marked by calls to builtin 213 Simple translations are automatically marked by calls to builtin
214 message translation function ``_()``:: 214 message translation function ``_()``::
215 215
216 print _("This message is translated") 216 print(_("This message is translated"))
217 217
218 Translations for messages whose grammatical depends on a number 218 Translations for messages whose grammatical depends on a number
219 must be done by ``ngettext()`` function:: 219 must be done by ``ngettext()`` function::
220 220
221 print ngettext("Nuked %i file", "Nuked %i files", number_of_files_nuked) 221 print(ngettext("Nuked %i file", "Nuked %i files", number_of_files_nuked))
222 222
223 Deferred Translations 223 Deferred Translations
224 ~~~~~~~~~~~~~~~~~~~~~ 224 ~~~~~~~~~~~~~~~~~~~~~
225 225
226 Sometimes translatable strings appear in the source code in untranslated 226 Sometimes translatable strings appear in the source code in untranslated
227 form [#note_admin.py]_ and must be translated elsewhere. 227 form [#note_admin.py]_ and must be translated elsewhere.
228 Example:: 228 Example::
229 229
230 for meal in ("spam", "egg", "beacon"): 230 for meal in ("spam", "egg", "beacon"):
231 print _(meal) 231 print(_(meal))
232 232
233 In such cases, strings must be marked for translation without actual 233 In such cases, strings must be marked for translation without actual
234 call to the translating function. To mark these strings, we use Python 234 call to the translating function. To mark these strings, we use Python
235 feature of automatic concatenation of adjacent strings and different 235 feature of automatic concatenation of adjacent strings and different
236 types of string quotes:: 236 types of string quotes::

Roundup Issue Tracker: http://roundup-tracker.org/