Localizing Output from Python Programs
You can localize output, such as messages and pivot table strings, from extension commands implemented in Python. The localization process consists of the following steps:
- Modifying the Python implementation code to identify translatable strings
- Extracting translatable text from the implementation code using standard Python tools
- Preparing a translated file of strings for each target language
- Installing the translation files along with the extension command
The process described here assumes use of the Python extension
module,
which is installed with IBM® SPSS® Statistics - Essentials for Python.
Notes
- When running
an extension command from within IBM SPSS Statistics, the language for extension command output will be automatically
synchronized with the IBM SPSS Statistics output
language (
OLANG
). When running an extension command from an external Python process, such as a Python IDE, you can set the output language by submitting aSET OLANG
command when IBM SPSS Statistics is started. If no translation for an item is available for the output language, the untranslated string will be used. - Messages produced by the
extension
module, such as error messages for violation of the specifications in the Syntax definition, are automatically produced in the current output language. Exceptions raised in the extension command implementation code are automatically converted to a Warnings pivot table. - Translation of dialog boxes built with the Custom Dialog Builder is a separate process, but translators should ensure that the dialog and extension command translations are consistent.
Additional Resources
Examples of extension commands implemented in Python with localized output are included with IBM SPSS Statistics - Essentials for Python. The Python
modules for these examples can be found in the location where extension commands are installed on
your computer. To view the location, run the SHOW EXTPATHS
syntax command. The
output displays a list of locations under the heading "Locations for extension commands". The files
are installed to the first writable location in the list.
Information on creating extension commands is also available from the following sources:
- The article "Writing IBM SPSS Statistics Extension Commands", available from the IBM SPSS Predictive Analytics community at https://www.ibm.com/community/spss-statistics .
- The chapter on Extension Commands in Programming and Data Management for IBM SPSS Statistics , which is also available from the IBM SPSS Predictive Analytics community.