Changeset 61
- Timestamp:
- Thu Jul 7 12:14:14 2005
- Files:
-
- trunk/transolution/xliffeditor/gtk_main.py (modified) (diff)
- trunk/transolution/xliffeditor/__init__.py (modified) (diff)
- trunk/transolution/xliffeditor/gtk_utils.py (modified) (diff)
- trunk/transolution/xliffeditor/xliffparser_ng.py (modified) (diff)
- trunk/transolution/xliffeditor/langs (added)
- trunk/transolution/xliffeditor/langs/langcodes.txt (added)
- trunk/win_setup.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/transolution/xliffeditor/gtk_main.py
r60 r61 74 74 return formatter 75 75 76 from transolution.path_mod import path 77 def getLangCodes(): 78 flangcodes = path(transolution.xliffeditor.langsdir) / 'langcodes.txt' 79 for line in flangcodes.lines(): 80 cols = line.strip().split('\t') 81 try: 82 lang,country,lcid = cols 83 except ValueError,e: 84 print e 85 else: 86 yield lang,country,lcid 76 87 77 88 import tm … … 286 297 return self.window.get_focus() 287 298 299 def _checkTargetLang(self,fname,xliff): 300 'Initialize target language of @xliff if there is none' 301 if len(xliff.files): 302 f = xliff.files[0] 303 if not f.getTargetLang(): 304 msg = _('Source language=%s\n'%(f.getSourceLang())) 305 msg += _('No target language set for file.\n') 306 msg += _('Please enter target language to use.') 307 308 try: 309 drop_down_values = ['%s (%s)'%(lcid,country) for lang,country,lcid in list(getLangCodes())] 310 except IOError,e: 311 drop_down_values = None 312 313 target_lang = entryDialog(self.window,_('Set target language for "%s"'%(path(fname).basename()) ),msg, _('Target language'), 314 default_response=gtk.RESPONSE_OK,drop_down_values=drop_down_values) 315 if target_lang: 316 # use the first part of the result string as it can have language description e.g. "AF-ZA (South Africa)" 317 target_lang = target_lang.split()[0] 318 # set the target languge the same for all files in the XLIFF (can this be a problem?) 319 for f in xliff.files: 320 f.setTargetLang(target_lang) 321 288 322 def openFile(self,xml): 289 323 'Open the xml file and add the Document to the notepad' 290 324 doc = createDocument(xml, use_skeleton=True ) 291 325 doc.setFormatter(getDocumentFormatter(self.doc_sub_formatters['Medium'])) 326 self._checkTargetLang(xml,doc.xliff) 327 292 328 329 # Create the DocumentViewPanel 293 330 notebook = self.notebook 294 295 docpanel = DocumentViewPanel(self.notebook,main_app=self, tag_table=self.tag_table) 331 docpanel = DocumentViewPanel(notebook,main_app=self, tag_table=self.tag_table) 296 332 297 333 # Set default fonts -
trunk/transolution/xliffeditor/__init__.py
r2 r61 2 2 GLADEDIR ='glade' 3 3 IMAGEDIR ='images' 4 LANGSDIR ='langs' 4 5 gladename="xliffeditor.glade" 5 6 … … 10 11 imagedir = os.path.join(__path__[0], IMAGEDIR) 11 12 13 langsdir = os.path.join(__path__[0], LANGSDIR) 14 12 15 # makes it work when run as py2exe 13 16 if not os.path.isfile(gladefile): -
trunk/transolution/xliffeditor/gtk_utils.py
r8 r61 155 155 return response 156 156 157 def entryDialog(parent,title,msg,lable,default_val=None,default_response=gtk.RESPONSE_OK): 157 def entryDialog(parent,title,msg,lable,default_val=None,default_response=gtk.RESPONSE_OK,drop_down_values = None): 158 ''' 159 Create a input dialog. 160 @drop_down_values = list of text values to fill a combobox dropdown with. 161 ''' 158 162 159 163 dialog = gtk.Dialog(title, parent, 0, … … 171 175 gtk.ICON_SIZE_DIALOG) 172 176 hbox.pack_start(stock, False, False, 0) 177 vbox = gtk.VBox(False, 8) 178 hbox.pack_start(vbox, True, True, 0) 179 vbox.pack_start(gtk.Label(msg), True, True, 0) 180 173 181 174 182 table = gtk.Table(2, 1) 175 183 table.set_row_spacings(4) 176 184 table.set_col_spacings(4) 177 hbox.pack_start(table, True, True, 0)185 vbox.pack_start(table, True, True, 0) 177 185 178 186 label = gtk.Label(lable) 179 187 label.set_use_underline(True) 180 188 table.attach(label, 0, 1, 0, 1) 181 local_entry1 = gtk.Entry() 182 table.attach(local_entry1, 1, 2, 0, 1) 189 190 if drop_down_values is None: 191 # Create entry 192 local_entry1 = gtk.Entry() 193 table.attach(local_entry1, 1, 2, 0, 1) 194 else: 195 # Create a combobox entry 196 combobox = gtk.combo_box_entry_new_text() 197 for v in drop_down_values: 198 combobox.append_text(v) 199 local_entry1 = combobox.child 200 table.attach(combobox, 1, 2, 0, 1) 201 print local_entry1 202 203 local_entry1.set_activates_default(True) 204 ## local_entry1 = gtk.Entry() 183 205 label.set_mnemonic_widget(local_entry1) 184 206 if default_val: 185 207 local_entry1.set_text(default_val) 186 208 187 local_entry1.set_activates_default(True)188 209 189 210 dialog.show_all() -
trunk/transolution/xliffeditor/xliffparser_ng.py
r52 r61 71 71 from transolution.path_mod import path 72 72 from document.segments import TuSegment,External,FileInfo,TuInfo 73 from transolution.xmlutils import loadXml,parseString,toxml,XmlError,getNodeAttr,setNodeAttr,getNodes,getElementsByTagName 73 from transolution.xmlutils import loadXml,parseString,toxml,XmlError,getNodeAttr,setNodeAttr,setCreateNodeAttr,getNodes,getElementsByTagName 73 73 import os 74 74 import zipfile,shutil … … 220 220 221 221 def setTargetLang(self,tlid): 222 self.node.attributes[(None,'target-language')].value = tlid 222 setCreateNodeAttr(self.node,'target-language',tlid) 223 ## self.node.attributes[(None,'target-language')].value = tlid 223 224 224 225 def getSourceLang(self): -
trunk/win_setup.py
r40 r61 42 42 data_files=[("images", glob.glob("transolution/xliffeditor/images/*.png")), 43 43 ("glade", glob.glob("transolution/xliffeditor/glade/*")), 44 ("langs", glob.glob("transolution/xliffeditor/langs/*")), 44 45 ("po", glob.glob("transolution/xliffeditor/po/*")), 45 46 ("filter_settings", glob.glob("transolution/filters/filter_settings/*"))
