4949
5050from bpython import importcompletion , inspection
5151from bpython .formatter import Parenthesis
52+ from bpython .translations import _
53+
5254
5355# Needed for special handling of __abstractmethods__
5456# abc only exists since 2.6, so check both that it exists and that it's
@@ -771,16 +773,16 @@ def pastebin(self, s=None):
771773 s = self .getstdout ()
772774
773775 if (self .config .pastebin_confirm and
774- not self .interact .confirm ("Pastebin buffer? (y/N) " )):
775- self .interact .notify ("Pastebin aborted" )
776+ not self .interact .confirm (_ ( "Pastebin buffer? (y/N) " ) )):
777+ self .interact .notify (_ ( "Pastebin aborted" ) )
776778 return
777779 return self .do_pastebin (s )
778780
779781 def do_pastebin (self , s ):
780782 """Actually perform the upload."""
781783 if s == self .prev_pastebin_content :
782- self .interact .notify ('Duplicate pastebin. Previous URL: ' +
783- self .prev_pastebin_url )
784+ self .interact .notify (_ ( 'Duplicate pastebin. Previous URL: %s' ) %
785+ ( self .prev_pastebin_url , ) )
784786 return self .prev_pastebin_url
785787
786788 if self .config .pastebin_helper :
@@ -793,16 +795,16 @@ def do_pastebin_xmlrpc(self, s):
793795 try :
794796 pasteservice = ServerProxy (self .config .pastebin_url )
795797 except IOError , e :
796- self .interact .notify ("Pastebin error for URL '%s': %s" %
798+ self .interact .notify (_ ( "Pastebin error for URL '%s': %s" ) %
797799 (self .config .pastebin_url , str (e )))
798800 return
799801
800- self .interact .notify ('Posting data to pastebin...' )
802+ self .interact .notify (_ ( 'Posting data to pastebin...' ) )
801803 try :
802804 paste_id = pasteservice .pastes .newPaste ('pycon' , s , '' , '' , '' ,
803805 self .config .pastebin_private )
804806 except (SocketError , XMLRPCError ), e :
805- self .interact .notify ('Upload failed: %s' % (str (e ), ) )
807+ self .interact .notify (_ ( 'Upload failed: %s' ) % (str (e ), ) )
806808 return
807809
808810 self .prev_pastebin_content = s
@@ -811,12 +813,12 @@ def do_pastebin_xmlrpc(self, s):
811813 paste_id = urlquote (paste_id )
812814 paste_url = paste_url_template .safe_substitute (paste_id = paste_id )
813815 self .prev_pastebin_url = paste_url
814- self .interact .notify ('Pastebin URL: %s' % (paste_url , ), 10 )
816+ self .interact .notify (_ ( 'Pastebin URL: %s' ) % (paste_url , ), 10 )
815817 return paste_url
816818
817819 def do_pastebin_helper (self , s ):
818820 """Call out to helper program for pastebin upload."""
819- self .interact .notify ('Posting data to pastebin...' )
821+ self .interact .notify (_ ( 'Posting data to pastebin...' ) )
820822
821823 try :
822824 helper = subprocess .Popen ('' ,
@@ -828,34 +830,34 @@ def do_pastebin_helper(self, s):
828830 paste_url = output .split ()[0 ]
829831 except OSError , e :
830832 if e .errno == errno .ENOENT :
831- self .interact .notify ('Upload failed: '
832- 'Helper program not found.' )
833+ self .interact .notify (_ ( 'Upload failed: '
834+ 'Helper program not found.' ) )
833835 else :
834- self .interact .notify ('Upload failed: '
835- 'Helper program could not be run.' )
836+ self .interact .notify (_ ( 'Upload failed: '
837+ 'Helper program could not be run.' ) )
836838 return
837839
838840 if helper .returncode != 0 :
839- self .interact .notify ('Upload failed: '
840- 'Helper program returned non-zero exit '
841- 'status %s.' % (helper .returncode , ))
841+ self .interact .notify (_ ( 'Upload failed: '
842+ 'Helper program returned non-zero exit '
843+ 'status %s.' % (helper .returncode , ) ))
842844 return
843845
844846 if not paste_url :
845- self .interact .notify ('Upload failed: '
846- 'No output from helper program.' )
847+ self .interact .notify (_ ( 'Upload failed: '
848+ 'No output from helper program.' ) )
847849 return
848850 else :
849851 parsed_url = urlparse (paste_url )
850852 if (not parsed_url .scheme
851853 or any (unicodedata .category (c ) == 'Cc' for c in paste_url )):
852- self .interact .notify ("Upload failed: "
853- "Failed to recognize the helper "
854- "program's output as an URL." )
854+ self .interact .notify (_ ( "Upload failed: "
855+ "Failed to recognize the helper "
856+ "program's output as an URL." ) )
855857 return
856858
857859 self .prev_pastebin_content = s
858- self .interact .notify ('Pastebin URL: %s' % (paste_url , ), 10 )
860+ self .interact .notify (_ ( 'Pastebin URL: %s' ) % (paste_url , ), 10 )
859861 return paste_url
860862
861863 def push (self , s , insert_into_history = True ):
0 commit comments