gettext: Prioritizing messages
1
1 12.7 Prioritizing messages: How to determine which messages to translate first
1 ==============================================================================
1
1 A translator sometimes has only a limited amount of time per week to
1 spend on a package, and some packages have quite large message catalogs
1 (over 1000 messages). Therefore she wishes to translate the messages
1 first that are the most visible to the user, or that occur most
1 frequently. This section describes how to determine these "most urgent"
1 messages. It also applies to determine the "next most urgent" messages
1 after the message catalog has already been partially translated.
1
1 In a first step, she uses the programs like a user would do. While
1 she does this, the GNU ‘gettext’ library logs into a file the not yet
1 translated messages for which a translation was requested from the
1 program.
1
1 In a second step, she uses the PO mode to translate precisely this
1 set of messages.
1
1 Here a more details. The GNU ‘libintl’ library (but not the
1 corresponding functions in GNU ‘libc’) supports an environment variable
1 ‘GETTEXT_LOG_UNTRANSLATED’. The GNU ‘libintl’ library will log into
1 this file the messages for which ‘gettext()’ and related functions
1 couldn’t find the translation. If the file doesn’t exist, it will be
1 created as needed. On systems with GNU ‘libc’ a shared library
1 ‘preloadable_libintl.so’ is provided that can be used with the ELF
1 ‘LD_PRELOAD’ mechanism.
1
1 So, in the first step, the translator uses these commands on systems
1 with GNU ‘libc’:
1
1 $ LD_PRELOAD=/usr/local/lib/preloadable_libintl.so
1 $ export LD_PRELOAD
1 $ GETTEXT_LOG_UNTRANSLATED=$HOME/gettextlogused
1 $ export GETTEXT_LOG_UNTRANSLATED
1
1 and these commands on other systems:
1
1 $ GETTEXT_LOG_UNTRANSLATED=$HOME/gettextlogused
1 $ export GETTEXT_LOG_UNTRANSLATED
1
1 Then she uses and peruses the programs. (It is a good and
1 recommended practice to use the programs for which you provide
1 translations: it gives you the needed context.) When done, she removes
1 the environment variables:
1
1 $ unset LD_PRELOAD
1 $ unset GETTEXT_LOG_UNTRANSLATED
1
1 The second step starts with removing duplicates:
1
1 $ msguniq $HOME/gettextlogused > missing.po
1
1 The result is a PO file, but needs some preprocessing before a PO
1 file editor can be used with it. First, it is a multi-domain PO file,
1 containing messages from many translation domains. Second, it lacks all
1 translator comments and source references. Here is how to get a list of
1 the affected translation domains:
1
1 $ sed -n -e 's,^domain "\(.*\)"$,\1,p' < missing.po | sort | uniq
1
1 Then the translator can handle the domains one by one. For
1 simplicity, let’s use environment variables to denote the language,
1 domain and source package.
1
1 $ lang=nl # your language
1 $ domain=coreutils # the name of the domain to be handled
1 $ package=/usr/src/gnu/coreutils-4.5.4 # the package where it comes from
1
1 She takes the latest copy of ‘$lang.po’ from the Translation Project,
1 or from the package (in most cases, ‘$package/po/$lang.po’), or creates
1 a fresh one if she’s the first translator (see ⇒Creating). She
1 then uses the following commands to mark the not urgent messages as
1 "obsolete". (This doesn’t mean that these messages - translated and
1 untranslated ones - will go away. It simply means that the PO file
1 editor will ignore them in the following editing session.)
1
1 $ msggrep --domain=$domain missing.po | grep -v '^domain' \
1 > $domain-missing.po
1 $ msgattrib --set-obsolete --ignore-file $domain-missing.po $domain.$lang.po \
1 > $domain.$lang-urgent.po
1
1 The she translates ‘$domain.$lang-urgent.po’ by use of a PO file
1 editor (⇒Editing). (FIXME: I don’t know whether ‘KBabel’ and
1 ‘gtranslator’ also preserve obsolete messages, as they should.) Finally
1 she restores the not urgent messages (with their earlier translations,
1 for those which were already translated) through this command:
1
1 $ msgmerge --no-fuzzy-matching $domain.$lang-urgent.po $package/po/$domain.pot \
1 > $domain.$lang.po
1
1 Then she can submit ‘$domain.$lang.po’ and proceed to the next
1 domain.
1