Index: gc_lang/fr/oxt/Lexicographer/Enumerator.py ================================================================== --- gc_lang/fr/oxt/Lexicographer/Enumerator.py +++ gc_lang/fr/oxt/Lexicographer/Enumerator.py @@ -3,11 +3,10 @@ # License: MPL 2 import unohelper import uno import traceback -import time import helpers import enum_strings import grammalecte.graphspell as sc @@ -56,17 +55,17 @@ setattr(xGridModel, k, w) self.xDialog.insertByName(name, xGridModel) return xGridModel def run (self, sLang): - dUI = enum_strings.getUI(sLang) + self.dUI = enum_strings.getUI(sLang) # dialog self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx) self.xDialog.Width = 240 self.xDialog.Height = 280 - self.xDialog.Title = dUI.get('title', "#title#") + self.xDialog.Title = self.dUI.get('title', "#title#") xWindowSize = helpers.getWindowSize() self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2)) self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2)) # fonts @@ -80,37 +79,37 @@ xFDSubTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD") xFDSubTitle.Name = "Verdana" # widget nX = 10 - nY1 = 10 + nY1 = 5 nY2 = nY1 + 225 nWidth = self.xDialog.Width - 20 nHeight = 10 # List - self._addWidget("list_section", 'FixedLine', nX, nY1, nWidth, nHeight, Label = dUI.get("list_section", "#err"), FontDescriptor = xFDTitle) - self._addWidget('count_button', 'Button', nX, nY1+12, 70, 10, Label = dUI.get('count_button', "#err")) - self._addWidget('count2_button', 'Button', nX+75, nY1+12, 70, 10, Label = dUI.get('count2_button', "#err")) - self._addWidget('unknown_button', 'Button', nX+150, nY1+12, 70, 10, Label = dUI.get('unknown_button', "#err")) + self._addWidget("list_section", 'FixedLine', nX, nY1, nWidth, nHeight, Label = self.dUI.get("list_section", "#err"), FontDescriptor = xFDTitle) + self._addWidget('count_button', 'Button', nX, nY1+12, 70, 10, Label = self.dUI.get('count_button', "#err")) + self._addWidget('count2_button', 'Button', nX+75, nY1+12, 70, 10, Label = self.dUI.get('count2_button', "#err")) + self._addWidget('unknown_button', 'Button', nX+150, nY1+12, 70, 10, Label = self.dUI.get('unknown_button', "#err")) self.xGridModel = self._addGrid("list_grid", nX, nY1+25, nWidth, 180, [ - {"Title": "Mot", "ColumnWidth": 180}, - {"Title": "Occur.", "ColumnWidth": 40} + {"Title": self.dUI.get("words", "#err"), "ColumnWidth": 175}, + {"Title": "Occurrences", "ColumnWidth": 45} ]) - self._addWidget('num_of_words', 'FixedText', nX, nY1+210, 60, nHeight, Label = dUI.get('num_of_words', "#err"), Align = 2) - self.xNumWord = self._addWidget('num_of_words_res', 'FixedText', nX+65, nY1+210, 30, nHeight, Label = "—") - self._addWidget('tot_of_words', 'FixedText', nX+100, nY1+210, 60, nHeight, Label = dUI.get('tot_of_words', "#err"), Align = 2) - self.xTotWord = self._addWidget('total_words_res', 'FixedText', nX+165, nY1+210, 30, nHeight, Label = "—") + self._addWidget('num_of_entries', 'FixedText', nX, nY1+210, 60, nHeight, Label = self.dUI.get('num_of_entries', "#err"), Align = 2) + self.xNumWord = self._addWidget('num_of_entries_res', 'FixedText', nX+65, nY1+210, 30, nHeight, Label = "—") + self._addWidget('tot_of_entries', 'FixedText', nX+100, nY1+210, 60, nHeight, Label = self.dUI.get('tot_of_entries', "#err"), Align = 2) + self.xTotWord = self._addWidget('tot_of_entries_res', 'FixedText', nX+165, nY1+210, 30, nHeight, Label = "—") # Tag - self._addWidget("tag_section", 'FixedLine', nX, nY2, nWidth, nHeight, Label = dUI.get("tag_section", "#err"), FontDescriptor = xFDTitle) + self._addWidget("tag_section", 'FixedLine', nX, nY2, nWidth, nHeight, Label = self.dUI.get("tag_section", "#err"), FontDescriptor = xFDTitle) - self._addWidget('tag_button', 'Button', nX, self.xDialog.Height-25, 50, 14, Label = dUI.get('tag_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x000000) + self._addWidget('tag_button', 'Button', nX, self.xDialog.Height-25, 50, 14, Label = self.dUI.get('tag_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x000000) # Close - self._addWidget('close_button', 'Button', self.xDialog.Width-60, self.xDialog.Height-25, 50, 14, Label = dUI.get('close_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000) + self._addWidget('close_button', 'Button', self.xDialog.Width-60, self.xDialog.Height-25, 50, 14, Label = self.dUI.get('close_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000) # container self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx) self.xContainer.setModel(self.xDialog) @@ -131,14 +130,17 @@ # XActionListener def actionPerformed (self, xActionEvent): try: if xActionEvent.ActionCommand == "Count": + self.setTitleOfFirstColumn(self.dUI.get("words", "#err")) self.count() elif xActionEvent.ActionCommand == "CountByLemma": + self.setTitleOfFirstColumn(self.dUI.get("lemmas", "#err")) self.count(bByLemma=True) elif xActionEvent.ActionCommand == "UnknownWords": + self.setTitleOfFirstColumn(self.dUI.get("unknown_words", "#err")) self.count(bOnlyUnknownWords=True) elif xActionEvent.ActionCommand == "Tag": pass elif xActionEvent.ActionCommand == "Close": self.xContainer.endExecute() @@ -155,10 +157,11 @@ # Code def getParagraphsOfText (self): "generator: returns full document text paragraph by paragraph" xCursor = self.xDocument.Text.createTextCursor() + #helpers.xray(xCursor) xCursor.gotoStart(False) xCursor.gotoEndOfParagraph(True) yield xCursor.getString() while xCursor.gotoNextParagraph(False): xCursor.gotoEndOfParagraph(True) @@ -185,16 +188,21 @@ for k, w in sorted(dWord.items(), key=lambda t: t[1], reverse=True): xGridDataModel.addRow(i, (k, w)) i += 1 nTotOccur += w self.xNumWord.Label = str(i) - self.xTotWord.Label = str(nTotOccur) + self.xTotWord.Label = nTotOccur # end of processing xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.ARROW")) xWindowPeer.setPointer(xPointer) for x in xWindowPeer.Windows: x.setPointer(xPointer) self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?) + + def setTitleOfFirstColumn (self, sTitle): + xColumnModel = self.xGridModel.ColumnModel + xColumn = xColumnModel.getColumn(0) + xColumn.Title = sTitle #g_ImplementationHelper = unohelper.ImplementationHelper() #g_ImplementationHelper.addImplementation(Enumerator, 'net.grammalecte.enumerator', ('com.sun.star.task.Job',)) Index: gc_lang/fr/oxt/Lexicographer/enum_strings.py ================================================================== --- gc_lang/fr/oxt/Lexicographer/enum_strings.py +++ gc_lang/fr/oxt/Lexicographer/enum_strings.py @@ -9,12 +9,16 @@ "list_section": "Calcul des occurrences des mots", "count_button": "Compter tout", "count2_button": "Compter par lemme", "unknown_button": "Mots inconnus", - "num_of_words": "Nombre de mots :", - "tot_of_words": "Total des mots :", + "num_of_entries": "Nombre d’entrées :", + "tot_of_entries": "Total des entrées :", + + "words": "Mots", + "lemmas": "Lemmes", + "unknown_words": "Mots inconnus", "tag_section": "Formatage", "tag": "Taguer", "close_button": "Fermer", @@ -24,14 +28,18 @@ "list_section": "Words", "count_button": "Count all", "count2_button": "Count by lemma", "unknown_button": "Unknown words", - "num_of_words": "Number of words:", - "tot_of_words": "Total of words:", + "num_of_entries": "Number of entries:", + "tot_of_entries": "Total of words:", + + "words": "Words", + "lemmas": "Lemmas", + "unknown_words": "Unknown words", "tag_section": "Format", "tag": "Tag", "close_button": "Close", }, }