Service Localization
Pida 0.5 support gettext.
How to translate a service
Take as an example the bugreport service. In order to translate it into French, first you need to locate the source code, in this case it can be found at pida/service/bugreport.
(For your service, replace every occurrence of bugreport by yourservicename)
1/ Add the localization code to the service
Add the following locale initialization code (just after your import)
# locale
from pida.core.locale import Locale
locale = Locale('bugreport')
_ = locale.gettext
If your service uses a glade file :
locale = locale
in your PidaGladeView?. Here is an example :
class BugreportView(PidaGladeView):
gladefile = 'bugreport'
locale = locale
...
2/ Search all strings to be translated
Every title, option title, and help text, must be wrapped with _(). for example :
label_text = 'Bug Report'
You replace it by :
label_text = _('Bug Report')
When building a view, don't :
- make a kiwi column with just a name, add the localized title !
- make string with multiple %s without a key. (bad: '%s:%s'. good: '%(key)s:%(value)s')
3/ Create first po file
Now, you want to create French translation of bugreport service, so let's use the locale.sh tool !
tools/locale.sh create bugreport fr_FR
4/ Editing pot
Using your favorite editor (Pida?!), and edit locale/fr_FR/LC_MESSAGES/bugreport.po
:)
How to update translation of a service ?
Do
tools/locale.sh update bugreport fr_FR
And edit locale/fr_FR/LC_MESSAGES/bugreport.po
Simple ? :)
How to update translation of pida ?
Do
tools/locale.sh update pida <lang>
And edit pida/resources/locale/<lang>/LC_MESSAGES/pida.po
