Difference between revisions of "Translation environment4"

From Gramps
Jump to: navigation, search
(See also)
(35 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This page describes the next translation environment.
+
{{man note|Current|This page describes the current translation environment used for Gramps '''4.0.x''' to Gramps master.}}
  
See [[GEPS_026:_Replace_'make'_for_Gramps_build|Replace make]]. ''work in progress'' (testing stage)
+
==Usage==
  
Could be used for Gramps '''4.0.x'''.
+
To generate an updated translation template catalog eg:<code>gramps.pot</code>:
 +
python update_po.py -p
  
==How it works==
+
Update the existing translation <code>xx.po</code> file where ''xx'' is your language code:
 +
python update_po.py -m it.po
 +
    Merge it.po with current template.... done.
 +
    Updated file: 'updated_it.po'.
  
* intltool (perl), gettext
+
{{stub}}
  
intltool-update -p
+
The python program <code>update_po.py</code>, is a parser that uses [http://docs.python.org/library/xml.etree.elementtree.html ElementTree] and [http://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/xgettext-Invocation.html xgettext].
or run:
 
genpot.sh
 
 
 
* python, ElementTree[http://docs.python.org/library/xml.etree.elementtree.html] and xgettext[http://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/xgettext-Invocation.html]
 
  
 +
<pre>
 
  python update_po.py -h
 
  python update_po.py -h
 
  python update_po.py --help
 
  python update_po.py --help
 +
    usage: update_po.py [-h] [-t] [-x] [-g] [-c] [-p] [-m {all, xx.po}] [-k {all, xx.po}] [-u {xx.po}] [-f {xx.po}]
 +
 +
    This program generates a new template and also provides some common features.
 +
 +
    optional arguments:
 +
      -h, --help            show this help message and exit
 +
      -t, --test            test if 'python' and 'gettext' are properly installed
 +
      -x, --xml            extract messages from xml based file formats
 +
      -g, --glade          extract messages from glade file format only
 +
      -c, --clean          remove created files
 +
      -p, --pot            create a new catalog
 +
 +
    Update:
 +
      Maintenance around translations
 +
      -m                    merge lang.po files with last catalog
 +
      -k                    check lang.po files
 +
 +
    Translation:
 +
      Display content of translations file
 +
      -u                    list untranslated messages
 +
      -f                    list fuzzy messages
 +
 
  python update_po.py [options]
 
  python update_po.py [options]
 +
</pre>
  
For generating a new template:
 
python update_po.py -p
 
  
 
* ''parser'' generates a new template and also provides some common features.
 
* ''parser'' generates a new template and also provides some common features.
Line 32: Line 54:
 
** merge flag (-m) will merge '''lang.po file(s)''' with last catalog.
 
** merge flag (-m) will merge '''lang.po file(s)''' with last catalog.
 
** check flag (-k) will check '''lang.po file(s)''', will try to compile and will also use ''check_po'' script.
 
** check flag (-k) will check '''lang.po file(s)''', will try to compile and will also use ''check_po'' script.
* ''translation'' options are some informations about one translation file.
+
* ''translation'' options provide some information about one translation file.
 
** untranslate flag (-u) will list untranslated messages on '''lang.po file'''.
 
** untranslate flag (-u) will list untranslated messages on '''lang.po file'''.
 
** fuzzy flag (-f) will list fuzzy messages on '''lang.po file'''.
 
** fuzzy flag (-f) will list fuzzy messages on '''lang.po file'''.
 +
 +
==== Alternate ways ====
 +
* Using: intltool (perl), gettext
 +
 +
intltool-update -p
 +
 +
which should be considered as incomplete, see [[Talk:Translation_environment4|differences between tools]].
 +
 +
* xgettext and shell
 +
 +
[https://github.com/gramps-project/gramps/blob/master/po/genpot.sh genpot.sh]
  
 
===Files and directory===
 
===Files and directory===
Line 51: Line 84:
 
  gramps/plugins/patchnames.py
 
  gramps/plugins/patchnames.py
 
  ...
 
  ...
 +
 +
We can still check if some references are missing via:
 +
$ intltool-update -m
  
 
==Translating man pages==
 
==Translating man pages==
  
You can also translated the man pages into your own language.
+
You can also translate the [https://en.wikipedia.org/wiki/Man_page man pages]  (short for '''manual page''' a form of software documentation on Linux systems) into your own language.
  
For the development (trunk) version you can find the required starting files under the directory /data/man.
+
For the development version (master branch) you can find the required starting files under the directory [https://github.com/gramps-project/gramps/tree/master/data/man /data/man].
  
 
You need at least [http://docutils.sourceforge.net/ docutils package].
 
You need at least [http://docutils.sourceforge.net/ docutils package].
  
You will find the files
+
Some of the files you will find in the <code>data/man</code> directory are:
*update_man.py
+
*<code>update_man.py</code>
*en.rst
+
*<code>en.rst</code>
*gramps.1
+
*<code>gramps.1</code>
 +
 
 +
First off all you must make a directory for your language under [https://github.com/gramps-project/gramps/tree/master/data/man data/man].
  
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>
+
and on Linux run the following command <code>mkdir xx</code>
  mkdir xx
 
</code>
 
  
where xx is your languagecode (fr for French, sv for Swedish, etc.) You should use SVN. See [[Brief_introduction_to_SVN| the introduction to SVN]]. Then do <code>
+
where <code>xx</code> is your two letter [https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes language code] (fr for French, sv for Swedish, etc.)  
  svn add xx
 
  svn commit -m "xx dir for man pages" xx
 
</code>
 
This will add the xx dir under svn revision control and upload the new dir.
 
  
Next step is to copy the en.rst from data/man to your new directory and rename it to your langage code.
+
Next step is to copy the <code>en.rst</code> from <code>data/man</code> to your new directory and rename it to your language code eg: <code>fr.rst</code> for French.
  
Translate all relevant strings in the data/man/xx/xx.rst file.  
+
Then translate all relevant strings in the <code>data/man/xx/xx.rst</code> file.  
  
Edit the file data/man/update_man.py by adding your lang
+
Edit the file [https://github.com/gramps-project/gramps/blob/master/data/man/update_man.py data/man/update_man.py] and search for following line <code>LANGUAGES = ['sv', 'nl', 'pl', 'cs', 'pt_BR', 'fr', 'xx']</code> where 'xx' is your new language. Save the file.
  
 
Run data/man/update_man.py:
 
Run data/man/update_man.py:
<code>  
+
<code>$ python update_man.py -m</code>
$ python update_man.py -m
 
</code>
 
  
Because you added new files, SVN requires that you set the correct propset for those files. Two things are to be done.
+
All changes must be committed and pushed to your server (You should use Git. See [[Brief_introduction_to_Git| the introduction to Git]].):
<code>
+
git commit -am "Add man page for xx"
  svn propset svn:mime-type text/plain xx/gramps.1
+
git push
  svn propset svn:eol-type native xx/gramps.1
 
</code>
 
  
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.
+
To see the result of your work, do:<code>$ man xx/gramps.1</code>
All changes must be committed and do not forget to change the ChangeLog file.
 
  
To see the result of your work, do:<code>
+
==See also==
  man xx/gramps.1
+
* [[Translating Gramps]]
</code>
+
* [[Translation environment22]]
 +
* [[Translation environment4]]
 +
* See [[GEPS 026: Replace 'make' for Gramps build|Replace make]]. ''completed in 2012 for the release of Gramps 4.0''
  
 
[[Category:Translators/Categories]]
 
[[Category:Translators/Categories]]
 
[[Category:Developers/General]]
 
[[Category:Developers/General]]

Revision as of 06:28, 8 January 2017

Gramps-notes.png
Current

This page describes the current translation environment used for Gramps 4.0.x to Gramps master.

Usage

To generate an updated translation template catalog eg:gramps.pot:

python update_po.py -p

Update the existing translation xx.po file where xx is your language code:

python update_po.py -m it.po
    Merge it.po with current template.... done.
    Updated file: 'updated_it.po'.
Gramps-notes.png

This article's content is incomplete or a placeholder stub.
Please update or expand this section.


The python program update_po.py, is a parser that uses ElementTree and xgettext.

 python update_po.py -h
 python update_po.py --help
     usage: update_po.py [-h] [-t] [-x] [-g] [-c] [-p] [-m {all, xx.po}] [-k {all, xx.po}] [-u {xx.po}] [-f {xx.po}]

     This program generates a new template and also provides some common features.

     optional arguments:
       -h, --help            show this help message and exit
       -t, --test            test if 'python' and 'gettext' are properly installed
       -x, --xml             extract messages from xml based file formats
       -g, --glade           extract messages from glade file format only
       -c, --clean           remove created files
       -p, --pot             create a new catalog

     Update:
       Maintenance around translations
       -m                    merge lang.po files with last catalog
       -k                    check lang.po files

     Translation:
       Display content of translations file
       -u                    list untranslated messages
       -f                    list fuzzy messages

 python update_po.py [options]


  • parser generates a new template and also provides some common features.
    • test flag (-t) will test if 'python' and 'gettext' are properly installed.
  • extract options are everything around extraction for message strings.
    • xml flag (-x) will extract messages from xml based, ini and desktop files.
    • glade flag (-g) will extract messages from glade file format only.
    • clean flag (-c) will remove created files.
    • pot flag (-p) will create a new catalog.
  • update options are everything around update for translation file(s).
    • merge flag (-m) will merge lang.po file(s) with last catalog.
    • check flag (-k) will check lang.po file(s), will try to compile and will also use check_po script.
  • translation options provide some information about one translation file.
    • untranslate flag (-u) will list untranslated messages on lang.po file.
    • fuzzy flag (-f) will list fuzzy messages on lang.po file.

Alternate ways

  • Using: intltool (perl), gettext
intltool-update -p

which should be considered as incomplete, see differences between tools.

  • xgettext and shell
genpot.sh

Files and directory

Like with previous environment, we need to list files with translation strings for retrieving messages and generating a 'po/gramps.pot' file. Process is now only using gettext and python.

  • gettext, 'POTFILES.in' and 'POTFILES.skip' files

If you want a script to take your translatable strings into account, you must add your source file path in the file : po/POTFILES.in. For this report example, you should add:

...
gramps/plugins/leak.py
gramps/plugins/mediamanager.py
gramps/plugins/myreport.py                # <------
gramps/plugins/narrativeweb.py
gramps/plugins/patchnames.py
...

We can still check if some references are missing via:

$ intltool-update -m

Translating man pages

You can also translate the man pages (short for manual page a form of software documentation on Linux systems) into your own language.

For the development version (master branch) you can find the required starting files under the directory /data/man.

You need at least docutils package.

Some of the files you will find in the data/man directory are:

  • update_man.py
  • en.rst
  • gramps.1

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

cd data/man

and on Linux run the following command mkdir xx

where xx is your two letter language code (fr for French, sv for Swedish, etc.)

Next step is to copy the en.rst from data/man to your new directory and rename it to your language code eg: fr.rst for French.

Then translate all relevant strings in the data/man/xx/xx.rst file.

Edit the file data/man/update_man.py and search for following line LANGUAGES = ['sv', 'nl', 'pl', 'cs', 'pt_BR', 'fr', 'xx'] where 'xx' is your new language. Save the file.

Run data/man/update_man.py: $ python update_man.py -m

All changes must be committed and pushed to your server (You should use Git. See the introduction to Git.):

git commit -am "Add man page for xx"
git push

To see the result of your work, do:$ man xx/gramps.1

See also