Difference between revisions of "Translating Gramps"

From Gramps
Jump to: navigation, search
(Formatting (compiling) .po file)
(Updating your translation: what is template.po? if I'm wrong please correct it)
Line 129: Line 129:
 
Assuming you have obtained originally the GRAMPS source tree as explained in [[Brief introduction to SVN]]. Now:
 
Assuming you have obtained originally the GRAMPS source tree as explained in [[Brief introduction to SVN]]. Now:
 
* Update your gramps tree from SVN. This can be done by executing the command <pre>svn up</pre> from the root GRAMPS svn directory. This will download an updated <code>gramps.pot</code> file.
 
* Update your gramps tree from SVN. This can be done by executing the command <pre>svn up</pre> from the root GRAMPS svn 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 template.po -o newlang.po</pre> or <pre>msgmerge --no-wrap lang.po template.po -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 SVN diffs.
+
* 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 SVN diffs.
 
* 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 SVN as you did with the original file.
 
* 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 SVN 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#head-d8e0d98b64f3878f8bb828aeb41a05bcc6a02cc4  windows users].
 
* 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#head-d8e0d98b64f3878f8bb828aeb41a05bcc6a02cc4  windows users].

Revision as of 08:44, 8 February 2009

Tips for translators of the GRAMPS program.

Gettext file format

Header

msginit is a GNU utility, called on /po directory, which generates a header for gettext file template : gramps.pot.

msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2004-12-30 10:52-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

msgid / msgstr / comment / fuzzy

# gramps.py:10
#, fuzzy
msgid "File not found"
msgstr ""
  1. text after # provides a comment, the file reference and the line number. This will help translator but is optional for having a translation.
  2. msgid is the string, present on gramps' code
  3. msgstr is your translation

fuzzy could be added because string is not up-to-date. It means that there was a change somewhere (a string has been added, removed or modified) and xgettext did a guess on what the translation should be. This guess is most likely not entirely correct, but it is often very close.

Tips for translators

Getting started

  1. Always save your translations in UTF-8 encoding
  2. Don't overwrite the English strings, your translation should be below the original string
  3. Take heed on special characters. You must have the same number of and types as the original string.
  4. Verify spelling and grammar on your translation.
  5. Don't translate "too freely". Your translation should be as close match to the original as possible
  6. Be consistent with your translations. If you decide on a specific word/phrase for something, stick to that throughout the translation.
  7. If possible, try the translation before sending

Translating GRAMPS into a new language means translating English strings used in the GRAMPS interface. To put it shortly, this amounts to

  1. obtaining the gramps.pot file with the strings to be translated,
  2. translating the strings in the template, and
  3. getting the translated file uploaded into gramps SVN repository.

Another avenue of translation is translating the documentation. This is a different and lengthy process and it is decribed in our Translating the manual page. Here we will concentrate on the interface translation only.

Obtaining gramps.pot

  • Download gramps.pot from GRAMPS SVN repository, see the introduction to SVN.
  • Look for gramps.pot in the directory gramps30/po or if you looking for the trunk version look for gramps.pot in the directory trunk/po.

Translating messages

  • Copy gramps.pot to the file named lang.po, according to the language you are translating into (fr.po for French, ru.po for Russian, etc.)
  • Use GTtranslator (GNOME), KBabel (KDE), Emacs po-mode, pootling (GNU/Linux, windows), poedit (GNU/Linux, OSX, windows), or any similar tool designed for translating .po files. If you do not like any of these tools, you can use any text editor to translate messages.
  • Even though 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 Content-Type line in the .po file. GRAMPS will handle the conversion to UNICODE.

Context

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 further down.

As a special context, you will see the manual context, eg :

'manual|Editing_Dates'

these strings should only be translated if a wiki manual is available in your language. The string refers to a section, eg Editing_Dates in Dutch becomes Datums_aanpassen.

Testing your .po file

check_po

  1. In the directory gramps30/po or the trunk/po run the command:
    make
    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.
  2. In the directory gramps30/po or the trunk/po run the command:
    ./check_po lang.po
    where lang is your language code. This will give you errors in your translation, information on badly translated phrases, ... the output could resemble something like this..
File:               nl.po
Template total:     3816
PO total:           3671
Fuzzy:              125
Untranslated:       12
%s mismatches:      0
%d mismatches:      2
%() name mismatches:9
%() missing s/d:    0
Runaway context:    0
XML special chars:  0
Last character:     15
Shortcut in msgstr: 16
PO Coverage:        99.67%
Template Coverage:  95.89%
-------- %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 e.g. that in 15 strings there is a mismatch with the 'last character':

-------- last character not identical ---------
msg nr: 98, lineno: 602
msgid "Could not make database directory: "
msgstr "Kon geen gegevensbestandsmap aanmaken"

This is very valuable information, because you can easily see what the problem is, even if you do not understand the language! Clearly the last characters must be ": "

  1. In the directory gramps30/po or the trunk/po run the command:
    msgfmt --statistics lang.po
    where lang is your language code. This should not throw an error.
  • Basically this gives the same info in a condensed format: 3533 translated messages, 125 fuzzy translations, 12 untranslated messages.

GNU `gettext' utilities

GNU `gettext' utilities provides a few stand-alone programs to massage in various ways the sets of translatable strings, or already translated strings:

msgattrib - attribute matching and manipulation on message catalog
msgcat - combines several message catalogs
msgcmp - compare message catalog and template
msgcomm - match two message catalogs
msgconv - character set conversion for message catalog
msgen - create English message catalog
msgexec - process translations of message catalog
msgfilter - edit translations of message catalog
msgfmt - compile message catalog to binary format (.po->.mo)
msggrep - pattern matching on message catalog
msginit - initialize a message catalog
msgmerge - merge message catalog and template
msgunfmt - uncompile message catalog from binary format
msguniq - unify duplicate translations in message catalog

For checking syntax :

msgfmt -c nl.po

Formatting (compiling) .po file

  • Currently, formatting is performed during build time, so you should not have to worry about it. The translated .po file is the product of your work. Check it into SVN if you obtained the permission to do so, or email it to Brian or Benny otherwise.

Updating your translation

If you have submitted a translation, changes are that after some weeks/months, new strings are added to GRAMPS, implying you need to update your translation file.

Assuming you have obtained originally the GRAMPS source tree as explained in Brief introduction to SVN. Now:

  • Update your gramps tree from SVN. This can be done by executing the command
    svn up
    from the root GRAMPS svn directory. This will download an updated gramps.pot file.
  • Use your outdated translation to translate the strings that did not change:
    msgmerge lang.po gramps.pot -o newlang.po
    or
    msgmerge --no-wrap lang.po gramps.pot -o newlang.po
    where lang is your language code. The --no-wrap option will prevent changes due to automatic word wrapping, use it if your previous po file was constructed like that. The --no-wrap options allows for more readable SVN diffs.
  • Translate all untranslated messages in newlang.po. When you are sure everything is right, rename newlang.po as lang.po and check it into SVN as you did with the original file.
  • If command msgmerge is not available on your system, you have to install the }gettext package. For windows users.

There is also the make target that does the following:

  • Create new gramps.pot template from the source code files
  make gramps.pot
  • Updates each po file in the source tree

It may be an overkill for you, but if you feel like using it, you can run:

  make update-po

in the po directory. This assumes that you have already succesfully configured the source.

Testing your update

You can test your update easily with the above mentioned check_po file. If you downloaded this file, just do:

python check_po newlang.po

. If everything is ok, the output will be something like this:

File:               newlang.po
Template total:     3075
PO total:           3075
Fuzzy:              0
Untranslated:       0
%s mismatches:      0
%d mismatches:      0
%() name mismatches:0
%() missing s/d:    0
Runaway context:    0
XML special chars:  0
Last character:     0
Shortcut in msgstr: 0
PO Coverage:        100.00%
Template Coverage:  100.00%

Installing your translation

You want to use the new translation immediately, and systemwide? You can by installing just the contents of the po directory, but you will need to build the source first, so:

./autogen.sh
make
cd po
make --prefix=/usr/share install     #as root !

This should install your translations to /usr/share/locale/xx/LC_MESSAGES/gramps.mo, with xx your language. You could of course copy your files manually to that dir with the gramps.mo name.

Make sure you only install from within the po directory, or you will install the development version of GRAMPS, which is not supported and for testing only!

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.

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.

The LDS Church has some specific terminology that can present difficulty in translating. There are two approaches to handling the information.

  1. If the LDS Church has a presence in your country, contact the LDS Temple in your area and ask them what the correct terminology is in your native language
  2. If the LDS Church does not have a presence in your country, it would probably be safe to simply not translate the phrases.

These terms include:

  1. LDS Ordinance names:
    • Sealed to Parents
    • Sealed to Spouse
    • LDS Baptism
    • Endowment
  2. LDS Status names for Ordinances:
    • Child
    • Cleared
    • Completed
    • Infant
    • Pre-1970
    • Qualified
    • Stillborn
    • Submitted
    • Uncleared
    • BIC (Born In the Covenant)
    • DNS (Do Not Submit)
    • Canceled
    • DNS/CAN (Do Not Submit/Previous sealing cancelled)


Advanced issues

Format line parameters

Format line parameters such as %s and %d should not be translated. The order of these parameters should not be changed. Examples:

English:

   Long widowhood: %s was a widow %d years.

Translation (using Backward English as an example :-):

   Gnol doohwodiw: %s saw a wodiw %d sraey.

Named format line parameters such as %(something)s and %(something)d also should not be translated. Feel free to change the order of named parameters to correctly phrase the message in your language. Also, use hints provided by the names. Examples:

English:

   Baptized before birth: %(male_name)s
           born %(byear)d, baptized %(bapyear)d.

Translation into Backward English:

   Dezitpab erofeb htrib: %(byear)d
           nrob %(male_name)s, dezitpab %(bapyear)d.

In the above example, the verb "born" should be in masculine form (if verbs in your language have gender, that is), since the person born is apparently a male.

Sometimes those %(something)s are positioned in a text without spaces, like in the example below:

English:

   This person was baptised%(endnotes)s.

Translation into Backward English:

   Siht nosrep saw desitpab%(endnotes)s.

Translation context

In some cases, two different concepts can be expressed by the same word in English and yet require different translations. For example, the title of the book and the nobility title of the person are expressed by the same Title word. However, in other languages different words are needed to describe the book title and the person's title.

To mitigate such problems, a context can be added to the translation string. A context-enabled string has a vertical line separating the context from the string:

book|Title
person|Title

The correct translation should not include either the context or the separator. The context is to give the translator idea of what the string means. However, both the context and the separator must not be in the translated string, so in backward english the above is translated into

Eltitkoob
Eltitnosrep

Plural forms

There was requests for plural forms support.

First, translators need to check if information is available on .po header. (See samples)

  1. msgid contains the singular string in english
  2. msgid_plural contains the plural string in english
  3. msgstr[0] contains the singular translated version (for 1 and sometimes 0, set on header)
  4. msgstr[1] contains the plural version (for 1 + 1 = 2 )
  5. msgstr[2] contains the plural form (for 2 + 1 = 3)
  • For language with one form (singular=plural, Plural-Forms: nplurals=1; plural=0), like Chinese, Hungarian or Turkish:
msgid "%d second"
msgstr_plural "%d seconds"
msgstr [0] "%d 秒"
  • For language with one plural form (Plural-Forms: nplurals=2; plural=n != 1;), like english:
msgid "%d hour"
msgstr_plural "%d hours"
msgstr [0] "%d hour"
msgstr [1] "%d hours"
  • For language with more plural forms (like Czech):
msgid "%d second"
msgstr_plural "%d seconds"
msgstr [0] "%d sekunda"
msgstr [1] "%d sekundy"
msgstr [2] "%d sekund"

As a final check, please do ensure that the following command does not throw any errors:

msgfmt -c filename.po

Translating mnemonics

Mnemonics are accelerator keys you find in labels, accessible by pressing the ALT key together with the mnemonic. You see then in the translated text with a low line, eg '_Help' is shown as 'Help' with a line under the H, and can be put to focus/selected by pressing 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: "If duplication of access keys in a window is unavoidable, you should still refrain from duplicating the access keys for any of these buttons that appear in the same window: OK, Cancel, Close, Apply or Help."

So you should check in your language what the mnemonic key is for those buttons, and avoid using the same in translated text

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 G will work just fine as the letter does not write over the line.

Translating relationships

Translating relationships is not done within the .po files, except for occasional father and mother 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, e.g., German or Russian. See the Relationship Calculator page for details on why and how to create such a plugin.

Translating dates

Handling date translation is not entirely done within the .po files. Complete handling of date translation for each language/culture is done inside a dedicated date handler module.

The need for a separate module comes from the requirements to handle culture-specific parsing and displaying of dates. For example, the month and day order is different between most European countries and the US. Also, each language has its own set of acceptable modifier and qualifiers for the date: things like "from X to Y" or "between X and Y" may have different word order. Same with "around", "calculated", "estimated". Add to this calendar names, and you have a compelling need for a dedicated module. See the Date Handler page for details on why and how to create such a module.

Translating man pages

You can also translated the man pages into your own language.

For the development (trunk) version you can find the required starting files under the directory (/trunk)/data/man. You will find the files

  • Makefile.am
  • gramps.1.in

First off all you must make a directory for your language under data/man.

  cd data/man

and do

  mkdir xx

where xx is your languagecode (fr for French, sv for Swedish, etc.) You should use SVN. See the introduction to SVN. Then do

  svn add xx
  svn commit -m "xx dir for man pages" xx

This will add the xx dir under svn revision control and upload the new dir. Next step is to copy the Makefile.am and gramps.1.in from data/man to your new directory. Translate all relevant strings in the data/man/xx/gramps.1.in file. Change the file data/man/xx/Makefile.am:

  • add the line mandir = @mandir@/xx
  • change the line && CONFIG_FILES=data/man/xx/$@ $(SHELL)

Next step: change the file data/man/Makefile:

  • add xx to the line SUBDIRS = fr nl sv

The final step is to alter the file Configure.in :

  • add data/man/xx/Makefile to the line AC_CONFIG_FILES([

Because you added new files, SVN requires that you set the correct propset for those files. Two things are to be done.

  svn propset svn:mime-type text/plain xx/gramps.1.in xx/Makefile.am
  svn propset svn:eol-type native xx/gramps.1.in xx/Makefile.am

You could also in the config file of subversion ( HOMEDIR/.subversion/config) enable the auto-prop feature (enable-auto-props = yes) and uncomment the relevant lines in the [auto-props] section. All changes must be committed and do not forget to change the ChangeLog file.

You should see no errors when you run the

 ./configure
 make

scripts.

Gnome-important.png
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)

 sudo make install

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:

 sudo make --prefix=/usr/share install

To see the result of your work, do:

  man -L xx gramps

Translating wiki manual

To have the link working in GRAMPS, you need to have or edit the GrampsDisplay.py file to contain your language. On line 30 of that file, you see:

MANUALS = {
   'nl' : '/nl',
}

This maps a language code to the extension used on the wiki, so to add french, change this too:

MANUALS = {
   'nl' : '/nl',
   'fr':  '/fr',
}
  • Every 'manual|...' entry in the gramp.pot 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 txt2po. Also previous gettext file for the manual and Translation Memory may help you to upgrade deprecated/old gettext files.

Translating third-party plugins

As Third-party Plugins are not officially part of GRAMPS and are not supported by the GRAMPS Developers but give users more tools to work with your genealogy data in GRAMPS, we can translate them ! Trying to avoid dupplicate strings which could generate conflicts, here an additional template. We should be able to copy/paste references at the end of main translation file for supporting translation on third-party plugins.