Updated translations, provided by the #! community. These have been

completed by:

	arl - German
	Hanna Pietikäinen - Finnish
	benji - French
	Alon Horn - Hebrew
	papparonny - Norwegian
This commit is contained in:
2009-01-26 19:32:03 +00:00
parent 72dcbe4f31
commit 648b5e23fc
20 changed files with 553 additions and 488 deletions

View File

@@ -5,3 +5,4 @@ python-build-stamp*
debian/oblogout
debian/*.log
debian/oblogout.*
debian/files

1
debian/files vendored
View File

@@ -1 +0,0 @@
oblogout_0.2-1-0ubuntu1_i386.deb misc extra

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -60,7 +60,7 @@ class OpenboxLogout():
# Start logger and gettext/i18n
self.logger = logging.getLogger('OpenboxLogout')
gettext.install('openboxlogout', '%s/locale' % self.determine_path(), unicode=1)
gettext.install('oblogout', '%s/locale' % self.determine_path(), unicode=1)
# Start dbus interface
bus = dbus.SystemBus()
@@ -111,8 +111,8 @@ class OpenboxLogout():
self.window.add(self.mainpanel)
for button in self.button_list:
self.add_button(button, self.buttonpanel)
self.add_button(button, self.buttonpanel)
if self.rendered_effects == True:
self.logger.debug("Stepping though render path")
w = gtk.gdk.get_default_root_window()
@@ -147,6 +147,9 @@ class OpenboxLogout():
self.window.set_app_paintable(True)
self.window.resize(gtk.gdk.screen_width(), gtk.gdk.screen_height())
self.window.realize()
print self.buttonpanel.get_allocation().width
if pixmap:
self.window.window.set_back_pixmap(pixmap, False)
self.window.move(0,0)

View File

@@ -0,0 +1,99 @@
# German translation for oblogout
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
# This file is distributed under the same license as the oblogout package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: oblogout\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-01-17 23:39+0000\n"
"PO-Revision-Date: 2009-01-26 13:49+0000\n"
"Last-Translator: arl <Unknown>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-01-26 15:52+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: openboxlogout.py:209
#, python-format
msgid "Button %s is not a valid button name, removing"
msgstr "%s ist keine gültige Beschriftung, entferne die Beschriftung"
#: openboxlogout.py:218
msgid "Can't Hibernate, disabling button"
msgstr "Hibernate ist nicht möglich, diese Funktion wird deaktiviert"
#: openboxlogout.py:222
msgid "Can't Safe Suspend, disabling button"
msgstr ""
"Kann nicht in den \"Safe Suspend\"-Modus wechseln, diese Funktion wird "
"deaktiviert."
#: openboxlogout.py:214
msgid "Can't Suspend, disabling button"
msgstr ""
"Kann nicht in den \"Suspend\"-Modus wechseln, diese Funktion wird deaktiviert"
#: openboxlogout.py:187
#, python-format
msgid "Color %s is not a valid color, defaulting to black"
msgstr ""
"Die Farbe %s ist keine gültige Farbe. Verwende die Standardfarbe schwarz"
#: openboxlogout.py:226
msgid "No valid buttons found, resetting to defaults"
msgstr ""
"Es wurden keine gültigen Schaltflächen gefunden, setze die Einstellung auf "
"den Standardwert zurück"
#: openboxlogout.py:54
msgid "Openbox Logout"
msgstr "Openbox Logout"
#: openboxlogout.py:142
msgid "Unable to determin the module path, exiting..."
msgstr "Der Mudolpfad konnte nicht gefunden werden, breche ab"
#: openboxlogout.py:154
#, python-format
msgid "Unable to find config file %s"
msgstr "Kann die Konfigurationsdatei %s nicht finden"
#: openboxlogout.py:192
msgid "cancel"
msgstr "abbrechen"
#: openboxlogout.py:192
msgid "hibernate"
msgstr "Ruhezustand"
#: openboxlogout.py:192
msgid "lock"
msgstr "sperren"
#: openboxlogout.py:192
msgid "logout"
msgstr "abmelden"
#: openboxlogout.py:192
msgid "restart"
msgstr "Neustart"
#: openboxlogout.py:192
msgid "safesuspend"
msgstr "sicherer Suspend"
#: openboxlogout.py:192
msgid "shutdown"
msgstr "Herunterfahren"
#: openboxlogout.py:192
msgid "suspend"
msgstr "Ruhezustand"
#: openboxlogout.py:192
msgid "switch"
msgstr "wechseln"

View File

@@ -1,28 +1,47 @@
# English (United Kingdom) translation for oblogout
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
# This file is distributed under the same license as the oblogout package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: oblogout\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-01-17 23:39+0000\n"
"PO-Revision-Date: 2009-01-26 12:52+0000\n"
"Last-Translator: Andrew Williams <andy@tensixtyone.com>\n"
"Language-Team: English (United Kingdom) <en_GB@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-01-26 15:52+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: openboxlogout.py:209
#, python-format
msgid "Button %s is not a valid button name, removing"
msgstr "Button %s is not a valid button name, removing"
msgstr "Button %s is not a valid button name, Removing."
#: openboxlogout.py:218
msgid "Can't Hibernate, disabling button"
msgstr "Can't Hibernate, disabling button"
msgstr "Can't Hibernate, Disabling button."
#: openboxlogout.py:222
msgid "Can't Safe Suspend, disabling button"
msgstr "Can't Safe Suspend, disabling button"
msgstr "Can't Safe Suspend, Disabling button."
#: openboxlogout.py:214
msgid "Can't Suspend, disabling button"
msgstr "Can't Suspend, disabling button"
msgstr "Can't Suspend, Disabling button."
#: openboxlogout.py:187
#, python-format
msgid "Color %s is not a valid color, defaulting to black"
msgstr "Color %s is not a valid color, defaulting to black"
msgstr "Color %s is not a valid color, Defaulting to black."
#: openboxlogout.py:226
msgid "No valid buttons found, resetting to defaults"
msgstr "No valid buttons found, resetting to defaults"
msgstr "No valid buttons found, Resetting to defaults."
#: openboxlogout.py:54
msgid "Openbox Logout"
@@ -30,7 +49,7 @@ msgstr "Openbox Logout"
#: openboxlogout.py:142
msgid "Unable to determin the module path, exiting..."
msgstr "Unable to determin the module path, exiting..."
msgstr "Unable to determine the module path, Exiting."
#: openboxlogout.py:154
#, python-format
@@ -51,7 +70,7 @@ msgstr "Lock"
#: openboxlogout.py:192
msgid "logout"
msgstr "Logout"
msgstr "Log-out"
#: openboxlogout.py:192
msgid "restart"
@@ -71,4 +90,4 @@ msgstr "Suspend"
#: openboxlogout.py:192
msgid "switch"
msgstr "Switch User"
msgstr "Switch"

View File

@@ -1,74 +1,93 @@
# Finnish translation for oblogout
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
# This file is distributed under the same license as the oblogout package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: oblogout\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-01-17 23:39+0000\n"
"PO-Revision-Date: 2009-01-26 14:54+0000\n"
"Last-Translator: Hanna Pietikäinen <hannapie@online.de>\n"
"Language-Team: Finnish <fi@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-01-26 15:52+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: openboxlogout.py:209
#, python-format
msgid "Button %s is not a valid button name, removing"
msgstr "Button %s is not a valid button name, removing"
msgstr ""
#: openboxlogout.py:218
msgid "Can't Hibernate, disabling button"
msgstr "Can't Hibernate, disabling button"
msgstr ""
#: openboxlogout.py:222
msgid "Can't Safe Suspend, disabling button"
msgstr "Can't Safe Suspend, disabling button"
msgstr ""
#: openboxlogout.py:214
msgid "Can't Suspend, disabling button"
msgstr "Can't Suspend, disabling button"
msgstr ""
#: openboxlogout.py:187
#, python-format
msgid "Color %s is not a valid color, defaulting to black"
msgstr "Color %s is not a valid color, defaulting to black"
msgstr ""
#: openboxlogout.py:226
msgid "No valid buttons found, resetting to defaults"
msgstr "No valid buttons found, resetting to defaults"
msgstr ""
#: openboxlogout.py:54
msgid "Openbox Logout"
msgstr "Openbox Logout"
msgstr ""
#: openboxlogout.py:142
msgid "Unable to determin the module path, exiting..."
msgstr "Unable to determin the module path, exiting..."
msgstr ""
#: openboxlogout.py:154
#, python-format
msgid "Unable to find config file %s"
msgstr "Unable to find config file %s"
msgstr ""
#: openboxlogout.py:192
msgid "cancel"
msgstr "Cancel"
msgstr ""
#: openboxlogout.py:192
msgid "hibernate"
msgstr "Hibernate"
msgstr "Lepotila"
#: openboxlogout.py:192
msgid "lock"
msgstr "Lock"
msgstr "Lukitse"
#: openboxlogout.py:192
msgid "logout"
msgstr "Logout"
msgstr "Kirjaudu ulos"
#: openboxlogout.py:192
msgid "restart"
msgstr "Restart"
msgstr "Uudelleenkäynnistä"
#: openboxlogout.py:192
msgid "safesuspend"
msgstr "Safe Suspend"
msgstr ""
#: openboxlogout.py:192
msgid "shutdown"
msgstr "Shutdown"
msgstr "Sammuta"
#: openboxlogout.py:192
msgid "suspend"
msgstr "Suspend"
msgstr "Keskeytä"
#: openboxlogout.py:192
msgid "switch"
msgstr "Switch User"
msgstr "Vaihda"

View File

@@ -0,0 +1,93 @@
# French translation for oblogout
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
# This file is distributed under the same license as the oblogout package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: oblogout\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-01-17 23:39+0000\n"
"PO-Revision-Date: 2009-01-26 14:36+0000\n"
"Last-Translator: benji <Unknown>\n"
"Language-Team: French <fr@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-01-26 15:52+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: openboxlogout.py:209
#, python-format
msgid "Button %s is not a valid button name, removing"
msgstr "Le nom du bouton %s n'est pas valide, suppression"
#: openboxlogout.py:218
msgid "Can't Hibernate, disabling button"
msgstr "Impossible de mettre en hibernation, désactivation du bouton"
#: openboxlogout.py:222
msgid "Can't Safe Suspend, disabling button"
msgstr "Impossible de mettre en veille sécurisée, désactivation du bouton"
#: openboxlogout.py:214
msgid "Can't Suspend, disabling button"
msgstr "Impossible de mettre en veille prolongée, désactivation du bouton"
#: openboxlogout.py:187
#, python-format
msgid "Color %s is not a valid color, defaulting to black"
msgstr "La couleur %s n'est pas valide, la couleur par défaut est noir"
#: openboxlogout.py:226
msgid "No valid buttons found, resetting to defaults"
msgstr "Aucun bouton valide trouvé, réinitialisation des valeurs par défaut"
#: openboxlogout.py:54
msgid "Openbox Logout"
msgstr "OpenBox Déconnexion"
#: openboxlogout.py:142
msgid "Unable to determin the module path, exiting..."
msgstr "Impossible de déterminer le chemin du module, arrêt..."
#: openboxlogout.py:154
#, python-format
msgid "Unable to find config file %s"
msgstr "Impossible de trouver le fichier de configuration %s"
#: openboxlogout.py:192
msgid "cancel"
msgstr "Annuler"
#: openboxlogout.py:192
msgid "hibernate"
msgstr "Mise en hibernation"
#: openboxlogout.py:192
msgid "lock"
msgstr "Verrouiller"
#: openboxlogout.py:192
msgid "logout"
msgstr "Déconnexion"
#: openboxlogout.py:192
msgid "restart"
msgstr "Redémarrer"
#: openboxlogout.py:192
msgid "safesuspend"
msgstr ""
#: openboxlogout.py:192
msgid "shutdown"
msgstr "Arrêt"
#: openboxlogout.py:192
msgid "suspend"
msgstr "Mise en veille prolongée"
#: openboxlogout.py:192
msgid "switch"
msgstr "Changer d'utilisateur"

View File

@@ -0,0 +1,93 @@
# Hebrew translation for oblogout
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
# This file is distributed under the same license as the oblogout package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: oblogout\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-01-17 23:39+0000\n"
"PO-Revision-Date: 2009-01-26 14:56+0000\n"
"Last-Translator: Alon Horn <salonh@t2.technion.ac.il>\n"
"Language-Team: Hebrew <he@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-01-26 15:52+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: openboxlogout.py:209
#, python-format
msgid "Button %s is not a valid button name, removing"
msgstr "הכפתור %s אינו חוקי. מסיר."
#: openboxlogout.py:218
msgid "Can't Hibernate, disabling button"
msgstr "לא יכול לעבור למצב שינה. מכבה את הכפתור."
#: openboxlogout.py:222
msgid "Can't Safe Suspend, disabling button"
msgstr "לא יכול לעבור למצב השהיה בטוחה. מכבה את הכפתור."
#: openboxlogout.py:214
msgid "Can't Suspend, disabling button"
msgstr "לא יכול לעבור למצב השהיה. מכבה את הכפתור."
#: openboxlogout.py:187
#, python-format
msgid "Color %s is not a valid color, defaulting to black"
msgstr "הצבע %s אינו חוקי. משתמש בברירת המחדל שחור."
#: openboxlogout.py:226
msgid "No valid buttons found, resetting to defaults"
msgstr "לא נמצאו כפתורים חוקיים. מאתחל לברירות המחדל."
#: openboxlogout.py:54
msgid "Openbox Logout"
msgstr "יציאה מ Openbox"
#: openboxlogout.py:142
msgid "Unable to determin the module path, exiting..."
msgstr "לא מצליח לקבוע את הנתיב למודול. יוצא..."
#: openboxlogout.py:154
#, python-format
msgid "Unable to find config file %s"
msgstr "לא מצליח למצוא את קובץ התצורה %s"
#: openboxlogout.py:192
msgid "cancel"
msgstr "ביטול"
#: openboxlogout.py:192
msgid "hibernate"
msgstr "מצב שינה"
#: openboxlogout.py:192
msgid "lock"
msgstr "נעילה"
#: openboxlogout.py:192
msgid "logout"
msgstr "התנתק"
#: openboxlogout.py:192
msgid "restart"
msgstr "הפעלה מחדש"
#: openboxlogout.py:192
msgid "safesuspend"
msgstr "השהיה בטוחה"
#: openboxlogout.py:192
msgid "shutdown"
msgstr "כיבוי"
#: openboxlogout.py:192
msgid "suspend"
msgstr "המתנה"
#: openboxlogout.py:192
msgid "switch"
msgstr "החלף"

View File

@@ -0,0 +1,93 @@
# Norwegian Bokmal translation for oblogout
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
# This file is distributed under the same license as the oblogout package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: oblogout\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-01-17 23:39+0000\n"
"PO-Revision-Date: 2009-01-26 12:51+0000\n"
"Last-Translator: papparonny <ronny@olufsen.org>\n"
"Language-Team: Norwegian Bokmal <nb@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-01-26 15:52+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: openboxlogout.py:209
#, python-format
msgid "Button %s is not a valid button name, removing"
msgstr "Knapp %s er ikke et gyldig knappenavn, fjerner"
#: openboxlogout.py:218
msgid "Can't Hibernate, disabling button"
msgstr "Kan ikke gå i dvale, utelukker knapp"
#: openboxlogout.py:222
msgid "Can't Safe Suspend, disabling button"
msgstr "Trygg standby umulig, utelukker knapp"
#: openboxlogout.py:214
msgid "Can't Suspend, disabling button"
msgstr "Standby umulig, utelukker knapp"
#: openboxlogout.py:187
#, python-format
msgid "Color %s is not a valid color, defaulting to black"
msgstr "Farge %s er ikke en gyldig farge, bruker svart"
#: openboxlogout.py:226
msgid "No valid buttons found, resetting to defaults"
msgstr "Ingen gyldige knapper funnet, bruker standard"
#: openboxlogout.py:54
msgid "Openbox Logout"
msgstr "Openbox Logout"
#: openboxlogout.py:142
msgid "Unable to determin the module path, exiting..."
msgstr "Fant ikke stien til modulen, avslutter..."
#: openboxlogout.py:154
#, python-format
msgid "Unable to find config file %s"
msgstr "Fant ikke config-fil %s"
#: openboxlogout.py:192
msgid "cancel"
msgstr "avbryt"
#: openboxlogout.py:192
msgid "hibernate"
msgstr "gå i dvalemodus"
#: openboxlogout.py:192
msgid "lock"
msgstr "lås"
#: openboxlogout.py:192
msgid "logout"
msgstr "logg ut"
#: openboxlogout.py:192
msgid "restart"
msgstr "omstart"
#: openboxlogout.py:192
msgid "safesuspend"
msgstr "trygg standby"
#: openboxlogout.py:192
msgid "shutdown"
msgstr "slå av"
#: openboxlogout.py:192
msgid "suspend"
msgstr "standby"
#: openboxlogout.py:192
msgid "switch"
msgstr "bytt"

View File

@@ -0,0 +1,93 @@
# Norwegian Nynorsk translation for oblogout
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
# This file is distributed under the same license as the oblogout package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: oblogout\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-01-17 23:39+0000\n"
"PO-Revision-Date: 2009-01-26 13:22+0000\n"
"Last-Translator: papparonny <ronny@olufsen.org>\n"
"Language-Team: Norwegian Nynorsk <nn@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-01-26 15:52+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: openboxlogout.py:209
#, python-format
msgid "Button %s is not a valid button name, removing"
msgstr "Knapp %s er ikkje eit gyldig knappenamn, fjernar"
#: openboxlogout.py:218
msgid "Can't Hibernate, disabling button"
msgstr "Kan ikkje gå i dvale, utelukkar knapp"
#: openboxlogout.py:222
msgid "Can't Safe Suspend, disabling button"
msgstr "Trygg kvile umogleg, utelukkar knapp"
#: openboxlogout.py:214
msgid "Can't Suspend, disabling button"
msgstr "Kvile umogleg, utelukkar knapp"
#: openboxlogout.py:187
#, python-format
msgid "Color %s is not a valid color, defaulting to black"
msgstr "Farge %s er ikkje ein gyldig farge, brukar svart"
#: openboxlogout.py:226
msgid "No valid buttons found, resetting to defaults"
msgstr "Ingen gyldige knappar funne, brukar standard"
#: openboxlogout.py:54
msgid "Openbox Logout"
msgstr "Openbox Utlogging"
#: openboxlogout.py:142
msgid "Unable to determin the module path, exiting..."
msgstr "Fann ikkje stien til modula, avsluttar..."
#: openboxlogout.py:154
#, python-format
msgid "Unable to find config file %s"
msgstr "Fann ikke config-fil %s"
#: openboxlogout.py:192
msgid "cancel"
msgstr "avbryt"
#: openboxlogout.py:192
msgid "hibernate"
msgstr "dvalemodus"
#: openboxlogout.py:192
msgid "lock"
msgstr "lås"
#: openboxlogout.py:192
msgid "logout"
msgstr "logg ut"
#: openboxlogout.py:192
msgid "restart"
msgstr "omstart"
#: openboxlogout.py:192
msgid "safesuspend"
msgstr "trygg kvile"
#: openboxlogout.py:192
msgid "shutdown"
msgstr "slå av"
#: openboxlogout.py:192
msgid "suspend"
msgstr "kvilemodus"
#: openboxlogout.py:192
msgid "switch"
msgstr "Byt"

10
tools/gen-mo.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
cd openboxlogout/
for file in ./pofiles/*.po; do
lang=`echo $file | cut -d "-" -f 2 - | cut -d "." -f 1`
mkdir -p locale/$lang/LC_MESSAGES
msgfmt --output-file="locale/$lang/LC_MESSAGES/oblogout.mo" "$file"
done

View File

@@ -1,457 +0,0 @@
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
#
# PYTHON MODULE: MKI18N.PY
# =========
#
# Abstract: Make Internationalization (i18n) files for an application.
#
# Copyright Pierre Rouleau. 2003. Released to public domain.
#
# Last update: Saturday, November 8, 2003. @ 15:55:18.
#
# File: ROUP2003N01::C:/dev/python/mki18n.py
#
# RCS $Header: //software/official/MKS/MKS_SI/TV_NT/dev/Python/rcs/mki18n.py 1.5 2003/11/05 19:40:04 PRouleau Exp $
#
# Update history:
#
# - File created: Saturday, June 7, 2003. by Pierre Rouleau
# - 10/06/03 rcs : RCS Revision 1.1 2003/06/10 10:06:12 PRouleau
# - 10/06/03 rcs : RCS Initial revision
# - 23/08/03 rcs : RCS Revision 1.2 2003/06/10 10:54:27 PRouleau
# - 23/08/03 P.R.: [code:fix] : The strings encoded in this file are encode in iso-8859-1 format. Added the encoding
# notification to Python to comply with Python's 2.3 PEP 263.
# - 23/08/03 P.R.: [feature:new] : Added the '-e' switch which is used to force the creation of the empty English .mo file.
# - 22/10/03 P.R.: [code] : incorporated utility functions in here to make script self sufficient.
# - 05/11/03 rcs : RCS Revision 1.4 2003/10/22 06:39:31 PRouleau
# - 05/11/03 P.R.: [code:fix] : included the unixpath() in this file.
# - 08/11/03 rcs : RCS Revision 1.5 2003/11/05 19:40:04 PRouleau
#
# RCS $Log: $
#
#
# -----------------------------------------------------------------------------
"""
mki18n allows you to internationalize your software. You can use it to
create the GNU .po files (Portable Object) and the compiled .mo files
(Machine Object).
mki18n module can be used from the command line or from within a script (see
the Usage at the end of this page).
Table of Contents
-----------------
makePO() -- Build the Portable Object file for the application --
catPO() -- Concatenate one or several PO files with the application domain files. --
makeMO() -- Compile the Portable Object files into the Machine Object stored in the right location. --
printUsage -- Displays how to use this script from the command line --
Scriptexecution -- Runs when invoked from the command line --
NOTE: this module uses GNU gettext utilities.
You can get the gettext tools from the following sites:
- `GNU FTP site for gettetx`_ where several versions (0.10.40, 0.11.2, 0.11.5 and 0.12.1) are available.
Note that you need to use `GNU libiconv`_ to use this. Get it from the `GNU
libiconv ftp site`_ and get version 1.9.1 or later. Get the Windows .ZIP
files and install the packages inside c:/gnu. All binaries will be stored
inside c:/gnu/bin. Just put c:/gnu/bin inside your PATH. You will need
the following files:
- `gettext-runtime-0.12.1.bin.woe32.zip`_
- `gettext-tools-0.12.1.bin.woe32.zip`_
- `libiconv-1.9.1.bin.woe32.zip`_
.. _GNU libiconv: http://www.gnu.org/software/libiconv/
.. _GNU libiconv ftp site: http://www.ibiblio.org/pub/gnu/libiconv/
.. _gettext-runtime-0.12.1.bin.woe32.zip: ftp://ftp.gnu.org/gnu/gettext/gettext-runtime-0.12.1.bin.woe32.zip
.. _gettext-tools-0.12.1.bin.woe32.zip: ftp://ftp.gnu.org/gnu/gettext/gettext-tools-0.12.1.bin.woe32.zip
.. _libiconv-1.9.1.bin.woe32.zip: http://www.ibiblio.org/pub/gnu/libiconv/libiconv-1.9.1.bin.woe32.zip
"""
# -----------------------------------------------------------------------------
# Module Import
# -------------
#
import os
import sys
import wx
# -----------------------------------------------------------------------------
# Global variables
# ----------------
#
__author__ = "Pierre Rouleau"
__version__= "$Revision: 1.5 $"
# -----------------------------------------------------------------------------
def getlanguageDict():
languageDict = {}
for lang in [x for x in dir(wx) if x.startswith("LANGUAGE")]:
i = wx.Locale(wx.LANGUAGE_DEFAULT).GetLanguageInfo(getattr(wx, lang))
if i:
languageDict[i.CanonicalName] = i.Description
languageDict['en'] = 'English'
return languageDict
# -----------------------------------------------------------------------------
# m a k e P O ( ) -- Build the Portable Object file for the application --
# ^^^^^^^^^^^^^^^
#
def makePO(applicationDirectoryPath, applicationDomain=None, verbose=0) :
"""Build the Portable Object Template file for the application.
makePO builds the .pot file for the application stored inside
a specified directory by running xgettext for all application source
files. It finds the name of all files by looking for a file called 'app.fil'.
If this file does not exists, makePo raises an IOError exception.
By default the application domain (the application
name) is the same as the directory name but it can be overridden by the
'applicationDomain' argument.
makePO always creates a new file called messages.pot. If it finds files
of the form app_xx.po where 'app' is the application name and 'xx' is one
of the ISO 639 two-letter language codes, makePO resynchronizes those
files with the latest extracted strings (now contained in messages.pot).
This process updates all line location number in the language-specific
.po files and may also create new entries for translation (or comment out
some). The .po file is not changed, instead a new file is created with
the .new extension appended to the name of the .po file.
By default the function does not display what it is doing. Set the
verbose argument to 1 to force it to print its commands.
"""
if applicationDomain is None:
applicationName = fileBaseOf(applicationDirectoryPath,withPath=0)
else:
applicationName = applicationDomain
currentDir = os.getcwd()
os.chdir(applicationDirectoryPath)
if not os.path.exists('app.fil'):
raise IOError(2,'No module file: app.fil')
# Steps:
# Use xgettext to parse all application modules
# The following switches are used:
#
# -s : sort output by string content (easier to use when we need to merge several .po files)
# --files-from=app.fil : The list of files is taken from the file: app.fil
# --output= : specifies the name of the output file (using a .pot extension)
cmd = 'xgettext -s --no-wrap --files-from=app.fil --output=messages.pot'
if verbose: print cmd
os.system(cmd)
languageDict = getlanguageDict()
for langCode in languageDict.keys():
if langCode == 'en':
pass
else:
langPOfileName = "./pofiles/%s_%s.po" % (applicationName , langCode)
if os.path.exists(langPOfileName):
cmd = 'msgmerge -s --no-wrap "%s" messages.pot > "%s.new"' % (langPOfileName, langPOfileName)
if verbose: print cmd
os.system(cmd)
os.chdir(currentDir)
# -----------------------------------------------------------------------------
# c a t P O ( ) -- Concatenate one or several PO files with the application domain files. --
# ^^^^^^^^^^^^^
#
def catPO(applicationDirectoryPath, listOf_extraPo, applicationDomain=None, targetDir=None, verbose=0) :
"""Concatenate one or several PO files with the application domain files.
"""
if applicationDomain is None:
applicationName = fileBaseOf(applicationDirectoryPath,withPath=0)
else:
applicationName = applicationDomain
currentDir = os.getcwd()
os.chdir(applicationDirectoryPath)
languageDict = getlanguageDict()
for langCode in languageDict.keys():
if langCode == 'en':
pass
else:
langPOfileName = "./pofiles/%s_%s.po" % (applicationName , langCode)
if os.path.exists(langPOfileName):
fileList = ''
for fileName in listOf_extraPo:
fileList += ("%s_%s.po " % (fileName,langCode))
cmd = "msgcat -s --no-wrap %s %s > %s.cat" % (langPOfileName, fileList, langPOfileName)
if verbose: print cmd
os.system(cmd)
if targetDir is None:
pass
else:
mo_targetDir = "%s/%s/LC_MESSAGES" % (targetDir,langCode)
cmd = "msgfmt --output-file=%s/%s.mo %s_%s.po.cat" % (mo_targetDir,applicationName,applicationName,langCode)
if verbose: print cmd
os.system(cmd)
os.chdir(currentDir)
# -----------------------------------------------------------------------------
# m a k e M O ( ) -- Compile the Portable Object files into the Machine Object stored in the right location. --
# ^^^^^^^^^^^^^^^
#
def makeMO(applicationDirectoryPath,targetDir='./locale',applicationDomain=None, verbose=0, forceEnglish=0) :
"""Compile the Portable Object files into the Machine Object stored in the right location.
makeMO converts all translated language-specific PO files located inside
the application directory into the binary .MO files stored inside the
LC_MESSAGES sub-directory for the found locale files.
makeMO searches for all files that have a name of the form 'app_xx.po'
inside the application directory specified by the first argument. The
'app' is the application domain name (that can be specified by the
applicationDomain argument or is taken from the directory name). The 'xx'
corresponds to one of the ISO 639 two-letter language codes.
makeMo stores the resulting files inside a sub-directory of `targetDir`
called xx/LC_MESSAGES where 'xx' corresponds to the 2-letter language
code.
"""
if targetDir is None:
targetDir = './locale'
if verbose:
print "Target directory for .mo files is: %s" % targetDir
if applicationDomain is None:
applicationName = fileBaseOf(applicationDirectoryPath,withPath=0)
else:
applicationName = applicationDomain
currentDir = os.getcwd()
os.chdir(applicationDirectoryPath)
languageDict = getlanguageDict()
for langCode in languageDict.keys():
if (langCode == 'en') and (forceEnglish==0):
pass
else:
print langCode
langPOfileName = "./pofiles/%s_%s.po" % (applicationName , langCode)
if os.path.exists(langPOfileName):
mo_targetDir = "%s/%s/LC_MESSAGES" % (targetDir,langCode)
if not os.path.exists(mo_targetDir):
mkdir(mo_targetDir)
cmd = 'msgfmt --output-file="%s/%s.mo" "%s"' % (mo_targetDir,applicationName, langPOfileName)
if verbose: print cmd
os.system(cmd)
os.chdir(currentDir)
# -----------------------------------------------------------------------------
# p r i n t U s a g e -- Displays how to use this script from the command line --
# ^^^^^^^^^^^^^^^^^^^
#
def printUsage(errorMsg=None) :
"""Displays how to use this script from the command line."""
print """
##################################################################################
# mki18n : Make internationalization files. #
# Uses the GNU gettext system to create PO (Portable Object) files #
# from source code, coimpile PO into MO (Machine Object) files. #
# Supports C,C++,Python source files. #
# #
# Usage: mki18n {OPTION} [appDirPath] #
# #
# Options: #
# -e : When -m is used, forces English .mo file creation #
# -h : prints this help #
# -m : make MO from existing PO files #
# -p : make PO, update PO files: Creates a new messages.pot #
# file. Creates a dom_xx.po.new for every existing #
# language specific .po file. ('xx' stands for the ISO639 #
# two-letter language code and 'dom' stands for the #
# application domain name). mki18n requires that you #
# write a 'app.fil' file which contains the list of all #
# source code to parse. #
# -v : verbose (prints comments while running) #
# --domain=appName : specifies the application domain name. By default #
# the directory name is used. #
# --moTarget=dir : specifies the directory where .mo files are stored. #
# If not specified, the target is './locale' #
# #
# You must specify one of the -p or -m option to perform the work. You can #
# specify the path of the target application. If you leave it out mki18n #
# will use the current directory as the application main directory. #
# #
##################################################################################"""
if errorMsg:
print "\n ERROR: %s" % errorMsg
# -----------------------------------------------------------------------------
# f i l e B a s e O f ( ) -- Return base name of filename --
# ^^^^^^^^^^^^^^^^^^^^^^^
#
def fileBaseOf(filename,withPath=0) :
"""fileBaseOf(filename,withPath) ---> string
Return base name of filename. The returned string never includes the extension.
Use os.path.basename() to return the basename with the extension. The
second argument is optional. If specified and if set to 'true' (non zero)
the string returned contains the full path of the file name. Otherwise the
path is excluded.
[Example]
>>> fn = 'd:/dev/telepath/tvapp/code/test.html'
>>> fileBaseOf(fn)
'test'
>>> fileBaseOf(fn)
'test'
>>> fileBaseOf(fn,1)
'd:/dev/telepath/tvapp/code/test'
>>> fileBaseOf(fn,0)
'test'
>>> fn = 'abcdef'
>>> fileBaseOf(fn)
'abcdef'
>>> fileBaseOf(fn,1)
'abcdef'
>>> fn = "abcdef."
>>> fileBaseOf(fn)
'abcdef'
>>> fileBaseOf(fn,1)
'abcdef'
"""
pos = filename.rfind('.')
if pos > 0:
filename = filename[:pos]
if withPath:
return filename
else:
return os.path.basename(filename)
# -----------------------------------------------------------------------------
# m k d i r ( ) -- Create a directory (and possibly the entire tree) --
# ^^^^^^^^^^^^^
#
def mkdir(directory) :
"""Create a directory (and possibly the entire tree).
The os.mkdir() will fail to create a directory if one of the
directory in the specified path does not exist. mkdir()
solves this problem. It creates every intermediate directory
required to create the final path. Under Unix, the function
only supports forward slash separator, but under Windows and MacOS
the function supports the forward slash and the OS separator (backslash
under windows).
"""
# translate the path separators
directory = unixpath(directory)
# build a list of all directory elements
aList = filter(lambda x: len(x)>0, directory.split('/'))
theLen = len(aList)
# if the first element is a Windows-style disk drive
# concatenate it with the first directory
if aList[0].endswith(':'):
if theLen > 1:
aList[1] = aList[0] + '/' + aList[1]
del aList[0]
theLen -= 1
# if the original directory starts at root,
# make sure the first element of the list
# starts at root too
if directory[0] == '/':
aList[0] = '/' + aList[0]
# Now iterate through the list, check if the
# directory exists and if not create it
theDir = ''
for i in range(theLen):
theDir += aList[i]
if not os.path.exists(theDir):
os.mkdir(theDir)
theDir += '/'
# -----------------------------------------------------------------------------
# u n i x p a t h ( ) -- Return a path name that contains Unix separator. --
# ^^^^^^^^^^^^^^^^^^^
#
def unixpath(thePath) :
r"""Return a path name that contains Unix separator.
[Example]
>>> unixpath(r"d:\test")
'd:/test'
>>> unixpath("d:/test/file.txt")
'd:/test/file.txt'
>>>
"""
thePath = os.path.normpath(thePath)
if os.sep == '/':
return thePath
else:
return thePath.replace(os.sep,'/')
# -----------------------------------------------------------------------------
# S c r i p t e x e c u t i o n -- Runs when invoked from the command line --
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
if __name__ == "__main__":
import getopt # command line parsing
argc = len(sys.argv)
if argc == 1:
printUsage('Missing argument: specify at least one of -m or -p (or both).')
sys.exit(1)
# If there is some arguments, parse the command line
validOptions = "ehmpv"
validLongOptions = ['domain=', 'moTarget=']
option = {}
option['forceEnglish'] = 0
option['mo'] = 0
option['po'] = 0
option['verbose'] = 0
option['domain'] = None
option['moTarget'] = None
try:
optionList,pargs = getopt.getopt(sys.argv[1:],validOptions,validLongOptions)
except getopt.GetoptError, e:
printUsage(e[0])
sys.exit(1)
for (opt,val) in optionList:
if (opt == '-h'):
printUsage()
sys.exit(0)
elif (opt == '-e'): option['forceEnglish'] = 1
elif (opt == '-m'): option['mo'] = 1
elif (opt == '-p'): option['po'] = 1
elif (opt == '-v'): option['verbose'] = 1
elif (opt == '--domain'): option['domain'] = val
elif (opt == '--moTarget'): option['moTarget'] = val
if len(pargs) == 0:
appDirPath = os.getcwd()
if option['verbose']:
print "No project directory given. Using current one: %s" % appDirPath
elif len(pargs) == 1:
appDirPath = pargs[0]
else:
printUsage('Too many arguments (%u). Use double quotes if you have space in directory name' % len(pargs))
sys.exit(1)
if option['domain'] is None:
# If no domain specified, use the name of the target directory
option['domain'] = fileBaseOf(appDirPath)
if option['verbose']:
print "Application domain used is: '%s'" % option['domain']
if option['po']:
try:
makePO(appDirPath,option['domain'],option['verbose'])
except IOError, e:
printUsage(e[1] + '\n You must write a file app.fil that contains the list of all files to parse.')
if option['mo']:
makeMO(appDirPath,option['moTarget'],option['domain'],option['verbose'],option['forceEnglish'])
sys.exit(1)
# -----------------------------------------------------------------------------