Commit cb438cf0 authored by steve9000's avatar steve9000

Add initial i18n support

parent 204a7547
......@@ -38,12 +38,13 @@ CVS_COMMAND = ["cvs", "-z3", "-q"]
#
################################################################################
class Entry:
states = _("Non CVS::Error::Newly added:Modified:Removed:Missing").split(":")
def __str__(self):
return "%s %s\n" % (self.name, (self.path, self.state))
def __repr__(self):
return "%s %s\n" % (self.name, (self.path, self.state))
def get_status(self):
return ["Non CVS", "", "Error", "", "Newly added", "Modified", "Removed", "Missing"][self.state]
return self.states[self.state]
class Dir(Entry):
def __init__(self, path, name, state):
......@@ -253,7 +254,6 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
'create-diff': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
}
MODIFIED_FILTER_MASK, UNKNOWN_FILTER_MASK = 1,2
filters = [lambda x: (x.state > tree.STATE_NONE),
......@@ -287,11 +287,11 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
self.treeview.append_column(column)
return column
self.treeview_column_location = addCol("Location", COL_LOCATION)
addCol("Status", COL_STATUS)
addCol("Rev", COL_REVISION)
addCol("Tag", COL_TAG)
addCol("Options", COL_OPTIONS)
self.treeview_column_location = addCol( _("Location"), COL_LOCATION)
addCol(_("Status"), COL_STATUS)
addCol(_("Rev"), COL_REVISION)
addCol(_("Tag"), COL_TAG)
addCol(_("Options"), COL_OPTIONS)
self.location = None
self.treeview_column_location.set_visible( self.button_recurse.get_active() )
......@@ -314,7 +314,7 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
self.label_changed()
def _search_recursively_iter(self):
yield "[%s] Scanning" % self.label_text
yield _("[%s] Scanning") % self.label_text
rootpath = self.model.get_path( self.model.get_iter_root() )
rootname = self.model.value_path( self.model.get_iter(rootpath), 0 )
prefixlen = 1 + len(rootname)
......@@ -335,7 +335,7 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
else:
iter = self.model.get_iter_root()
root = name
yield "[%s] Scanning %s" % (self.label_text, root[prefixlen:])
yield _("[%s] Scanning %s") % (self.label_text, root[prefixlen:])
#import time; time.sleep(1.0)
entries = filter(showable, listdir_cvs(root))
......@@ -358,7 +358,7 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
todo.append( (self.model.get_path(child), None) )
if not recursive:
if len(entries) == 0:
self.model.add_empty(iter, "no cvs files")
self.model.add_empty(iter, _("no cvs files"))
if differences or len(path)==1:
start = path[:]
while len(start) and not self.treeview.row_expanded(start):
......@@ -396,14 +396,14 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
self.run_cvs_diff( [path] )
def run_cvs_diff_iter(self, paths, empty_patch_ok):
yield "[%s] Fetching differences." % self.label_text
yield _("[%s] Fetching differences") % self.label_text
difffunc = self._command_iter(CVS_COMMAND + ["diff", "-u"], paths, 0).next
diff = None
while type(diff) != type(()):
diff = difffunc()
yield 1
prefix, patch = diff[0], diff[1]
yield "[%s] Applying patch." % self.label_text
yield _("[%s] Applying patch") % self.label_text
if patch:
self.show_patch(prefix, patch)
elif empty_patch_ok:
......@@ -477,7 +477,7 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
if len(files):
self._command(command, files, refresh)
else:
self.statusbar.add_status("Select some files first.")
self.statusbar.add_status( _("Select some files first") )
def on_button_update_clicked(self, object):
self._command_on_selected(CVS_COMMAND + ["update","-dP"] )
......
......@@ -303,7 +303,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.scheduler.add_task( self._search_recursively_iter( path ).next )
def _search_recursively_iter(self, rootpath):
yield "[%s] Scanning" % self.label_text
yield _("[%s] Scanning") % self.label_text
prefixlen = 1 + len( self.model.value_path( self.model.get_iter(rootpath), 0 ) )
todo = [ rootpath ]
while len(todo):
......@@ -311,7 +311,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
path = todo.pop(0)
iter = self.model.get_iter( path )
roots = self.model.value_paths( iter )
yield "[%s] Scanning %s" % (self.label_text, roots[0][prefixlen:])
yield _("[%s] Scanning %s") % (self.label_text, roots[0][prefixlen:])
#import time; time.sleep(1.0)
differences = [0]
alldirs = []
......@@ -352,7 +352,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
while level < len(path):
level += 1
self.treeview[0].expand_row( path[:level], 0)
yield "[%s] Done" % self.label_text
yield _("[%s] Done") % self.label_text
def launch_comparison(self, iter, pane, force=1):
"""Launch comparison at 'iter'.
......@@ -410,14 +410,14 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.file_created( path, dst_pane)
elif os.path.isdir(src):
if os.path.exists(dst):
if misc.run_dialog("'%s' exists.\nOverwrite?" % os.path.basename(dst),
if misc.run_dialog( _("'%s' exists.\nOverwrite?") % os.path.basename(dst),
parent = self,
buttonstype = gtk.BUTTONS_OK_CANCEL) != gtk.RESPONSE_OK:
continue
misc.copytree(src, dst)
self.recursively_update( path )
except OSError, e:
misc.run_dialog("Error copying '%s' to '%s'\n\n%s." % (src, dst,e), self)
misc.run_dialog(_("Error copying '%s' to '%s'\n\n%s.") % (src, dst,e), self)
def delete_selected(self):
"""Delete all selected files/folders recursively.
......@@ -435,13 +435,13 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
os.remove(name)
self.file_deleted( path, pane) #xxx
elif os.path.isdir(name):
if misc.run_dialog("'%s' is a directory.\nRemove recusively?" % os.path.basename(name),
if misc.run_dialog(_("'%s' is a directory.\nRemove recusively?") % os.path.basename(name),
parent = self,
buttonstype=gtk.BUTTONS_OK_CANCEL) == gtk.RESPONSE_OK:
shutil.rmtree(name)
self.recursively_update( path )
except OSError, e:
misc.run_dialog("Error removing %s\n\n%s." % (name,e), parent = self)
misc.run_dialog(_("Error removing %s\n\n%s.") % (name,e), parent = self)
def on_treeview_row_activated(self, view, path, column):
iter = self.model.get_iter(path)
......
......@@ -367,7 +367,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
try:
pattern = re.compile( tofind, (match_case and re.M or (re.M|re.I)) )
except re.error, e:
misc.run_dialog("Regular expression error\n'%s'" % e, self, messagetype=gtk.MESSAGE_ERROR)
misc.run_dialog( _("Regular expression error\n'%s'") % e, self, messagetype=gtk.MESSAGE_ERROR)
else:
match = pattern.search(text, insert.get_offset()+1 )
if match == None and wrap:
......@@ -378,9 +378,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
iter.forward_chars( match.end() - match.start() )
buf.move_mark( buf.get_selection_bound(), iter )
view.scroll_to_mark( buf.get_insert(), 0)
elif regex:
misc.run_dialog( _("The regular expression '%s' was not found." % tofind), self, messagetype=gtk.MESSAGE_INFO)
else:
misc.run_dialog( "The %s '%s' was not found" % (regex and "regular expression" or "text", tofind),
self, messagetype=gtk.MESSAGE_INFO)
misc.run_dialog( _("The text '%s' was not found.") % tofind, self, messagetype=gtk.MESSAGE_INFO)
#
# text buffer loading/saving
......@@ -419,14 +420,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.scheduler.add_task( self._set_files_internal(files).next )
def _set_files_internal(self, files):
yield "[%s] Set num panes" % self.label_text
yield _("[%s] Set num panes") % self.label_text
self.set_num_panes( len(files) )
self._disconnect_buffer_handlers()
self.linediffer.diffs = [[],[]]
self.queue_draw()
buffers = [t.get_buffer() for t in self.textview][:self.num_panes]
try_codecs = self.prefs.text_codecs.split()
yield "[%s] Opening files" % self.label_text
yield _("[%s] Opening files") % self.label_text
panetext = ["\n"] * self.num_panes
tasks = []
for i,f in misc.enumerate(files):
......@@ -442,11 +443,11 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
except IOError, e:
buffers[i].set_text("\n")
misc.run_dialog(
"Could not open '%s' for reading.\n\nThe error was:\n%s" % (f, str(e)),
_("Could not open '%s' for reading.\n\nThe error was:\n%s") % (f, str(e)),
parent = self)
else:
panetext[i] = buffers[i].get_text( buffers[i].get_start_iter(), buffers[i].get_end_iter() )
yield "[%s] Reading files" % self.label_text
yield _("[%s] Reading files") % self.label_text
while len(tasks):
for t in tasks[:]:
try:
......@@ -461,7 +462,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
print "codec error fallback", err
t.buf.delete( t.buf.get_start_iter(), t.buf.get_end_iter() )
misc.run_dialog(
"Could not read from '%s'.\n\nI tried encodings %s." % (t.filename, try_codecs),
_("Could not read from '%s'.\n\nI tried encodings %s.") % (t.filename, try_codecs),
parent = self)
tasks.remove(t)
else:
......@@ -478,7 +479,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
panetext[t.pane] += "\n"
yield 1
self.undosequence.clear()
yield "[%s] Computing differences" % self.label_text
yield _("[%s] Computing differences") % self.label_text
lines = map(lambda x: x.split("\n"), panetext)
step = self.linediffer.set_sequences_iter(*lines)
while step.next() == None:
......@@ -565,7 +566,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
buf = self.textview[pane].get_buffer()
bufdata = buf.get_data("meld")
if saveas or not bufdata.filename:
fselect = gtk.FileSelection("Choose a name for buffer %i" % (pane+1))
fselect = gtk.FileSelection( _("Choose a name for buffer %i.") % (pane+1))
fselect.set_transient_for(self.widget.get_toplevel() )
response = fselect.run()
if response != gtk.RESPONSE_OK:
......@@ -576,7 +577,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
fselect.destroy()
if os.path.exists(filename):
response = misc.run_dialog(
'"%s" exists!\nOverwrite?' % os.path.basename(filename),
_('"%s" exists!\nOverwrite?') % os.path.basename(filename),
parent = self,
buttonstype = gtk.BUTTONS_YES_NO)
if response == gtk.RESPONSE_NO:
......@@ -590,7 +591,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
open(bufdata.filename, "w").write(text)
except IOError, e:
misc.run_dialog(
"Error writing to %s\n\n%s." % (bufdata.filename, e),
_("Error writing to %s\n\n%s.") % (bufdata.filename, e),
self, buttongtk.MESSAGE_ERROR, gtk.BUTTONS_OK)
return gnomeglade.RESULT_ERROR
else:
......@@ -648,7 +649,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
modified = [view.get_buffer().get_data("meld").filename
for view in self.textview[:self.num_panes] if view.get_buffer().get_data("meld").modified]
if len(modified):
message = "Refreshing will discard changes in:\n%s\n\nYou cannot undo this operation." % "\n".join(modified)
message = _("Refreshing will discard changes in:\n%s\n\nYou cannot undo this operation.") % "\n".join(modified)
response = misc.run_dialog( message, parent=self, messagetype=gtk.MESSAGE_WARNING, buttonstype=gtk.BUTTONS_OK_CANCEL)
if response == gtk.RESPONSE_OK:
files = [t.get_buffer().get_data("meld").filename for t in self.textview[:self.num_panes] ]
......
......@@ -546,7 +546,7 @@
<child>
<widget class="button" id="toolbar_new">
<property name="visible">True</property>
<property name="label" translatable="yes">NEW...</property>
<property name="label" translatable="yes">_New...</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-new</property>
<signal name="pressed" handler="on_toolbar_new_clicked" last_modification_time="Sat, 02 Nov 2002 17:52:37 GMT"/>
......
......@@ -48,7 +48,7 @@ class BrowseFileDialog(gnomeglade.Component):
self.numfile = len(labels)
self.callback = callback
self.labels = map(gtk.Label, labels )
self.entries = map( lambda x:gnome.ui.FileEntry("fileentry", "Browse "+x), labels)
self.entries = map( lambda x:gnome.ui.FileEntry("fileentry", _("Browse %s") % x), labels)
for i in range(self.numfile):
self.labels[i].set_justify(gtk.JUSTIFY_RIGHT)
self.table.attach(self.labels[i], 0, 1, i, i+1, gtk.SHRINK)
......@@ -358,19 +358,19 @@ class MeldApp(gnomeglade.GnomeApp):
# Toolbar and menu items (file)
#
def on_menu_new_diff2_activate(self, *extra):
BrowseFileDialog(self,_("Original File:Modified File").split(":"), self.append_filediff)
BrowseFileDialog(self, [_("Original File"), _("Modified File")], self.append_filediff)
def on_menu_new_diff3_activate(self, *extra):
BrowseFileDialog(self,["Other Changes","Common Ancestor","Local Changes"], self.append_filediff )
BrowseFileDialog(self, [_("Other Changes"), _("Common Ancestor"), _("Local Changes")], self.append_filediff )
def on_menu_new_dir2_activate(self, *extra):
BrowseFileDialog(self,["Original Directory", "Modified Directory"], self.append_dirdiff, isdir=1)
BrowseFileDialog(self, [_("Original Directory"), _("Modified Directory")], self.append_dirdiff, isdir=1)
def on_menu_new_dir3_activate(self, *extra):
BrowseFileDialog(self,["Other Directory", "Original Directory", "Modified Directory"], self.append_dirdiff, isdir=1)
BrowseFileDialog(self, [_("Other Directory"), _("Original Directory"), _("Modified Directory")], self.append_dirdiff, isdir=1)
def on_menu_new_cvsview_activate(self, *extra):
BrowseFileDialog(self,["Root CVS Directory"], self.append_cvsview, isdir=1)
BrowseFileDialog(self,[_("Root CVS Directory")], self.append_cvsview, isdir=1)
def on_menu_save_activate(self, menuitem):
try:
......@@ -400,7 +400,7 @@ class MeldApp(gnomeglade.GnomeApp):
try: state.append( c.get_data("pyobject").is_modified() )
except AttributeError: state.append(0)
if 1 in state and not developer:
response = misc.run_dialog('You have some unsaved changes.\nQuit anyway?',
response = misc.run_dialog( _("You have some unsaved changes.\nQuit anyway?"),
parent = self,
buttonstype=gtk.BUTTONS_OK_CANCEL )
if response!=gtk.RESPONSE_OK:
......@@ -571,7 +571,7 @@ class MeldApp(gnomeglade.GnomeApp):
# usage
#
################################################################################
usage_string = """Meld is a file and directory comparison tool. Usage:
usage_string = _("""Meld is a file and directory comparison tool. Usage:
meld Start with no windows open
meld <dir> Start with CVS browser in 'dir'
......@@ -581,7 +581,7 @@ usage_string = """Meld is a file and directory comparison tool. Usage:
For more information choose help -> contents.
Report bugs to steve9000@users.sourceforge.net.
"""
""")
################################################################################
#
......@@ -623,13 +623,13 @@ def main():
doc.connect("create-diff", lambda obj,arg: app.append_filediff(arg) )
doc.run_cvs_diff([a])
else:
app.usage("`%s' is not a directory or file, cannot open cvs view" % arg[0])
app.usage( _("`%s' is not a directory or file, cannot open cvs view") % arg[0])
elif len(arg) in (2,3):
done = 0
exists = map( lambda a: os.access(a, os.R_OK), arg)
if 0 in exists:
m = "Cannot open "
m = _("Cannot open ")
for i in range(len(arg)):
if not exists[i]:
m += "`%s'" % arg[i]
......@@ -646,12 +646,12 @@ def main():
app.append_dirdiff( arg )
done = 1
if not done:
m = "Cannot compare a mixture of files and directories.\n"
m = _("Cannot compare a mixture of files and directories.\n")
for i in range(len(arg)):
m += "(%s)\t`%s'\n" % (arefiles[i] and "file" or "dir", arg[i])
m += "(%s)\t`%s'\n" % (arefiles[i] and _("file") or _("folder"), arg[i])
app.usage(m)
else:
app.usage("Wrong number of arguments (Got %i)" % len(arg))
app.usage( _("Wrong number of arguments (Got %i)") % len(arg))
app.mainloop()
......@@ -35,7 +35,7 @@ class MeldDoc(gobject.GObject):
self.prefs = prefs
self.prefs.notify_add(self.on_preference_changed)
self.num_panes = 0
self.label_text = "untitled"
self.label_text = _("untitled")
def save(self):
pass
......
......@@ -59,7 +59,7 @@ def appdir(pathin):
where = os.path.dirname(sys.argv[0])
pathout = os.path.join( where, pathin )
if not os.path.exists(pathout):
run_dialog("Cannot find '%s'\nI looked in '%s'\n(%s)" % (pathin,where,pathout), None, gtk.MESSAGE_ERROR)
run_dialog(_("Cannot find '%s'\nI looked in '%s'\n(%s)") % (pathin,where,pathout), None, gtk.MESSAGE_ERROR)
sys.exit(1)
return pathout
......@@ -116,7 +116,7 @@ def shorten_names(*names):
base = basenames[0].strip()
return [ r+base for r in roots ]
# no common path. empty names get changed to "[None]"
return map( lambda x: x or "[None]", names)
return map( lambda x: x or _("[None]"), names)
def look(s, o):
"""Return a list of attributes in 'o' which contain the string 's'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment