Changes

Jump to: navigation, search

Translating Gramps

3,953 bytes added, 17:17, 28 June 2021
m
Translating mnemonics keys(Keyboard Shortcut keys)
The page [[Coding_for_translation|coding for translation]] may also be of interest to translators.
Please read [[Category:A Translators/Categories]][[Category:Developers/GeneralGuide to Git]]
==Gettext file format==
===Getting started===
# Always save your translations in UTF-8 encoding '''without [https://en.wikipedia.org/wiki/Byte-order_mark BOM]''' ([http://achilles-keep-moving.blogspot.de/2011/10/msgfmt-fatal-error-with-utf-8-with-bom.html take care with ''NotePad''])
# Don't overwrite the English strings, your translation should be below the original string
# Take heed on special characters. You must have the same number of and types as the original string.
===Obtaining gramps.pot===
* Download <code>gramps.pot</code> from Gramps Git repository, see [[Brief_introduction_to_Git| the introduction to Git]].
You can also download files by browsing via [https://github.com/gramps-project/gramps GitHub web interface].
* Look for <code>gramps.pot</code> in the '''po''' directory.
===Translating messages===
* Copy <code>gramps.pot</code> to the file named <code>lang.po</code>, according to the language you are translating into (<code>fr.po</code> for French, <code>ru.po</code> for Russian, etc.)
* Use [http://gtranslator.sourceforge.net GTtranslator] (GNOME, windows), [http://i18n.kde.org/tools/ KBabel] (KDE), [http://userbase.kde.org/Lokalize Lokalize] (KDE, windows), Emacs po-mode, [http://translatevirtaal.sourceforgetranslatehouse.net/wiki/pootling/index pootlingorg Virtaal] (GNU/Linux, Mac, windows), [http://www.poedit.net/ poedit] (GNU/Linux, OSX, windows), or any similar tool designed for translating <code>.po</code> files. If you do not like any of these tools, you can use any text editor to translate messages. If using vim, properly setting the "langmap" option will significantly speed up your work.* Even though GRAMPS Gramps uses UNICODE (UTF-8) for its character set, you may use your native character set for your translation. Just make sure you specify the character set you are using in the <code>Content-Type</code> line in the <code>.po</code> file. Gramps will handle the conversion to UNICODE.
* If there are non ASCII characters in the original English string, try to preserve them by copying them, if applicable.
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_3Gramps_4.3_Wiki_Manual_1_Wiki_Manual_-_Entering_and_Editing_Data:_Detailed_-_part_1#Editing_dates |Editing_Dates]] in Dutch becomes [[Gramps_3Gramps_4.3_Wiki_Manual_1_Wiki_Manual_-_Entering_and_Editing_Data:_Detailed_-_part_1/de#Daten_bearbeiten|Datums_aanpassen]].
===Testing your <code>.po</code> file===
 
{{man warn|Environment change|For Gramps 4.0, {{stable_branch}} and master, see [[Translation_environment4|new environment]].}}
 
In the <code>po</code> directory run the command: <pre>make</pre> If there are errors in your po file, this will fail and give you an error message. You should correct these errors. If you have trouble understanding the error, try to run the next test, which might give a more verbose output.
-------- %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
===Formatting (compiling) <code>.po</code> file===
* Currently, [[Coding_for_translation#How_it_works|formatting (msgfmt) is performed during build time]], so you should not have to worry about it. The translated <code>.po</code> file is the product of your work. However, try to [[Translating_Gramps#Save_as_.mo_file|check syntax]] before any commit. ===Send your contribution=== Check it into Git if you obtained the permission to do so, or email it . The following configuration option simplifies pushing a branch back to [[Contact|Brian or Benny]] otherwisethe server: $ git config --global push.default upstream Otherwise you can fork gramps repository with a Github account and pull a merge requestSee: {{Code Browser}}
===Updating your translation===
Assuming you have obtained originally the Gramps source tree as explained in [[Brief introduction to Git]]. Now:
* Update your Gramps tree from Git. This can be done by executing the command <pre>git pull--rebase</pre> from the root Gramps directory. This will download an updated <code>gramps.pot</code> file.
* Use your outdated translation to translate the strings that did not change:<pre>msgmerge lang.po gramps.pot -o newlang.po</pre> or <pre>msgmerge --no-wrap lang.po gramps.pot -o newlang.po</pre> where <code>lang</code> is your language code. The <code>--no-wrap</code> option will prevent changes due to automatic word wrapping, use it if your previous po file was constructed like that. The <code>--no-wrap</code> options allows for more readable Git diffs.
* 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 eariler 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.
cd po
python update_po -m all
in the <code>po</code> directory. This assumes that you have already succesfully successfully configured the source. Note, this command ignores <code>--no-wrap</code> option, so not practical for Git diffs.
{{man warn|Environment change|For Gramps 4.0 , {{stable_branch}} and master, see [[Translation_environment4|new environment]].}}
===Testing your update===
===Installing your translation===
{{man warn|Environment change|For Gramps 4.0 , {{stable_branch}} and master, see [[Translation_environment4|new environment]].}}
You want to use the new translation immediately, and systemwide?
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.
===== gramps.sh =====
On a gramps launcher (copy from ''<code>{prefix}/bin/gramps</code>'') you can set :
export GRAMPSDIR=/...
export GRAMPSI18N=/...
==Hard to translate phrases==
Some things are just hard to translate. Below are a few of the more difficult items, along with some suggestions on how to handle them.
===Gramps terminology===
There are terms with special significance in computer software. The terms are often creatively awkward constructs in English... just so the term is more unique and stands out in a sentence. Translating the words literally or substituting a translation of the underlying concept may not be workable. It may be necessary to become ''creative'' and substitute a similarly awkward (and short!) label in your target language.
 
The labels of some Gramps core concepts or interface elements hold that higher level of significance. These must be translated consistently between the User Interface and the Wiki. (Inconsistent translations will confuse the users.)
 
''Example:'' The '''[[Gramps_Glossary#active_person|Active Person]]''' in Gramps is not a person with a healthy amount of vigorous physical exercise. Instead, it is the record from the [[Gramps_Glossary#people|People]] [[Gramps_Glossary#category|Category]] that is the focal center of reference for display &amp; change. Neither would translate into a memorable label.
 
The [[Gramps Glossary]] is a good resource for understanding the context and significance of such terms. If you translate the Glossary and then alphabetize the translated terms, also leave an ID SPAN with the untranslated English term. This allows hotlinks from untranslated pages to work in unison with translated hotlinks.
 
If it becomes necessary to be ''creative'' translating a term, please add a [[Translating_Gramps#Language_specific_pages|language specific]] reference page for your language. This helps other Translators share your style of creativity.
 
===LDS terminology===
The Church of Jesus Christ of Latter Day Saints (a.k.a. Mormons) maintains a lot of genealogy data. In the United States, they are probably the non-government organization with the most detailed records available. Genealogical research is important to the Mormon church. They are responsible for defining the [[GEDCOM]] format.
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 an underline 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:
So you should check in your language what the mnemonic key is for those buttons, and avoid using the same in translated text
'''{{man warn|Warning''': some |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===
==Translating man pages==
{{man warn|Environment change|For gramps 4.0 , {{stable_branch}} and master, see [[Translation_environment4#Translating_man_pages|new environment]].}}
You can also translated the man pages into your own language.
First off all you must make a directory for your language under data/man.
<code>
cd data/man
</code>
<code>cd data/man</code> and do  <code> mkdir xx</code>
where xx is your languagecode (fr for French, sv for Swedish, etc.) You should use Git. See [[Brief_introduction_to_Git| the introduction to Git]].
git push
You should see no errors when you run the  <code> ./configure</code><br/> <code>make</code> <br/>scripts.
{{man warn|Install|This last step must be done only in the data/man/xx directory. If not, your normal gramps installation will be overwritten. And this step must be done as superuser(su)}}
<code>
sudo make install
</code>
This will put the gramps.1.gz file into /usr/local/share/man/xx/man1 directory. You could also use a prefix. Then you do:<code>
sudo make --prefix=/usr/share install
</code>
<code>sudo make install</code> This will put the gramps.1.gz file into /usr/local/share/man/xx/man1 directory. You could also use a prefix. Then you do: <code>sudo make --prefix=/usr/share install</code> To see the result of your work, do: <code> man -L xx gramps</code>
==Translating wiki manual==
To have enable the weblink for help when pressing the link working {{man button|F1}} button in the Grampsprogram, you need to have or edit the GrampsDisplay.py file <code>MANUALS</code> variable to contain your language.On line 30 of that file, you seecode locale in the:
[https://github.com/gramps-project/gramps/blob/master/gramps/gui/display.py display.py] file for Gramp 4.x or greater
 
or
 
GrampsDisplay.py file for Gramps 3.x or earlier
 
 
 
On approximately line 41 of that file, you may see:
 
#list of manuals on wiki, map locale code to wiki extension, add language codes
#completely, or first part, so pt_BR if Brazilian portugeze wiki manual, and
#nl for Dutch (nl_BE, nl_NL language code)
MANUALS = {
'nl' : '/nl',
}
This maps These entries map a language code to the extension used on the wiki, so to add french, change this too:
MANUALS = {
}
*Every '<code>manual|...</code>' entry in the <code>gramp.pot </code> file refers to a section in the manual, so make sure to use good section headings so this does not change too much over time.
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==
* See [[Addons_development#Get_translators_to_translate_your_addon_into_multiple_languages|3rd-party addon for Gramps]].
 
[[Category:Translators/Categories]]
[[Category:Developers/General]]
4,609
edits

Navigation menu