From what we have seen so far, we can now add translation facilities to any product as long as the text is in Python code. Using
MessageFactory we can mark text as translatable.
The following example will modify the
pox.banner package developed in Chapter 6. It's also available in this book's downloadable code.
The following steps should have been taken during
pox.banner package development. However, we waited to introduce them until now for clarity's sake.
From now on, every code we produce will be i18n-aware from scratch.
MessageFactoryto be used in the whole package. Open
pox/banner/__init__.pyfile to add the following lines:
from zope.i18nmessageid import MessageFactory ...