From 54908da3605bb755d9faa79283cdc1619d7ab2c2 Mon Sep 17 00:00:00 2001 From: nubae Date: Sun, 27 Dec 2009 06:20:02 +0000 Subject: fixed global _ bug so now admin should work fine, user is being worked on --- diff --git a/pyqclic_common.py b/pyqclic_common.py index fb2eb3c..56e352b 100644 --- a/pyqclic_common.py +++ b/pyqclic_common.py @@ -85,7 +85,7 @@ class PyQClicCommon: , gtk.STOCK_SAVE , gtk.RESPONSE_OK) - file_dialog = gtk.FileChooserDialog(title=_("Select PyQClic Project") + file_dialog = gtk.FileChooserDialog(title="Select PyQClic Project" , action=dialog_action , buttons=dialog_buttons) """set the filename if we are saving""" @@ -98,7 +98,7 @@ class PyQClicCommon: file_dialog.add_filter(filter) """Create and add the 'all files' filter""" filter = gtk.FileFilter() - filter.set_name(_("All files")) + filter.set_name("All files") filter.add_pattern("*") file_dialog.add_filter(filter) @@ -119,7 +119,7 @@ class PyQClicCommon: window.set_title("PyQClic - %s" % (os.path.basename(xml_file))) else: - window.set_title(_("PyQClic - Untitled")) + window.set_title("PyQClic - Untitled") def decode64(self,data): filew = open('/tmp/pyqclic_decode.png','w') @@ -168,13 +168,12 @@ class PyQClicCommon: cr.show_text(self.string) - def about_program(self,widget): about = gtk.AboutDialog() about.set_program_name("PyQClic") about.set_version("0.2") about.set_copyright("(c) David Van Assche / ") - about.set_comments(_("PyClic is a tool similar to Jclic but written in python and containing collaboration")) + about.set_comments("PyClic is a tool similar to Jclic but written in python and containing collaboration") about.set_website("http://git.sugarlabs.org/projects/pyclic") about.set_logo(gtk.gdk.pixbuf_new_from_file("aboutpyclic.png")) about.run() diff --git a/pyqclicadmin.py b/pyqclicadmin.py index 220f3cc..2f776b6 100644 --- a/pyqclicadmin.py +++ b/pyqclicadmin.py @@ -96,7 +96,7 @@ class PyQClicAdmin: print "Tag not loaded, probably empty" title_loaded = True # Title Tag loaded at this point and placed by self.title_entry.set_text - elif (item_node.nodeName == pyQClicCommon._xml_tags[CATEGORY_TAG]): + elif (item_node.nodeName == PyQClicCommon._xml_tags[CATEGORY_TAG]): """Set the category, the firstChild in this case is the actual category that we saved.""" #Make sure it's not a blank string @@ -129,7 +129,7 @@ class PyQClicAdmin: category_loaded = True #At this point we have found category and title and have placed them in their #their corresponding positions - elif (item_node.nodeName == pyQClicCommon._xml_tags[AUTHOR_TAG]): + elif (item_node.nodeName == PyQClicCommon._xml_tags[AUTHOR_TAG]): """Set the author, the firstChild in this case is the actual author that we saved. This tag is not really that important and in fact was put in as an after though just in case its wanted""" @@ -140,7 +140,7 @@ class PyQClicAdmin: print "Tag not loaded, probably empty" author_loaded = True #At this point category, title and author have been loaded and placed in the document - elif (item_node.nodeName == pyQClicCommon._xml_tags[IMAGE_TAG]): + elif (item_node.nodeName == PyQClicCommon._xml_tags[IMAGE_TAG]): """Set the image, the firstChild in this case is the image that we saved. Then decode from base64""" #Make sure it's not a blank string @@ -154,7 +154,7 @@ class PyQClicAdmin: image_loaded = True #Weve now loaded the image, the category, the title and the author and placed #them in their corresponding positions. - elif (item_node.nodeName == pyQClicCommon._xml_tags[COLOR_TAG]): + elif (item_node.nodeName == PyQClicCommon._xml_tags[COLOR_TAG]): """Set the image, the firstChild in this case is the image that we saved. Then decode from base64""" #Make sure it's not a blank string @@ -182,13 +182,13 @@ class PyQClicAdmin: #We've now loaded all the QUIZ tag elements, the ones that require just one iteration. #We are looking for the questions Node, which contains all the iterrable values, that is to say #values for each question found. - elif (node.nodeName == pyQClicCommon._xml_tags[QUESTIONS_TAG]): + elif (node.nodeName == PyQClicCommon._xml_tags[QUESTIONS_TAG]): # Now loop through the question nodes children for item_node in node.childNodes: #We create an empty questions list to iterate through and place items in self.questions_list=[] #we look for the question tag - if (item_node.nodeName == pyQClicCommon._xml_tags[QUESTION_TAG]): + if (item_node.nodeName == PyQClicCommon._xml_tags[QUESTION_TAG]): """Grab all the questions.""" #Make sure it's not a blank string if (item_node.firstChild): @@ -206,7 +206,7 @@ class PyQClicAdmin: #create empty self.coordinate list to place coordinates into self.coordinate=[] # Look for coordinates tag - if (item_node.nodeName == pyQClicCommon._xml_tags[COORDINATES_TAG]): + if (item_node.nodeName == PyQClicCommon._xml_tags[COORDINATES_TAG]): """Grab all the coordinates.""" #Make sure it's not a blank string if (item_node.firstChild): @@ -227,7 +227,7 @@ class PyQClicAdmin: #iterator list called entradas. self.entradas=[] #we look for entry tag - if (item_node.nodeName == pyQClicCommon._xml_tags[ENTRY_TAG]): + if (item_node.nodeName == PyQClicCommon._xml_tags[ENTRY_TAG]): """Grab all the entries.""" #Make sure it's not a blank string if (item_node.firstChild): @@ -260,25 +260,25 @@ class PyQClicAdmin: The xml document that we will save the post to.""" #create - quiz_element = xml_document.createElement(pyQClicCommon._xml_tags[QUIZ_TAG]) + quiz_element = xml_document.createElement(PyQClicCommon._xml_tags[QUIZ_TAG]) #create - category_element = xml_document.createElement(pyQClicCommon._xml_tags[CATEGORY_TAG]) + category_element = xml_document.createElement(PyQClicCommon._xml_tags[CATEGORY_TAG]) #Create category category_element.appendChild(xml_document.createTextNode(self.Category)) #Creates - image_element = xml_document.createElement(pyQClicCommon._xml_tags[IMAGE_TAG]) + image_element = xml_document.createElement(PyQClicCommon._xml_tags[IMAGE_TAG]) #Create image image_element.appendChild(xml_document.createTextNode(self.Image)) #Creates - title_element = xml_document.createElement(pyQClicCommon._xml_tags[TITLE_TAG]) + title_element = xml_document.createElement(PyQClicCommon._xml_tags[TITLE_TAG]) #Creates title title_element.appendChild(xml_document.createTextNode(self.Title)) #Creates - author_element = xml_document.createElement(pyQClicCommon._xml_tags[AUTHOR_TAG]) + author_element = xml_document.createElement(PyQClicCommon._xml_tags[AUTHOR_TAG]) #Creates author author_element.appendChild(xml_document.createTextNode(self.Author)) #Creates - color_element = xml_document.createElement(pyQClicCommon._xml_tags[COLOR_TAG]) + color_element = xml_document.createElement(PyQClicCommon._xml_tags[COLOR_TAG]) #Create colorvalues list, and add R,G,B values to it (we should really strip the brackets on string #conversion here taking out the []), but we do that on load instead. Reason = this function was created #before the load function @@ -298,7 +298,7 @@ class PyQClicAdmin: # there is only one of each. xml_document.documentElement.appendChild(quiz_element) #create - questions_element = xml_document.createElement(pyQClicCommon._xml_tags[QUESTIONS_TAG]) + questions_element = xml_document.createElement(PyQClicCommon._xml_tags[QUESTIONS_TAG]) #Setup iteration Iterate = 0 #Set questions here, no point in saving values before hand, in fact, come to think of it, we dont really even @@ -308,17 +308,17 @@ class PyQClicAdmin: # while there are coordinates in the self.coordinates list, iterate through and save stuff while Iterate < len(self.coordinates): #Create - question_element = xml_document.createElement(pyQClicCommon._xml_tags[QUESTION_TAG]) + question_element = xml_document.createElement(PyQClicCommon._xml_tags[QUESTION_TAG]) #create question and turn to string (XML requires it) question_element.appendChild(xml_document.createTextNode(str(question))) c = self.coordinates[Iterate] #Create - coordinates_element = xml_document.createElement(pyQClicCommon._xml_tags[COORDINATES_TAG]) + coordinates_element = xml_document.createElement(PyQClicCommon._xml_tags[COORDINATES_TAG]) #create x,y, and turn into strings. This method is better than doing a str # as no bracets are saved, just value,value for each set of x,y coordinates. coordinates_element.appendChild(xml_document.createTextNode("%d,%d" % (c[0],c[1]))) #Create - entry_element = xml_document.createElement(pyQClicCommon._xml_tags[ENTRY_TAG]) + entry_element = xml_document.createElement(PyQClicCommon._xml_tags[ENTRY_TAG]) #create entry and append each entry via th iterator entry_element.appendChild(xml_document.createTextNode(self.Entries[Iterate])) @@ -345,7 +345,7 @@ class PyQClicAdmin: #Get the available DOM Implementation, in this case, the XML parser impl = minidom.getDOMImplementation() #Create the document, with PyClicAdmin as base node - xml_document = impl.createDocument(None, pyQClicCommon._xml_tags[MAIN_TAG], None) + xml_document = impl.createDocument(None, PyQClicCommon._xml_tags[MAIN_TAG], None) #Save the questions into the xml self.xml_save(xml_document) #Now actually try to save the file @@ -544,7 +544,7 @@ class PyQClicAdmin: """Allright it all worked! save the current file and set the title.""" self.xml_file = xml_file - pyQClicCommon.set_window_title_from_file(self.xml_file) + PyQClicCommon.set_window_title_from_file(self.xml_file) #simple little function to grab combobox changed value for category def on_changed(self,widget): @@ -617,26 +617,28 @@ class PyQClicAdmin: # Now lets get all of the supported languages on the system language = os.environ.get('LANGUAGE', None) if (language): - """langage comes back something like en_CA:en_US:en_GB:en - on linuxy systems, on Win32 it's nothing, so we need to - split it up into a list""" +# """langage comes back something like en_CA:en_US:en_GB:en +# on linuxy systems, on Win32 it's nothing, so we need to +# split it up into a list""" langs += language.split(":") - """Now add on to the back of the list the translations that we - know that we have, our defaults""" +# """Now add on to the back of the list the translations that we +# know that we have, our defaults""" langs += ["en_US", "es_ES"] - """Now langs is a list of all of the languages that we are going - to try to use. First we check the default, then what the system - told us, and finally the 'known' list""" +# """Now langs is a list of all of the languages that we are going +# to try to use. First we check the default, then what the system +# told us, and finally the 'known' list""" gettext.bindtextdomain(APP_NAME, self.local_path) gettext.textdomain(APP_NAME) # Get the language to use self.lang = gettext.translation(APP_NAME, self.local_path , languages=langs, fallback = True) - """Install the language, map _() (which we marked our - strings to translate with) to self.lang.gettext() which will - translate them.""" +# """Install the language, map _() (which we marked our +# strings to translate with) to self.lang.gettext() which will +# translate them.""" + + global _ _ = self.lang.gettext diff --git a/pyqclicuser.py b/pyqclicuser.py index 7a1f8fd..2c1986f 100644 --- a/pyqclicuser.py +++ b/pyqclicuser.py @@ -55,7 +55,7 @@ class PyQClicUser: except IOError, (errno, strerror): #show error if not xml file or doesnt load. self.show_error_dlg( - "Error loading quiz file(%s): %s" % (errno, strerror)) + "Error loading quiz file[%s]: %s" % (errno, strerror)) return success # Heavy duty xml file parser. Stores false or true for all loaded objects, though currently unused in program @@ -102,7 +102,7 @@ class PyQClicUser: the actual category that we saved.""" #Make sure it's not a blank string if (item_node.firstChild): - self.title_category.set_text(_("Subject: ") + item_node.firstChild.nodeValue) + self.title_category.set_text(item_node.firstChild.nodeValue) else: print "Tag wasnt loaded, probably empy" category_loaded = True @@ -275,13 +275,13 @@ class PyQClicUser: #create questions_element = xml_document.createElement(PyQClicCommon._xml_tags[QUESTIONS_TAG]) #Setup iteration - Iterate = 0 + self.Iterate = 0 #Set questions here, no point in saving values before hand, in fact, come to think of it, we dont really even #need to save this, as it is quite clear we have questions going up in number starting at 1. But for #clarity of XML document we do it that way. question = 1 # while there are coordinates in the self.coordinates list, iterate through and save stuff - while Iterate < len(self.coordinates): + while self.Iterate < len(self.coordinates): #Create question_element = xml_document.createElement(PyQClicCommon._xml_tags[QUESTION_TAG]) #create question and turn to string (XML requires it) @@ -392,8 +392,8 @@ class PyQClicUser: self.cr.show_text(self.string) height=50 - while self.iterate < len(self.Entries): - if self.iterate==0: + while self.Iterate < len(self.Entries): + if self.Iterate==0: #Draw the results page self.cr.set_source_rgb(0.7, 0.2, 0.0) #draw outer rectangle @@ -409,8 +409,8 @@ class PyQClicUser: self.cr.set_source_rgb(0,0,0) self.cr.show_text(self.answer_string) else: - print str(self.Entries[self.iterate])+_(" is wrong!") - self.iterate=self.iterate+1 + print str(self.Entries[self.Iterate])+_(" is wrong!") + self.iterate=self.Iterate+1 height=height+30 #needed function to get the active text from the combo box, as gtk doesnt have that built in. found on the web @@ -532,6 +532,7 @@ class PyQClicUser: self.vbox2.remove(label) for label2 in self.label2_list: self.vbox2.remove(label2) + _=self.lang.gettext self.entry_list=[] self.Entries=[] self.coordinates=[] @@ -598,6 +599,7 @@ class PyQClicUser: """Install the language, map _() (which we marked our strings to translate with) to self.lang.gettext() which will translate them.""" + global _ _ = self.lang.gettext @@ -731,6 +733,8 @@ class PyQClicUser: self.question_list=[] #define empty labels2 list self.label2_list=[] + self.Iterate=[] + self.Entries=[] #define color values for question circle self.colorred=0 @@ -768,7 +772,7 @@ class PyQClicUser: #Add an author label self.author_label=gtk.Label(_("Author")) self.vbox2.pack_start(self.author_label,False,False,0) - #Add a Category label + #Add a Category label self.title_category=gtk.Label(_("Category")) self.vbox2.pack_start(self.title_category,False,False,0) -- cgit v0.9.1