Homec4science

Errors are now internationalized. Minor bug fixes, global code improvement. To…

Authored by Gregory Favre <gregory.favre@cern.ch> on Dec 15 2005, 12:49.

Description

Errors are now internationalized. Minor bug fixes, global code improvement. To properly handle errors: Create a file named following this pattern: modulename_config.py (e.g. webcomment_config.py)

In this file developers should declare the following dictionnaries:

  • cfg_modulename_error_messages
  • cfg_modulename_warning_messages

Content of these dictionaries:
ERR_MODULENAME_ERROR_NAME: '_("internationalized text with eventual text replacement strings %s %i")'

Errorlib will actually interpret strings for internationalization if they begin with '_(' and end with ')'.

NOTE: ERR_MODULENAME must be uppercase; names of dictionary and config file must respect the rules defined above.

Example:

file miscutil_config.py:
cfg_miscutil_error_messages = \
{ 'ERR_MISCUTIL_BAD_FILE_ARGUMENT_PASSED': '_("Invalid argument %s was passed")',

'ERR_MISCUTIL_WRITE_FAILED': '_("Unable to write to file %s")',
'ERR_MISCUTIL_NO_ERROR_MESSAGE': '_("Trying to write a non error message to error log")'

}

cfg_miscutil_warning_messages = \
{ 'WRN_MISCUTIL_SOME_WARNING': '_("example warning (%s)")',

'ERR_MISCUTIL_STRANGE_WARNING': '_("Warnings can also be displayed as errors")'

}

Event Timeline

Gregory Favre <gregory.favre@cern.ch> committed R3600:1f781318ab1b: Errors are now internationalized. Minor bug fixes, global code improvement. To… (authored by Gregory Favre <gregory.favre@cern.ch>).Dec 15 2005, 12:49