Skip to content

Commit

Permalink
Gettext localization implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaleino committed Jun 10, 2007
1 parent ffb140e commit 26f5e1a
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 32 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
pastebinit (0.8.2) gutsy; urgency=low

* Closing launchpad bug #119723 "Implement gettext localization"

-- David Paleino <d.paleino@gmail.com> Sun, 09 Jun 2007 01:28:11 +0200

pastebinit (0.8.1-0ubuntu2) gutsy; urgency=low

* Closing launchpad bug #119273 "Normal kill does not work"
Expand Down
2 changes: 2 additions & 0 deletions debian/dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
usr/bin
usr/share/locale
2 changes: 2 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pastebinit usr/bin/
po/mo/* usr/share/locale/
8 changes: 5 additions & 3 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

build:
xsltproc -''-nonet /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl pastebinit.xml

# build translations
(cd po; $(MAKE))

clean:
dh_testdir
Expand All @@ -16,9 +19,8 @@ install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs usr/bin

install -m 755 $(CURDIR)/pastebinit $(CURDIR)/debian/pastebinit/usr/bin/
dh_installdirs
dh_install

binary-arch: build install
binary-indep: build install
Expand Down
61 changes: 32 additions & 29 deletions pastebinit
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

try:
import urllib, os, sys, re, getopt, select, xml.dom.minidom
import urllib, os, sys, re, getopt, select, xml.dom.minidom, gettext
from gettext import gettext as _

gettext.textdomain("pastebinit")

defaultPB = "http://paste.stgraber.org" #Default pastebin
version = "0.8.1" #Version number to show in the usage
version = "0.8.2" #Version number to show in the usage
configfile = os.environ.get('HOME') + "/.pastebinit.xml"

# Custom urlopener to handle 401's
Expand Down Expand Up @@ -67,7 +70,7 @@ try:
params['s'] = "Submit Post"
params['regexp'] = '">http://pastebin.ca/(.*)</a></p><p>'
else:
sys.exit("Unknown website, please post a bugreport to request this pastebin to be added ("+website+")")
sys.exit(_("Unknown website, please post a bugreport to request this pastebin to be added (%s)") % website)
return params

#XML Handling methods
Expand All @@ -90,18 +93,18 @@ try:
# Display usage instructions
def Usage ():
print "pastebinit v" + version
print "Required arguments:"
print "\t-i <filename> (or pipe the text)"
print "Optional arguments:"
print "\t-b <pastebin url:default is '" + website + "'>"
print "\t-a <author:default is '" + user + "'>"
print "\t-f <format of paste:default is '" + format + "'>"
print "\t-r <parent posts ID:defaults to none>"
print "Optional arguments supported only by 1t2.us and paste.stgraber.org:"
print "\t-j <jabberid for notifications:default is '" + jabberid + "'>"
print "\t-m <permatag for all versions of a post:default is blank>"
print "\t-t <title of paste:default is blank>"
print "\t-u <username> -p <password>"
print _("Required arguments:")
print _("\t-i <filename> (or pipe the text)")
print _("Optional arguments:")
print _("\t-b <pastebin url:default is '%s'>") % website
print _("\t-a <author:default is '%s'>") % website
print _("\t-f <format of paste:default is '%s'>") % format
print _("\t-r <parent posts ID:defaults to none>")
print _("Optional arguments supported only by 1t2.us and paste.stgraber.org:")
print _("\t-j <jabberid for notifications:default is '%s'>") % jabberid
print _("\t-m <permatag for all versions of a post:default is blank>")
print _("\t-t <title of paste:default is blank>")
print _("\t-u <username> -p <password>")

# Set defaults
website = defaultPB
Expand Down Expand Up @@ -133,7 +136,7 @@ try:
f.close()
gotconfigxml = 1
except KeyboardInterrupt:
sys.exit("KeyboardInterrupt catched.")
sys.exit(_("KeyboardInterrupt catched."))
except:
gotconfigxml = 0

Expand All @@ -146,10 +149,10 @@ try:
format = getFirstNodeText(configxml, "format")
jabberid = getFirstNodeText(configxml, "jabberid")
except KeyboardInterrupt:
sys.exit("KeyboardInterrupt catched.")
sys.exit(_("KeyboardInterrupt catched."))
except:
print "Error parsing configuration file!"
print "Please ensure that your configuration file looks similar to the following:"
print _("Error parsing configuration file!")
print _("Please ensure that your configuration file looks similar to the following:")
print configexample
sys.exit(1)

Expand All @@ -163,17 +166,17 @@ try:

# Check number of arguments
if len(sys.argv) == 1 and filename == "":
print "Error no arguments specified!\n"
print _("Error no arguments specified!\n")
Usage()
sys.exit(1)

# Get options
try:
optlist, list = getopt.getopt(sys.argv[1:], 'i:f:b:a:r:j:t:m:u:p:')
except KeyboardInterrupt:
sys.exit("KeyboardInterrupt catched.")
sys.exit(_("KeyboardInterrupt catched."))
except getopt.GetoptError:
print "Invalid arguments!\n"
print _("Invalid arguments!\n")
Usage()
sys.exit(1)

Expand Down Expand Up @@ -202,21 +205,21 @@ try:

#If - is specified as a filename read from stdin, otherwise load the specified file.
if filename == "":
print "Error no filename specified!\n"
print _("Error no filename specified!\n")
Usage()
sys.exit(1)
elif filename == "-" and content == "":
content = sys.stdin.read()
sys.exit("KeyboardInterrupt catched.")
sys.exit(_("KeyboardInterrupt catched."))
elif content == "":
try:
f = open(filename)
content = f.read()
f.close()
except KeyboardInterrupt:
sys.exit("KeyboardInterrupt catched.")
sys.exit(_("KeyboardInterrupt catched."))
except:
sys.exit("Unable to read from: " + filename)
sys.exit(_("Unable to read from: %s") % filename)

params = getParameters(website, content, user, jabberid, version, format, parentpid, permatag, title, username, password) #Get the parameters array
reLink = params['regexp'] #Extract the regexp
Expand All @@ -232,9 +235,9 @@ try:
else:
print page.url #Get the final page and show the ur
except KeyboardInterrupt:
sys.exit("KeyboardInterrupt catched.")
sys.exit(_("KeyboardInterrupt catched."))
except:
sys.exit("Unable to read or parse the result page, it could be a server timeout or a change server side, try with another pastebin.")
sys.exit(_("Unable to read or parse the result page, it could be a server timeout or a change server side, try with another pastebin."))

except KeyboardInterrupt:
sys.exit("KeyboardInterrupt catched.")
sys.exit(_("KeyboardInterrupt catched."))
12 changes: 12 additions & 0 deletions po/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
all: build-mo

# create mo from the po files
%.mo : %.po
mkdir -p mo/$(subst .po,,$<)/LC_MESSAGES/
msgfmt $< -o mo/$(subst .po,,$<)/LC_MESSAGES/pastebinit.mo

# generate all *.mo files
build-mo: $(patsubst %.po,%.mo,$(wildcard *.po))

update-po:
pygettext -a -D ../pastebinit
109 changes: 109 additions & 0 deletions po/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Po file for pastebinit
# Copyright (C) 2007, Pastebinit Developers Team
# David Paleino <d.paleino@gmail.com>, 2007
#
msgid ""
msgstr ""
"Project-Id-Version: 0.8.1\n"
"POT-Creation-Date: 2007-06-10 20:31+0200\n"
"PO-Revision-Date: 2007-06-10 20:52+0200\n"
"Last-Translator: David Paleino <d.paleino@gmail.com>"
"Language-Team: Italian <it@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"

#: ../pastebinit:35
#, docstring
msgid "Return the parameters array for the selected pastebin"
msgstr "Ritorna l'array di parametri per il pastebin selezionato"

#: ../pastebinit:71
msgid "Unknown website, please post a bugreport to request this pastebin to be added (%s)"
msgstr "Sito sconosciuto, invia un bugreport per richiedere che il pastebin %s venga aggiunto"

#: ../pastebinit:94
msgid "Required arguments:"
msgstr "Argomenti richiesti:"

#: ../pastebinit:95
msgid "\t-i <filename> (or pipe the text)"
msgstr "\t-i <nomefile> (o attraverso una pipe)"

#: ../pastebinit:96
msgid "Optional arguments:"
msgstr "Argomenti opzionali:"

#: ../pastebinit:97
msgid "\t-b <pastebin url:default is '%s'>"
msgstr "\t-b <indirizzo pastebin:default è '%s'>"

#: ../pastebinit:98
msgid "\t-a <author:default is '%s'>"
msgstr "\t-a <autore:default è '%s'>"

#: ../pastebinit:99
msgid "\t-f <format of paste:default is '%s'>"
msgstr "\t-f <formato:default è '%s'>"

#: ../pastebinit:100
msgid "\t-r <parent posts ID:defaults to none>"
msgstr "\t-r <ID invii genitori:default è nessuno>"

#: ../pastebinit:101
msgid "Optional arguments supported only by 1t2.us and paste.stgraber.org:"
msgstr "Argomenti opzionali supportati solo da 1t2.us e paste.stgraber.org:"

#: ../pastebinit:102
msgid "\t-j <jabberid for notifications:default is '%s'>"
msgstr "\t-j <jabberid per le notifiche:default è '%s'>"

#: ../pastebinit:103
msgid "\t-m <permatag for all versions of a post:default is blank>"
msgstr "\t-m <permatag per tutte le versioni di un post:default è nessuno>"

#: ../pastebinit:104
msgid "\t-t <title of paste:default is blank>"
msgstr "\t-t <titolo del paste:default è nessuno>"

#: ../pastebinit:105
msgid "\t-u <username> -p <password>"
msgstr "\t-u <usename> -p <password>"

#: ../pastebinit:137 ../pastebinit:150 ../pastebinit:175 ../pastebinit:211
#: ../pastebinit:218 ../pastebinit:236 ../pastebinit:241
msgid "KeyboardInterrupt catched."
msgstr "KeyboardInterrupt catturato."

#: ../pastebinit:152
msgid "Error parsing configuration file!"
msgstr "Errore nell'analisi del file di configurazione!"

#: ../pastebinit:153
msgid "Please ensure that your configuration file looks similar to the following:"
msgstr "Per favore, assicurati che il tuo file di configurazione assomigli a questo:"

#: ../pastebinit:167
msgid ""
"Error no arguments specified!\n"
msgstr ""
"Errore, nessun argomento specificato!\n"

#: ../pastebinit:177
msgid ""
"Invalid arguments!\n"
msgstr ""
"Argomenti non validi!\n"

#: ../pastebinit:206
msgid ""
"Error no filename specified!\n"
msgstr ""
"Errore, nessun file specificato!\n"

#: ../pastebinit:220
msgid "Unable to read from: %s"
msgstr "Impossibile leggere da: %s"

#: ../pastebinit:238
msgid "Unable to read or parse the result page, it could be a server timeout or a change server side, try with another pastebin."
msgstr "Impossibile leggere o analizzare la pagina dei risultati, potrebbe essere un timeout del server o un cambiamento sul server, prova con un altro pastebin."

0 comments on commit 26f5e1a

Please sign in to comment.