TRANSLATORS howto (take 2)

Jon Lapham lapham at extracta.com.br
Tue Jun 3 18:16:13 CDT 2003


Here is the updated version.  Basically, the only difference is that it 
has all of Derek's suggestions in place.

-- 
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
  Jon Lapham  <lapham at extracta.com.br>          Rio de Janeiro, Brasil
  Work: Extracta Moléculas Naturais SA     http://www.extracta.com.br/
  Web: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------

-------------- next part --------------
HOWTO: Translating GnuCash

Most modern linux distributions will come with gnucash and the development 
packages necessary to compile it.  The idea of this document is to give you
step-by-step instructions on how to update translations for the gnucash
project.  

Sections:

1) Get the source from CVS
2) Mailing lists
3) Contact the maintainer of your language
4) Compile 
5) Install and run
6) The glossary file
7) Initial processing of the translation file
8) Translating the .po file
9) Testing and submitting your translations
10) Problems
11) How to translate the GnuCash manual
12) How to translate the files containing the new account hierarchies

==============================================================================
1) Get the source from CVS

The first thing to do is to download the latest STABLE branch of gnucash
from CVS and get it to compile.  Do not use the HEAD branch, since the text
in the HEAD branch changes so much, it would be a waste of time to translate 
it.  Do not worry, when the HEAD branch becomes stable, the existing 
translations in the STABLE branch will be merged.  Your work will not be lost.

Login (password is "guest") to the CVS server:
cvs -d :pserver:cvs at cvs.gnucash.org:/home/cvs/cvsroot login

cvs -d :pserver:cvs at cvs.gnucash.org:/home/cvs/cvsroot checkout \
        -rgnucash-1-8-branch gnucash

After this initial CVS checkout, you can update your CVS files using:

cvs -d :pserver:cvs at cvs.gnucash.org:/home/cvs/cvsroot update gnucash

==============================================================================
2) Mailing lists

You should subscribe to 2 mailing lists: gnucash-devel and gnucash-patches.

To subscribe, go the the gnucash web site, and follow the links to the 
mailing lists:
http://www.gnucash.org/
http://www.gnucash.org/en/lists.phtml

The gnucash-devel mailing list is a good place to send technical questions 
you have about doing the translations.  The gnucash-patches list is where 
you will send your updated translation files.

Another excellent place to get help is on IRC, as many of the developers hang
out there and are eager to help.  Go to the #gnucash channel at 
"irc.gnome.org".  If you don't know what that mean, fire up an IRC client 
(for example, xchat), connect to irc.gnome.org and then type "/join 
#gnucash".

==============================================================================
3) Contact the maintainer of your language

To find out who is the last person to work on your language, look near the 
top of the po/XXXX.po file which corresponds to your language.   If your 
language does not have a .po file available, you can build one my issuing 
this command:

FIXME: command to build a new .po file

The beginning of your .po file should look something similar to this:

# Localization for Portuguese-Brazil
# Copyright (C) 2003 Free Software Foundation, Inc.
# Jon Lapham <lapham at extracta.com.br>, 2003
# Jose Carlos Nascimento - <joseca at psabs.com>, 2001.
# 
msgid ""
msgstr ""
"Project-Id-Version: GnuCash 1.8.3\n"
"POT-Creation-Date: 2003-05-16 16:42-0300\n"
"PO-Revision-Date: 2003-06-02 12:00-0300\n"
"Last-Translator: Jon Lapham <lapham at extracta.com.br>\n"
"Language-Team: NONE \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

Look to see who the "Last-translator" was, and send an email to that person 
and ask what you can do to help.  This is important because if there already 
is an active maintainer of the translation file, you should interact directly
with him or her.  If there is not Last-translator, or that person is not 
maintaining the file actively (and tells you to take over), you will become 
the maintainer and you should change the "Last-translator" to your name and 
email address.

==============================================================================
4) Compile 

Before starting to work on your translations, I suggest making sure you can 
compile the gnucash source code.  This way you can get your system set up 
correctly with all the development packages you need.  It is a good idea
to actually run gnucash with your new translations because it is quite 
helpful to see the phrases in the context of the running program.

Enter the gnucash directory and run the autogen.sh script.  There are many 
options available when compiling gnucash, see the README.cvs file for more
information on the options.  For now, we will just enable debugging and 
change the default prefix because these two changes will be handly later 
for tracking down problems and installing multiple versions.

cd gnucash
./autogen.sh --enable-debug --prefix=/opt/gnucash-1.8

If autogen complains about missing development packages, find them on your
favorite OS distribution, install it, and try to re-run the autogen command.
Eventually, you should be able to get autogen to run without any error 
messages.

Note: there are some warnings that spew forth during autogen.  Do not worry
about them, apparently they are normal.

Next, compile gnucash:

make

Note: when you are configuring and building gnucash, do *not* run the 
configure script, aclocal, autoconf, or any other programs.  EVEN IF THE 
AUTOGEN OUTPUT SUGGESTS THAT THEY DO.  This is important, and has caused a 
lot of confusion.  Unfortunately the auto tools complain and cause bogus 
warnings.

==============================================================================
5) Install and run

To install (assuming "make" completed without any problems) you must be 
root.  

su - 
make install

After installation, insure that it works by running (as a normal user,
no need to be root here):

/opt/gnucash-1.8/bin/gnucash

It is a good idea to use absolute paths like this to insure you run 
the proper gnucash executable.  To run your OS pre-installed version of
gnucash, usually you can type:

/usr/bin/gnucash

In either case, you can easily switch between the various languages the 
gnucash has available by placing the LANG env var before the call to the
executable:

LANG=pt_BR /opt/gnucash-1.8/bin/gnucash

==============================================================================
6) The glossary file

Inside the po/glossary/ directory should be a "glossary" file for your 
language.  This file contains a bunch of commonly used terms found in gnucash.
It is recommended that you get this file translated first, and use it as a 
guide when translating the real .po file.  

Go into the glossary directory and rebuild your language's glossary file:

cd po/glossary/
./txt-to-pot.sh gnc-glossary.txt > gnc-glossary.pot

If your .po glossary file does not exist, use this gnc-glossary.pot file to
create it:

cp gnc-glossary.pot XXXX.po

If your .po glossary file does exist, use the msgmerge program to update it:

/usr/bin/msgmerge -o XXXX.po XXXX.po gnc-glossary.pot

Now, open your language's glossary file and translate it completely.

==============================================================================
7) Initial processing of the translation file

Before you begin actualy translation work, you should update the gnucash.pot 
file and use this to update your .po file.  This process will insure that 
you have the latest translatable strings.

cd po/
rm gnucash.pot
make gnucash.pot

If your language file does not exist, use the gnucash.pot file as a template
for it:

cp gnucash.pot XXXX.po

If your laguage file does exist, update it using the msgmerge program:

/usr/bin/msgmerge -o XXXX.po XXXX.po gnucash.pot

The top of the .po file should be editted somewhat.  The comments at the 
top of the file should be changed to be current:

# Messages in Deutsch für GnuCash
# Copyright (C) 1999 Free Software Foundation, Inc.
# Jan-Uwe Finck <Jan-Uwe.Finck at bigfoot.de>, 1999.

Make sure that the header of your .po file contains this line:
"Plural-Forms: nplurals=2; plural=n != 1;\n"

...and that you change the "Last-translator" string to your name.

==============================================================================
8) Translating the .po file

Finally.  You are ready to do some translating!

Here is an example of translating some text into German:

Before:
#: messages-i18n.c:11
msgid ""
"The GnuCash personal finance manager.\n"
"The GNU way to manage your money!"
msgstr ""

After, the tranlation in the de.po file:

#: messages-i18n.c:11
msgid ""
"The GnuCash personal finance manager.\n"
"The GNU way to manage your money!"
msgstr ""
"GnuCash: Ihr persönlicher Finanzmanager.\n"
"Der GNU-Weg, ihr Geld zu verwalten !"

You should read through every translation in the .po file at least once.  
If you translate a string that has the phrase "#, fuzzy" in the comments
above it, remove the word fuzzy.   A fuzzy translation means that the 
computer guessed what the translation should be.

After you finish translating, you should not have any "#, fuzzy" strings left.

For example:

#: messages-i18n.c:35
#, fuzzy, c-format
msgid ""
"There was an error writing the file\n"
"     %s\n"
"\n"
"%s"
msgstr ""
"Es gab einen Fehler beim Öffnen der Datei. \n"
"     %s."

You need to correct the translated string and remove the 'fuzzy' keyword.
For example:

#: messages-i18n.c:35
#, c-format
msgid ""
"There was an error writing the file\n"
"     %s\n"
"\n"
"%s"
msgstr ""
"Es gab einen Fehler beim Öffnen der Datei. \n"
"     %s."

Notice that the comment "c-format" was not removed.  That is correct, you 
should leave that.

When you see the comment "c-format", it means that the format codes in the 
tranlatable string are referring to C formatting codes.  So, '%s' means text, 
'%d' means an integer, etc...

==============================================================================
9) Testing and submitting your translations

You must check that your new translations are programatically correct (ie: 
that there are no unclosed quotes, etc).  To do this, use the msgfmt program

/usr/bin/msgfmt -c --statistics XXXX.po

This will report any errors in your .po file if it finds them.

If you want to see your translations within a running version of gnucash,
simply place your .po file in you CVS copy of the gnucash source code (which
you have previously installed) and from within the po/ directory type (you
may nee to be root to do this):

make install

Now you can run gnucash with your ned translations:

LANG=XXXX /opt/gnucash-1.8/bin/gnucash

When you are happy with the new translation file, email a gzipped version
of it to the gnucash-patches mailing list.

gzip XXXX.po
(email this file using your favorite mail client)

==============================================================================
10) Problems

When you see this error message during autogen.sh run:

configure.in:1219: error: `intl/Makefile' is already registered with
AC_CONFIG_FILES.
autoconf/status.m4:844: AC_CONFIG_FILES is expanded from...
configure.in:1219: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
autoheader: /usr/bin/autom4te failed with exit status: 1
**Error**: autoheader failed.

Reload the configure.in script:
cvs up -C configure.in

---------------------------------
If you see any "Gtk-CRITICAL" messages while running gnucash, it is probably
because you translated a string differently than how it exists in some other
gnome library.  You must discover which string you tranlated differently, and
change the translation to exactly match that of the gnome libraries.

To do this, you need to run gnucash under gdb:

LANG=XXXX /opt/gnucash-1.8/bin/gnucash-env gdb /usr/bin/guile

Then, from within gdb, issue:
run -e main -s /opt/gnucash-1.8/libexec/gnucash/overrides/gnucash --g-fatal-warnings

Eventually, gnucash should crash (becuase of the --g-fatal-warnings 
directive), when it does, issue from within gdb:

backtrace

You should see some output that looks like this:

#0  0xffffe002 in ?? ()
#1  0x42028a73 in abort () from /lib/tls/libc.so.6
#2  0x4019d3d8 in g_logv () from /usr/lib/libglib-1.2.so.0
#3  0x4019d414 in g_log () from /usr/lib/libglib-1.2.so.0
#4  0x40500fdd in gtk_type_check_object_cast () from 
/usr/lib/libgtk-1.2.so.0
#5  0x407292e5 in gnc_mdi_tweak_menus (mc=0x825adb0) at gnc-mdi-utils.c:574
#6  0x40729d13 in gnc_mdi_child_changed_cb (mdi=0x8266fd8, prev_child=0x0,
     data=0x8265fd8) at gnc-mdi-utils.c:861

Notice position #5 which has "gnc_mdi_tweak_menus at 
gnc-mdi-utils.c:574"?  Open that source file and find line 574:

573:  widget = gnc_mdi_child_find_menu_item(mc, "_View/_Toolbar");
574:  gtk_signal_handler_block_by_data(GTK_OBJECT(widget), info);

So, the problem is with the translation of "_View/_Toolbar".  The "/" is a 
menu seperator, so you now know that the problem is with either the 
translation of "_View" or "_Toolbar".  By switching to an English gnucash
and looking through your .po file, you should be able to find the problem.
Change the offending translation to whatever you see in the gnucash app.
Remember that the translations must contain the proper underscores.

==============================================================================
11) How to translate the GnuCash manual

This section describes the actions needed to translate the manual.

1) Create a new directory doc/sgml/<locale> (where <locale> is
   something like es, en_GB, or pt_PT).
2) Copy the files from doc/sgml/C into this directory.
3) Recreate the image files in doc/sgml/C/gnucash so that they are
   appropriate to the locale.
4) Edit all the sgml files and translate for the locale.

==============================================================================
12) How to translate the files containing the new account hierarchies

This section describes the actions needed to translate the files
containing the new account hierarchies.

1) Create a new directory accounts/<locale>.
2) Copy the acctchrt_* files from accounts/C to accounts/<locale>
3) Do not change any xml tags.
For each file:
4) Change the gnc-act:title, gnc-act:short-description, and
   gnc-act:long-description to contain appropriately translated text.
   Do not add any newlines in the long description except at the end
   and begining of the string.
5) For each gnc:account in the file translate the act:name, and
   act:description fields.  Please do not translate any other fields.

Note: You absolutely don't need to translate all of the files from
accounts/C.  A subset of those are fine as well. Probably several of
them will not apply to your local legislative/economic system anyway.
For a really customized account hierarchy you might better create a
new account hierarchy file in GnuCash, and then, by hand-editing the
xml code, split it up into several files and cut&paste the appropriate
tags from the accounts/C/acctchrt_* files.

----------------------------------------------------------------------

Thanks so very much to all the translators for their hard effort and
excellent work.


More information about the gnucash-devel mailing list