Changes

Jump to: navigation, search

Translating Gramps

1,041 bytes added, 28 June
m
<abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>,
As an extension to standard gettext, strings in Gramps can have a context prefix. This prefix should '''not''' be translated, and just be deleted in the translation. More info and an example [[#Translation context|further down]].
As a special context, you will see the manual context, eg <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, :
'manual|Editing_Dates'
these strings should only be translated if a '''wiki user manual''' is available in your language, eg <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, in Dutch :
'Datums_aanpassen'
The string refers to a section, eg <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, [[Gramps_4.1_Wiki_Manual_-_Entering_and_Editing_Data:_Detailed_-_part_1#Editing_dates |Editing_Dates]] in Dutch becomes [[Gramps_4.1_Wiki_Manual_-_Entering_and_Editing_Data:_Detailed_-_part_1/de#Daten_bearbeiten|Datums_aanpassen]].
===Testing your <code>.po</code> file===
-------- %d mismatches --------------
You can see that there are 3816 strings to be translated and the coverage is around 96 %. There are still 12 untranslated strings and some 120 fuzzies. The last one can be ok, but should be checked. Additional information shows <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g. </abbr>, that in 15 strings there is a mismatch with the 'last character':
-------- last character not identical ---------
msg nr: 98, lineno: 602
* Check fuzzy messages and translate all untranslated messages in <code>newlang.po</code>. When you are sure everything is right, rename <code>newlang.po</code> as <code>lang.po</code> and check it into Git as you did with the original file.
* If command <code>msgmerge</code> is not available on your system, you have to install the <code>gettext</code> package. For [http://wiki.wxpython.org/index.cgi/Internationalization#How_to_get_gettext_tools_for_Win32 windows users].
* To back-port translations, <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, to merge master branch translations onto an earlier branch, do this on the earlier branch (assuming gramps.pot is updated):
<pre>msgmerge -C lang.po master-lang.po gramps.pot -o newlang.po</pre>. Then resolve the fuzzies as usual.
Actually you don't even need to install the files in order to test them. This is useful because you can develop Gramps without needing superuser privileges. Bear in mind the Gramps i18n process goes something like this when you use the master branch:
* when you type <code>python build</code> in the source tree root (/home/user/Gramps <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>) all the po/*.po files are compiled into build/mo/{lang}/*.mo files.
* when you type <code>python install</code> inside the po directory, these .mo files are copied to {prefix}/share/locale/{lang}/LC_MESSAGES as gramps.mo files.
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<abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, change
<object class="GtkLabel" id="label3">
:into
<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<abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, change
<property name="label" translatable="yes">Name:</property>
:into
<property name="label" translatable="yes">place|Name:</property>
* In the corresponding dialog initialization, add code to set the string to the correct translation during runtime, <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>,:
:globally in the file:
PLACE_NAME = _('place|Name:')
for widget_name in ('name_btn1', 'name_btn2'):
self.get_widget(widget_name).set_label(PLACE_NAME)
:The exact method to call on the Gtk control will be different based on the actual GUI element affected. E<abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, a GtkButton has a set_label method, whereas a GtkLabel has a set_text.
* Regenerate the POT, translate the new PO strings, and test your work.
===Translating mnemonics keys(Keyboard Shortcut keys)===
Mnemonics are accelerator keys (also known as Keyboard Shortcut keys) you find in labels, accessible by pressing the {{man key press|ALT}} key together with the mnemonic. You see then in the translated text with a low line, eg <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, '_Help' is shown as 'Help' with a line under the H, and can be put to focus/selected by pressing {{man key press|ALT|h}}.
It is nice if mnemonics on a screen are unique, but it is not required. If you use twice the same mnemonic, the user must press repeatedly the accelerator to switch between the different entries. However, note the following rule:
{{man warn|Warning|Some fonts family will not properly display mnemonics on "g", "j", "p", "q" or "y" as these print the letter over the line under it making it very hard to distinguish the small line. Please avoid to use mnemonics key bindings on these letters. Also try to avoid i and l, as people have difficulty distinguishing between those.}}
Capital letters are no problem though, underlining eg <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, G will work just fine as the letter does not write over the line.
===Translating relationships===
Translating relationships is not done within the <code>.po</code> files, except for occasional <code>father</code> and <code>mother</code> strings here and there in the interfaces and reports. Complete translation of all relationships for the language/culture is done inside a relationship calculator plugin.
In short, the need for a plugin comes from the impossibility to translate "first cousin twice removed" in languages such as, <abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, German or Russian. See the [[Relationship Calculator]] page for details on why and how to create such a plugin.
===Translating dates===
Note that reports/tools link to a section in the page with the same name as the report name in Gramps.
*You should be able to edit directly on wiki or using tools like [http://translate.sourceforge.net/wiki/toolkit/txt2po txt2po] or [http://po4a.alioth.debian.org/ po4a]. Also previous gettext file for the manual and [http://en.wikipedia.org/wiki/Translation_memory Translation Memory] may help you to upgrade deprecated/old gettext files. eg<abbr title="exempli gratia - Latin phrase meaning 'for example'">e.g.</abbr>, store existing entries from ''/usr/share/locale''.
==Language specific pages==
2,785
edits

Navigation menu