Jump to: navigation, search

Translating Gramps

1,733 bytes added, 11:56, 29 January 2014
Translation context
If you are a Gramps translator and need a developer to help you add a context to the Gramps source files, please ask for it on the gramps-devel list.
====Translation context in GUI labels====
If there is a string in the Glade GUI (i.e., in a .glade source file) that requires the translation context, it's impossible to have it translated statically. In this case, one needs to add runtime code to the corresponding dialog initialization to override the label string with the text obtained with an sgettext call. I.e.,
* Verify the relevant widget has a meaningful id in the .glade file (as opposed to a silly autogenerated one). Modify the id if needed and make sure no existing code used the old widget id! E.g., change
<object class="GtkLabel" id="label3">
<object class="GtkLabel" id="place_name_label">
* Add a context to the translatable string in the .glade file. This way, when you look at the POT file or a PO file derived from it, you see a reference to this place, along with the actual place in the .py file(s) which also has the same context string. E.g., change
<property name="label" translatable="yes">Name:</property>
<property name="label" translatable="yes">place|Name:</property>
* In the corresponding dialogs' initialization, add code to set the string to the correct translation during runtime, e.g.:
:globally in the file:
PLACE_NAME = _('place|Name:')
:in the MergePlace.__init__ method:
for widget_name in ('name_btn1', 'name_btn2'):
:The exact method to call on the Gtk control will be different based on the actual GUI element affected. E.g., a GtkButton has a set_label method, whereas a GtkLabel has a set_text.
===Plural forms===

Navigation menu