X Tutup
Skip to content

Commit 428bcba

Browse files
committed
i18n
Internationalization support for bpython. First italian translation.
1 parent e84680f commit 428bcba

File tree

6 files changed

+111
-29
lines changed

6 files changed

+111
-29
lines changed

bpython/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def confirm(self, q):
244244
except ValueError:
245245
return False
246246

247-
return reply.lower() in ('y', 'yes')
247+
return reply.lower() in (_('y'), _('yes'))
248248

249249

250250
def notify(self, s, n=10):
@@ -871,7 +871,7 @@ def p_key(self, key):
871871
TerminalFormatter())
872872
page(source)
873873
else:
874-
self.statusbar.message('Cannot show source.')
874+
self.statusbar.message(_('Cannot show source.'))
875875
return ''
876876

877877
elif key == '\n':
@@ -1521,10 +1521,10 @@ def init_wins(scr, colors, config):
15211521
# problems that needed dirty hackery to fix. :)
15221522

15231523
statusbar = Statusbar(scr, main_win, background, config,
1524-
" <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
1525-
(config.undo_key, config.save_key,
1526-
config.pastebin_key, config.last_output_key,
1527-
config.show_source_key),
1524+
_(" <%s> Rewind <%s> Save <%s> Pastebin "
1525+
" <%s> Pager <%s> Show Source ") %
1526+
(config.undo_key, config.save_key, config.pastebin_key,
1527+
config.last_output_key, config.show_source_key),
15281528
get_colpair(config, 'main'))
15291529

15301530
return main_win, statusbar

bpython/gtk_.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ def formatvalue(self, value):
8585

8686

8787
class ExceptionDialog(gtk.MessageDialog):
88-
def __init__(self, exc_type, exc_value, tb, text='An error occurred.'):
88+
def __init__(self, exc_type, exc_value, tb, text=_('An error occurred.')):
8989
gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_CLOSE,
9090
type=gtk.MESSAGE_ERROR,
9191
message_format=text)
9292
self.set_resizable(True)
9393
import cgitb
9494
text = cgitb.text((exc_type, exc_value, tb), 5)
95-
expander = gtk.Expander('Exception details')
95+
expander = gtk.Expander(_('Exception details'))
9696
self.vbox.pack_start(expander)
9797
textview = gtk.TextView()
9898
textview.get_buffer().set_text(text)
@@ -108,7 +108,7 @@ class ExceptionManager(object):
108108
the exception's type, value, a traceback and a text to display as
109109
arguments.
110110
"""
111-
def __init__(self, DialogType, text='An error occurred.'):
111+
def __init__(self, DialogType, text=_('An error occurred.')):
112112
self.DialogType = DialogType
113113
self.text = text
114114

@@ -144,7 +144,7 @@ class Statusbar(gtk.Statusbar):
144144
"""Contains feedback messages"""
145145
def __init__(self):
146146
gtk.Statusbar.__init__(self)
147-
self.context_id = self.get_context_id('Statusbar')
147+
self.context_id = self.get_context_id(_('Statusbar'))
148148

149149
def message(self, s, n=3):
150150
self.clear()
@@ -221,7 +221,7 @@ def do_expose_event(self, event):
221221
width, height = self.get_size()
222222
self.style.paint_flat_box(self.window, gtk.STATE_NORMAL,
223223
gtk.SHADOW_OUT, None, self,
224-
'tooltip', 0, 0, width, height)
224+
_('tooltip'), 0, 0, width, height)
225225
gtk.Window.do_expose_event(self, event)
226226

227227
def forward(self):
@@ -290,7 +290,7 @@ def confirm(self, q):
290290
return response == gtk.RESPONSE_YES
291291

292292
def file_prompt(self, s):
293-
chooser = gtk.FileChooserDialog(title="File to save to",
293+
chooser = gtk.FileChooserDialog(title=_("File to save to"),
294294
action=gtk.FILE_CHOOSER_ACTION_SAVE,
295295
buttons=(gtk.STOCK_CANCEL,
296296
gtk.RESPONSE_CANCEL,
@@ -301,12 +301,12 @@ def file_prompt(self, s):
301301
chooser.set_current_folder(os.path.expanduser('~'))
302302

303303
pyfilter = gtk.FileFilter()
304-
pyfilter.set_name("Python files")
304+
pyfilter.set_name(_("Python files"))
305305
pyfilter.add_pattern("*.py")
306306
chooser.add_filter(pyfilter)
307307

308308
allfilter = gtk.FileFilter()
309-
allfilter.set_name("All files")
309+
allfilter.set_name(_("All files"))
310310
allfilter.add_pattern("*")
311311
chooser.add_filter(allfilter)
312312

@@ -477,7 +477,7 @@ def do_key_press_event(self, event):
477477
show_source_in_new_window(source, self.config.color_gtk_scheme,
478478
self.config.syntax)
479479
else:
480-
self.interact.notify('Cannot show source.')
480+
self.interact.notify(_('Cannot show source.'))
481481
elif event.keyval == gtk.keysyms.Return:
482482
if self.list_win_visible:
483483
self.list_win_visible = False
@@ -766,10 +766,10 @@ def main(args=None):
766766

767767
setlocale(LC_ALL, '')
768768

769-
gtk_options = ('gtk-specific options',
770-
"Options specific to bpython's Gtk+ front end",
769+
gtk_options = (_('gtk-specific options'),
770+
_("Options specific to bpython's Gtk+ front end"),
771771
[optparse.Option('--socket-id', dest='socket_id',
772-
type='int', help='Embed bpython')])
772+
type='int', help=_('Embed bpython'))])
773773
config, options, exec_args = bpython.args.parse(args, gtk_options,
774774
True)
775775

@@ -825,7 +825,7 @@ def main(args=None):
825825
pastebin.connect("activate", repl_widget.do_paste)
826826
filemenu.append(pastebin)
827827

828-
pastebin_partial = gtk.MenuItem("Pastebin selection")
828+
pastebin_partial = gtk.MenuItem(_("Pastebin selection"))
829829
pastebin_partial.connect("activate", repl_widget.do_partial_paste)
830830
filemenu.append(pastebin_partial)
831831

bpython/urwid.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def confirm(self, q):
396396
except ValueError:
397397
return False
398398

399-
return reply.lower() in ('y', 'yes')
399+
return reply.lower() in (_('y'), _('yes'))
400400

401401
def notify(self, s, n=10):
402402
return self.statusbar.message(s, n)
@@ -410,12 +410,11 @@ def __init__(self, event_loop, palette, interpreter, config):
410410
self.listbox = urwid.ListBox(urwid.SimpleListWalker([]))
411411

412412
# String is straight from bpython.cli
413-
self.statusbar = Statusbar(
414-
config,
415-
" <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
416-
(config.undo_key, config.save_key,
417-
config.pastebin_key, config.last_output_key,
418-
config.show_source_key))
413+
self.statusbar = Statusbar(config,
414+
_(" <%s> Rewind <%s> Save <%s> Pastebin "
415+
" <%s> Pager <%s> Show Source ") %
416+
(config.undo_key, config.save_key, config.pastebin_key,
417+
config.last_output_key, config.show_source_key))
419418

420419
self.interact = URWIDInteraction(self.config, self.statusbar)
421420

@@ -477,7 +476,7 @@ def cw(self):
477476
# Stolen from cli. TODO: clean up and split out.
478477
if (not text or
479478
(not text[-1].isalnum() and text[-1] not in ('.', '_'))):
480-
return
479+
return
481480

482481
# Seek backwards in text for the first non-identifier char:
483482
for i, c in enumerate(reversed(text)):

data/bpython

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
22

33
import sys
4-
from bpython.cli import main
4+
import gettext
5+
6+
gettext.install('bpython', 'i18n/po/')
57

8+
from bpython.cli import main
69
sys.exit(main())

data/bpython-gtk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
22

33
import sys
4-
from bpython.gtk_ import main
4+
import gettext
5+
6+
gettext.install('bpython', 'i18n/po/')
57

8+
from bpython.gtk_ import main
69
sys.exit(main())
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Bpython Italian Translation - first translation ever for bpython!.
2+
# Copyright (C) 2010 bpython developers
3+
# Michele Orrù <maker.py@gmail.com>, 2010.
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: 0.9\n"
8+
"POT-Creation-Date: 2010-07-18 19:54+CEST\n"
9+
"PO-Revision-Date: 2010-07-18\n"
10+
"Last-Translator: Michele Orrù <maker.py@gmail.com>\n"
11+
"Language-Team: Michele Orrù\n"
12+
"MIME-Version: 1.0\n"
13+
"Content-Type: text/plain; charset=UTF-8\n"
14+
"Content-Transfer-Encoding: UTF-8\n"
15+
"Generated-By: pygettext.py 1.5\n"
16+
17+
18+
#: bpython/cli.py:247 bpython/urwid.py:399
19+
msgid "y"
20+
msgstr "s"
21+
22+
#: bpython/cli.py:247 bpython/urwid.py:399
23+
msgid "yes"
24+
msgstr "si"
25+
26+
#: bpython/cli.py:874 bpython/gtk_.py:480
27+
msgid "Cannot show source."
28+
msgstr "Non è possibile mostrare il codice sorgente."
29+
30+
#: bpython/cli.py:1524 bpython/urwid.py:414
31+
msgid " <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source "
32+
msgstr " <%s> Rewind <%s> Salva <%s> Pastebin <%s> Pager <%s> Mostra Sorgente"
33+
34+
#: bpython/gtk_.py:88 bpython/gtk_.py:111
35+
msgid "An error occurred."
36+
msgstr "È stato riscontrato un errore."
37+
38+
#: bpython/gtk_.py:95
39+
msgid "Exception details"
40+
msgstr "Dettagli sull'eccezione."
41+
42+
#: bpython/gtk_.py:147
43+
msgid "Statusbar"
44+
msgstr "Barra di stato"
45+
46+
#: bpython/gtk_.py:224
47+
msgid "tooltip"
48+
msgstr ""
49+
50+
#: bpython/gtk_.py:293
51+
msgid "File to save to"
52+
msgstr "File nel quale salvare"
53+
54+
#: bpython/gtk_.py:304
55+
msgid "Python files"
56+
msgstr "File Python"
57+
58+
#: bpython/gtk_.py:309
59+
msgid "All files"
60+
msgstr "Tutti i files"
61+
62+
#: bpython/gtk_.py:769
63+
msgid "gtk-specific options"
64+
msgstr "Opzioni specifiche di gtk"
65+
66+
#: bpython/gtk_.py:770
67+
msgid "Options specific to bpython's Gtk+ front end"
68+
msgstr "Opzioni specifiche riguandanti il Gtk+ frontend di bpython"
69+
70+
#: bpython/gtk_.py:772
71+
msgid "Embed bpython"
72+
msgstr ""
73+
74+
#: bpython/gtk_.py:828
75+
msgid "Pastebin selection"
76+
msgstr "Nopasta la selezione"
77+

0 commit comments

Comments
 (0)
X Tutup