comparison doc/developers.txt @ 6658:408fd477761f

Add i18n object to roundupdb.Database This makes the i18n object accessible everywhere (including in detectors where localized error messages were impossible). See issue2551184
author Ralf Schlatterbeck <rsc@runtux.com>
date Tue, 03 May 2022 14:51:59 +0200
parents cbc18a8bc61f
children a8c757a33ab1
comparison
equal deleted inserted replaced
6657:2453d7b58a92 6658:408fd477761f
287 <span tal:replace="python: i18n.ngettext( 287 <span tal:replace="python: i18n.ngettext(
288 'Oh but it\'s only %i shilling.', 288 'Oh but it\'s only %i shilling.',
289 'Oh but it\'s only %i shillings.', 289 'Oh but it\'s only %i shillings.',
290 fine) % fine" 290 fine) % fine"
291 /> 291 />
292
293 Detectors and extensions
294 ^^^^^^^^^^^^^^^^^^^^^^^^
295
296 The correct ``i18n`` objects gets automatically injected in the hyperdb.
297 In a detector you can access the i18n object and do translation like
298 this::
299
300 def statusfail(db, cl, nodeid, newvalues):
301 _ = db.i18n.gettext
302 raise ValueError(_("this does not work"))
303
304 def init(db):
305 # fire before changes are made
306 db.status.audit('create', statusfail)
307
292 308
293 Extracting Translatable Messages 309 Extracting Translatable Messages
294 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 310 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
295 311
296 The most common tool for message extraction is ``xgettext`` utility 312 The most common tool for message extraction is ``xgettext`` utility

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