|
|||||||
1. Introduction
2. Installing Karrigell 3. The Web server 4. Working with Apache or Xitami 5. Programming 6. Debugging 7. Python scripts 8. Karrigell Services 9. Python Inside HTML 10. HTML Inside Python 11. HTMLTags - generate HTML in Python 12. Including documents 13. Sessions 14. Authentication 15. Internationalization 15.1 Introduction 15.2 Internationalization program |
15. InternationalizationAs you'll have guessed by reading this documentation, I'm not from an English-speaking country (I'm French, and more precisely Breton - the name Karrigell is a Breton word). So I've included a program to facilitate internationalization of scripts 15.1 IntroductionTranslation is made using the
This text file is transformed into a binary file with a .mo extension by a Python program called msgfmt.py, written by Martin v. Löwis (it's included in Karrigell's Server Directory) In a script, every time you want a message translated into a given language, instead of writing the message as a normal string with quotes, it's written using a function called _, this way :
In order to have it translated into the requested language :
where domain is the name of the .po file, baseDir the directory in which the subdirectory language/LC_MESSAGES is stored, and language is the language used For instance, if the language is
"francais" and the .po file is called messages.po, stored in
15.2 Internationalization programThe raw use ofgettext may be difficult when writing or debugging
a program ; for each new string you want to translate you have to create the
whole .po file then the .mo file without erasing previous translations.
Karrigell provides a simple web interface to create and modify translations of
strings, hiding the underlying gettext mechanism
For security reasons, this script is reserved to the administrator. An
authentication script is run, relying on md5 digests stored in a file called
With your browser, call the script Fill in the fields and validate the form ; this creates or updates the translations
You can check the effect by calling the script you've just modified and changing the language order in the preferences Translation is held in a file which is common to all the files in the same directory. You can also edit the whole dictionary clicking on the first item in the script list
(1) On Microsoft Internet Explorer the language preference is set by Tools/Internet Options/General/Languages ; accepted languages are chosen from a list and ordered by preference. On Netscape use Edition/Preferences/Languages |