Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-02-24 14:54:11 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-03-02 06:31:09 (GMT)
commite493f42f9a30d67c3548176ca970f081ba7e3f3f (patch)
tree89a6c8e870adea421ed07e44d283bf83274ed6ee
parent766eed3bf106a9ada4c15fdcc2847704c8f6f77a (diff)
adding gettext support
-rw-r--r--GUI_Components/Edit_Pane.py11
-rw-r--r--GUI_Components/Format_Pane.py3
-rw-r--r--GUI_Components/Image_Pane.py10
-rw-r--r--GUI_Components/Library_Pane.py6
-rw-r--r--GUI_Components/Publish_Pane.py2
-rw-r--r--sugaractivity.py131
6 files changed, 146 insertions, 17 deletions
diff --git a/GUI_Components/Edit_Pane.py b/GUI_Components/Edit_Pane.py
index 36ea739..e591fb4 100644
--- a/GUI_Components/Edit_Pane.py
+++ b/GUI_Components/Edit_Pane.py
@@ -9,6 +9,7 @@ from GUI_Components.Compound_Widgets.Library_View import Library_View
from Processing.Article.Article import Article
from Processing.IO_Manager import IO_Manager
import logging
+from gettext import gettext as _
logger = logging.getLogger('infoslicer')
@@ -116,11 +117,11 @@ class Edit_Pane(Pane):
start = buf.get_start_iter()
end = buf.get_end_iter()
buf.delete(start, end)
- buf.insert(buf.get_start_iter(), _("You can choose a Wikipedia article to copy from by selecting it from the drop-down menu above."))
- buf.insert(buf.get_end_iter(), _("If you want to download more articles from Wikipedia, you can do this in the Library tab."))
+ buf.insert(buf.get_start_iter(), _("\nYou can choose a Wikipedia article to copy from by selecting it from the drop-down menu above.\n\n"))
+ buf.insert(buf.get_end_iter(), "If you want to download more articles from Wikipedia, you can do this in the Library tab.")
else:
buf = article.getBuffer()
- buf.insert(buf.get_start_iter(), _("You have not downloaded any articles from Wikipedia. You can download new articles in the Library tab."))
+ buf.insert(buf.get_start_iter(), _("\nYou have not downloaded any articles from Wikipedia.\n\nYou can download new articles in the Library tab."))
i = 0
selectionindex = 0
@@ -141,9 +142,7 @@ class Edit_Pane(Pane):
return article
def set_working_article(self, article):
- self.editarticle.articletitle.set_markup("<span size='medium'><b> %s </b> %s \n<b> %s </b> %s</span>" % \
- (_("Theme:"), article.article_theme, _("Article:"), article.article_title))
+ self.editarticle.articletitle.set_markup("<span size='medium'><b>" + _("Theme:") + "</b> %s \n<b>" + _("Article:") + "</b> %s</span>"%(article.article_theme, article.article_title))
self.editarticle.textbox.set_article(article)
self.editarticle.article_theme = _("Wikipedia Articles")
-
diff --git a/GUI_Components/Format_Pane.py b/GUI_Components/Format_Pane.py
index d4bba35..511d633 100644
--- a/GUI_Components/Format_Pane.py
+++ b/GUI_Components/Format_Pane.py
@@ -95,6 +95,5 @@ class Format_Pane(Pane):
return article
def set_working_article(self, article):
- self.panel.articletitle.set_markup("<span size='medium'><b> %s </b> %s \n<b> %s </b> %s</span>" % \
- (_("Theme:"), article.article_theme, _("Article:"), article.article_title))
+ self.panel.articletitle.set_markup("<span size='medium'><b>" + _("Theme:") + "</b> %s \n<b>" + _("Article:") + "</b> %s</span>"%(article.article_theme, article.article_title))
self.panel.textbox.set_article(article)
diff --git a/GUI_Components/Image_Pane.py b/GUI_Components/Image_Pane.py
index b5a458e..04dcd7b 100644
--- a/GUI_Components/Image_Pane.py
+++ b/GUI_Components/Image_Pane.py
@@ -8,6 +8,7 @@ from GUI_Components.Compound_Widgets.Gallery_View import Gallery_View
from Processing.Article.Article import Article
from Processing.IO_Manager import IO_Manager
import logging
+from gettext import gettext as _
logger = logging.getLogger('infoslicer')
@@ -107,16 +108,16 @@ class Image_Pane(Pane):
return article
def set_working_article(self, article):
- logger.debug("working received, title %s theme %s " %
+ logger.debug("working received, title %s theme %s " %
(article.article_title, article.article_theme))
- self.editarticle.articletitle.set_markup("<span size='medium'><b>Theme:</b> %s \n<b>Article:</b> %s</span>"%(article.article_theme, article.article_title))
+ self.editarticle.articletitle.set_markup("<span size='medium'><b>" + _("Theme:") + "</b> %s \n<b>" + _("Article:") + "</b> %s</span>"%(article.article_theme, article.article_title))
if article == None:
article = Article()
self.editarticle.textbox.set_article(article)
if article.article_theme == None:
article.article_theme = _("My Articles")
- theme_list = IO_Manager().get_pages_in_theme(_("Wikipedia Articles"))
- self.gallery.theme = _("Wikipedia Articles")
+ theme_list = IO_Manager().get_pages_in_theme("Wikipedia Articles")
+ self.gallery.theme = "Wikipedia Articles"
count = -1
self.gallery.articlemenu.get_model().clear()
@@ -127,4 +128,3 @@ class Image_Pane(Pane):
self.gallery.articlemenu.set_active(count)
-
diff --git a/GUI_Components/Library_Pane.py b/GUI_Components/Library_Pane.py
index 1ecb7d6..4dd200f 100644
--- a/GUI_Components/Library_Pane.py
+++ b/GUI_Components/Library_Pane.py
@@ -68,12 +68,12 @@ class Library_Pane(Pane):
searchentry = gtk.Entry()
searchentry.set_text(_("Article name"))
- searchentry.connect("activate", self.click_search_button, None)
+ searchentry.connect(_("activate"), self.click_search_button, None)
searchentryitem.add(searchentry)
searchentry.show()
self.searchbutton = gtk.ToolButton(gtk.STOCK_FIND)
- self.searchbutton.connect("clicked", self.librarypanel.commence_retrieval, searchentry, statuslabel, wikimenu, self.wikis)
+ self.searchbutton.connect(_("clicked"), self.librarypanel.commence_retrieval, searchentry, statuslabel, wikimenu, self.wikis)
self.toolbar.insert(self.searchbutton, -1)
self.searchbutton.show()
@@ -91,7 +91,7 @@ class Library_Pane(Pane):
self.name = _("Library")
def click_search_button(self, widget, data):
- self.searchbutton.emit("clicked")
+ self.searchbutton.emit(_("clicked"))
def get_source_article(self):
return self.librarypanel.get_source()
diff --git a/GUI_Components/Publish_Pane.py b/GUI_Components/Publish_Pane.py
index 94b9f0f..5673dfc 100644
--- a/GUI_Components/Publish_Pane.py
+++ b/GUI_Components/Publish_Pane.py
@@ -40,4 +40,4 @@ class Publish_Pane(Pane):
IO_Manager().save_article(article)
self.working = article
self.panel.populate_themes()
- self.panel.export_message.set_text(_("Select the theme you want, choose the articles you wish to include in the package and click 'Publish'."))
+ self.panel.export_message.set_text(_('Select the theme you want, choose the articles you wish to include in the package and click "Publish".'))
diff --git a/sugaractivity.py b/sugaractivity.py
new file mode 100644
index 0000000..8c2c560
--- /dev/null
+++ b/sugaractivity.py
@@ -0,0 +1,131 @@
+# Copyright (C) IBM Corporation 2008
+
+import gtk
+from Infoslicer_GUI import Infoslicer_GUI
+from sugar.activity import activity
+from gettext import gettext as _
+from Processing.IO_Manager import IO_Manager
+
+class sugaractivity( activity.Activity, Infoslicer_GUI ):
+ """
+ Created by Jonathan Mace
+
+ This is the Sugar implementation of the infoslicer GUI.
+
+ It sets things in the sugar.activity class in the abstract methods.
+ """
+
+ """
+ Set up Sugar specific GUI config and show interface
+ """
+ def __init__(self, handle):
+ activity.Activity.__init__(self, handle)
+ gtk.gdk.threads_init()
+ gtk.gdk.threads_enter()
+ self.toolbox = activity.ActivityToolbox(self)
+ Infoslicer_GUI.__init__(self)
+ self._name = handle
+ self.toolbox.connect("current-toolbar-changed", self.page_switched, None)
+
+ self.set_title(_('InfoSlicer'))
+
+ self.set_toolbox(self.toolbox)
+ self.toolbox.show()
+
+ self.show_all()
+ self.toolbox.set_current_toolbar(2)
+
+ print "dictionary:"
+ print handle.get_dict()
+
+ """
+ Operating system specific file reading and writing methods are below
+ """
+ def read_file(self, file_path):
+ print "reading the file"
+ """
+ At the moment, the format of a saved file will just be:
+ sourcetitle
+ edittitle
+ edittheme
+ currentindex
+ """
+
+ file = open(file_path, 'r')
+ text = file.read()
+ file.close()
+ lines = text.splitlines()
+ if len(lines) < 3:
+ return
+ sourcetitle = lines[0]
+ workingtitle = lines[1]
+ workingtheme = lines[2]
+ currentindex = lines[3]
+
+ print "file read"
+ print "sourcetitle: %s, workingtitle: %s, workingtheme: %s, currentindex: %s" % (sourcetitle, workingtitle, workingtheme, currentindex)
+ iomanager = IO_Manager()
+ if iomanager.page_exists(sourcetitle, "Wikipedia Articles"):
+ sourcearticle = iomanager.load_article(sourcetitle, "Wikipedia Articles")
+ else:
+ sourcearticle = Article()
+ sourcearticle.article_title = sourcetitle
+ sourcearticle.article_theme = "Wikipedia Articles"
+ if iomanager.page_exists(workingtitle, workingtheme):
+ workingarticle = iomanager.load_article(workingtitle, workingtheme)
+ else:
+ workingarticle = Article()
+ workingarticle.article_title = workingtitle
+ workingarticle.article_theme = workingtheme
+
+ self.switch_page(currentindex)
+
+ self.currentpane.set_source_article(sourcearticle)
+ self.currentpane.set_working_article(workingarticle)
+
+ def write_file(self, file_path):
+ print "writing the file to %s" % file_path
+ sourcearticle = self.currentpane.get_source_article()
+ workingarticle = self.currentpane.get_working_article()
+
+ sourcetitle = sourcearticle.article_title
+ if not sourcetitle:
+ sourcetitle = "none"
+ workingtitle = workingarticle.article_title
+ if not workingtitle:
+ workingtitle = "none"
+ workingtheme = workingarticle.article_theme
+ if not workingtheme:
+ workingtheme = "none"
+ currentindex = self.currentindex
+
+ file = open(file_path, 'w')
+ print "writing source: %s, working: %s, theme: %s" % (sourcetitle, workingtitle, workingtheme)
+ file.write("%s\n%s\n%s\n%s" % (sourcetitle, workingtitle, workingtheme, str(currentindex)))
+ file.close()
+
+
+
+ def settoolbars(self, toolbars, toolbarnames):
+ for i in range(0, len(toolbars)):
+ self.toolbox.add_toolbar(toolbarnames[i], toolbars[i])
+ toolbars[i].show()
+
+
+ def setpanel(self, panel):
+ self._main_view = panel
+ self.set_canvas(self._main_view)
+ self._main_view.show()
+
+
+ def page_switched(self, widget, page_num, data):
+ print "page_switched to %s" % (page_num, )
+ if page_num > 0:
+ self.mode_switched(page_num - 1)
+
+ def switch_page(self, page_num):
+ self.mode_switched(page_num)
+
+ def can_close(self):
+ self.do_quit_event()
+ return True