~ryan-c-ahearn/backintime/command_line_interface

« back to all changes in this revision

Viewing changes to cli/snapshotswidget.py

  • Committer: Ryan Ahearn
  • Date: 2010-03-02 04:48:25 UTC
  • Revision ID: ryan.c.ahearn@gmail.com-20100302044825-4efo4lqb7b5pjzwa
Added gettext calls to all strings that will be displayed to the user

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import subprocess
21
21
import tempfile
22
22
import urwid
 
23
import gettext
23
24
 
24
25
import logger
25
26
import restorewidget
26
27
 
 
28
_=gettext.gettext
 
29
 
27
30
class SnapshotsWidget(urwid.WidgetWrap):
28
31
 
29
32
    def __init__( self, main_win, config, snapshots, path ):
36
39
 
37
40
        left_side, right_side = self._build_snapshot_lists()
38
41
        pile_list = [
39
 
            urwid.Text( 'Diff versions of: %s' % path ),
 
42
            urwid.Text( _('Diff versions of') + ': %s' % path ),
40
43
            urwid.Divider(),
41
44
            urwid.Columns( [
42
45
                urwid.Pile( left_side ),
44
47
                ], 1 ),
45
48
            urwid.Divider(),
46
49
            urwid.GridFlow( [
47
 
                urwid.AttrWrap( urwid.Button( 'Jump to', self.jump ), 'button', 'button_focus' ),
48
 
                urwid.AttrWrap( urwid.Button( 'Diff', self.diff ), 'button', 'button_focus' ),
49
 
                urwid.AttrWrap( urwid.Button( 'Cancel', self.go_back ), 'button', 'button_focus' )
 
50
                urwid.AttrWrap( urwid.Button( _('Jump to'), self.jump ), 'button', 'button_focus' ),
 
51
                urwid.AttrWrap( urwid.Button( _('Diff'), self.diff ), 'button', 'button_focus' ),
 
52
                urwid.AttrWrap( urwid.Button( _('Cancel'), self.go_back ), 'button', 'button_focus' )
50
53
                ], 11, 2, 1, 'right' )
51
54
            ]
52
55
 
56
59
    def _build_snapshot_lists( self ):
57
60
        snapshots_list = self._snapshots.get_snapshots_list()
58
61
        left_list = [
59
 
            urwid.Text( 'Snapshots:' ),
 
62
            urwid.Text( _('Snapshots') + ':' ),
60
63
            urwid.Divider()
61
64
            ]
62
65
        left_list_buttons = []
63
66
        right_list = [
64
 
            urwid.Text( 'Diff with:' ),
 
67
            urwid.Text( _('Diff with') + ':' ),
65
68
            urwid.Divider()
66
69
            ]
67
70
        right_list_buttons = []
73
76
        path = self._path
74
77
        if os.path.lexists( path ):
75
78
            if os.path.isdir( path ) == isdir:
76
 
                left_list.append( urwid.RadioButton( left_list_buttons, 'Now', True, self.left_changed, '' ) )
77
 
                right_list.append( urwid.RadioButton( right_list_buttons, 'Now', False, self.right_changed, '' ) )
 
79
                left_list.append( urwid.RadioButton( left_list_buttons, _('Now'), True, self.left_changed, '' ) )
 
80
                right_list.append( urwid.RadioButton( right_list_buttons, _('Now'), False, self.right_changed, '' ) )
78
81
 
79
82
        # add snapshots
80
83
        for snapshot in snapshots_list:
135
138
        
136
139
        if int( output[0] ) > rows:
137
140
            temp_file, temp_file_name = tempfile.mkstemp( '_bitdiff', os.path.basename( path ), text=True )
138
 
            output_text = 'This diff was too long for the window, it has been written to: %s' % temp_file_name
 
141
            output_text = _('This diff was too long for the window, it has been written to') + ': %s' % temp_file_name
139
142
            callback = subprocess.Popen( diff_cmd, shell=True, stdout=temp_file )
140
143
            callback.communicate()
141
144
        else:
148
151
            urwid.Divider(),
149
152
            urwid.Text( output_text ),
150
153
            urwid.Divider(),
151
 
            urwid.AttrWrap( urwid.Button( 'OK', self.go_back ), 'button', 'button_focus' )
 
154
            urwid.AttrWrap( urwid.Button( _('OK'), self.go_back ), 'button', 'button_focus' )
152
155
            ]
153
156
 
154
157
        display_widget = urwid.Pile( pile_list )