Index: gc_lang/fr/oxt/TextFormatter/TextFormatter.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/TextFormatter.py +++ gc_lang/fr/oxt/TextFormatter/TextFormatter.py @@ -7,11 +7,11 @@ import traceback import time import json -import tf_strings +import tf_strings as ui import tf_options import tf_tabrep import helpers import TextFormatterEditor @@ -38,11 +38,10 @@ def __init__ (self, ctx): self.ctx = ctx self.xSvMgr = self.ctx.ServiceManager self.xContainer = None self.xDialog = None - helpers.startConsole() # XJobExecutor def trigger (self, args): try: xTF = TextFormatter(self.ctx) @@ -62,16 +61,17 @@ self.xDialog.insertByName(name, xWidget) return xWidget def run (self, sLang): self.sLang = sLang - self.dUI = tf_strings.getUI(sLang) + + ui.selectLang(sLang) ## dialog self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx) self.xDialog.Width = 310 - self.xDialog.Title = self.dUI.get('title', "#title#") + self.xDialog.Title = ui.get('title') ## fonts xFD1 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor") xFD1.Height = 12 xFD1.Name = "Verdana" @@ -99,20 +99,20 @@ self.bClose = False # group box // surnumerary spaces y = 10 nPosRes = nRightLimit1 - 20 - self.ssp = self._addWidget('ssp', 'CheckBox', x, y+2, nWidth, nHeight, Label = self.dUI.get('ssp', "#err"), FontDescriptor = xFD1, \ + self.ssp = self._addWidget('ssp', 'CheckBox', x, y+2, nWidth, nHeight, Label = ui.get('ssp'), FontDescriptor = xFD1, \ FontRelief = 1, TextColor = nColor, State = True) self._addWidget("section1", 'FixedLine', nRightLimit1-(nWidth//5), y, nWidth//5, nHeight) - self.ssp1 = self._addWidget('ssp1', 'CheckBox', x, y+15, nWidth, nHeight, Label = self.dUI.get('ssp1', "#err"), State = True) - self.ssp2 = self._addWidget('ssp2', 'CheckBox', x, y+25, nWidth, nHeight, Label = self.dUI.get('ssp2', "#err"), State = True) - self.ssp3 = self._addWidget('ssp3', 'CheckBox', x, y+35, nWidth, nHeight, Label = self.dUI.get('ssp3', "#err"), State = True) - self.ssp4 = self._addWidget('ssp4', 'CheckBox', x, y+45, nWidth, nHeight, Label = self.dUI.get('ssp4', "#err"), State = True) - self.ssp5 = self._addWidget('ssp5', 'CheckBox', x, y+55, nWidth, nHeight, Label = self.dUI.get('ssp5', "#err"), State = True) - self.ssp6 = self._addWidget('ssp6', 'CheckBox', x, y+65, nWidth, nHeight, Label = self.dUI.get('ssp6', "#err"), State = True) - self.ssp7 = self._addWidget('ssp7', 'CheckBox', x, y+75, nWidth, nHeight, Label = self.dUI.get('ssp7', "#err"), State = True) + self.ssp1 = self._addWidget('ssp1', 'CheckBox', x, y+15, nWidth, nHeight, Label = ui.get('ssp1'), State = True) + self.ssp2 = self._addWidget('ssp2', 'CheckBox', x, y+25, nWidth, nHeight, Label = ui.get('ssp2'), State = True) + self.ssp3 = self._addWidget('ssp3', 'CheckBox', x, y+35, nWidth, nHeight, Label = ui.get('ssp3'), State = True) + self.ssp4 = self._addWidget('ssp4', 'CheckBox', x, y+45, nWidth, nHeight, Label = ui.get('ssp4'), State = True) + self.ssp5 = self._addWidget('ssp5', 'CheckBox', x, y+55, nWidth, nHeight, Label = ui.get('ssp5'), State = True) + self.ssp6 = self._addWidget('ssp6', 'CheckBox', x, y+65, nWidth, nHeight, Label = ui.get('ssp6'), State = True) + self.ssp7 = self._addWidget('ssp7', 'CheckBox', x, y+75, nWidth, nHeight, Label = ui.get('ssp7'), State = True) self.ssp1_res = self._addWidget('ssp1_res', 'FixedText', nPosRes, y+15, 20, nHeight, Label = "", Align = 2) self.ssp2_res = self._addWidget('ssp2_res', 'FixedText', nPosRes, y+25, 20, nHeight, Label = "", Align = 2) self.ssp3_res = self._addWidget('ssp3_res', 'FixedText', nPosRes, y+35, 20, nHeight, Label = "", Align = 2) self.ssp4_res = self._addWidget('ssp4_res', 'FixedText', nPosRes, y+45, 20, nHeight, Label = "", Align = 2) self.ssp5_res = self._addWidget('ssp5_res', 'FixedText', nPosRes, y+55, 20, nHeight, Label = "", Align = 2) @@ -119,81 +119,81 @@ self.ssp6_res = self._addWidget('ssp6_res', 'FixedText', nPosRes, y+65, 20, nHeight, Label = "", Align = 2) self.ssp7_res = self._addWidget('ssp7_res', 'FixedText', nPosRes, y+75, 20, nHeight, Label = "", Align = 2) # group box // missing spaces y = y + 85 - self.space = self._addWidget('space', 'CheckBox', x, y+2, nWidth, nHeight, Label = self.dUI.get('space', "#err"), FontDescriptor = xFD1, \ + self.space = self._addWidget('space', 'CheckBox', x, y+2, nWidth, nHeight, Label = ui.get('space'), FontDescriptor = xFD1, \ FontRelief = 1, TextColor = nColor, State = True) self._addWidget("section2", 'FixedLine', nRightLimit1-(nWidth//3), y, nWidth//3, nHeight) - self.space1 = self._addWidget('space1', 'CheckBox', x, y+15, nWidth, nHeight, Label = self.dUI.get('space1', "#err"), State = True) - self.space2 = self._addWidget('space2', 'CheckBox', x, y+25, nWidth, nHeight, Label = self.dUI.get('space2', "#err"), State = True) + self.space1 = self._addWidget('space1', 'CheckBox', x, y+15, nWidth, nHeight, Label = ui.get('space1'), State = True) + self.space2 = self._addWidget('space2', 'CheckBox', x, y+25, nWidth, nHeight, Label = ui.get('space2'), State = True) self.space1_res = self._addWidget('space1_res', 'FixedText', nPosRes, y+15, 20, nHeight, Label = "", Align = 2) self.space2_res = self._addWidget('space2_res', 'FixedText', nPosRes, y+25, 20, nHeight, Label = "", Align = 2) # group box // non-breaking spaces y = y + 35 - self.nbsp = self._addWidget('nbsp', 'CheckBox', x, y+2, nWidth, nHeight, Label = self.dUI.get('nbsp', "#err"), FontDescriptor = xFD1, \ + self.nbsp = self._addWidget('nbsp', 'CheckBox', x, y+2, nWidth, nHeight, Label = ui.get('nbsp'), FontDescriptor = xFD1, \ FontRelief = 1, TextColor = nColor, State = True) self._addWidget("section3", 'FixedLine', nRightLimit1-(nWidth//3), y, nWidth//3, nHeight) - self.nbsp1 = self._addWidget('nbsp1', 'CheckBox', x, y+15, 85, nHeight, Label = self.dUI.get('nbsp1', "#err"), State = True) - self.nbsp2 = self._addWidget('nbsp2', 'CheckBox', x, y+25, 85, nHeight, Label = self.dUI.get('nbsp2', "#err"), State = True) - self.nbsp3 = self._addWidget('nbsp3', 'CheckBox', x, y+35, nWidth, nHeight, Label = self.dUI.get('nbsp3', "#err"), State = True) - self.nbsp4 = self._addWidget('nbsp4', 'CheckBox', x, y+45, 85, nHeight, Label = self.dUI.get('nbsp4', "#err"), State = True) - self.nbsp5 = self._addWidget('nbsp5', 'CheckBox', x, y+55, 85, nHeight, Label = self.dUI.get('nbsp5', "#err"), State = True) - self.nbsp6 = self._addWidget('nbsp6', 'CheckBox', x, y+65, 85, nHeight, Label = self.dUI.get('nbsp6', "#err"), State = True) - self.nnbsp1 = self._addWidget('nnbsp1', 'CheckBox', x+85, y+15, 30, nHeight, Label = self.dUI.get('nnbsp', "#err"), HelpText = self.dUI.get('nnbsp_help', "#err"), State = False) - self.nnbsp2 = self._addWidget('nnbsp2', 'CheckBox', x+85, y+25, 30, nHeight, Label = self.dUI.get('nnbsp', "#err"), State = False) - self.nnbsp4 = self._addWidget('nnbsp4', 'CheckBox', x+85, y+45, 30, nHeight, Label = self.dUI.get('nnbsp', "#err"), State = False) + self.nbsp1 = self._addWidget('nbsp1', 'CheckBox', x, y+15, 85, nHeight, Label = ui.get('nbsp1'), State = True) + self.nbsp2 = self._addWidget('nbsp2', 'CheckBox', x, y+25, 85, nHeight, Label = ui.get('nbsp2'), State = True) + self.nbsp3 = self._addWidget('nbsp3', 'CheckBox', x, y+35, nWidth, nHeight, Label = ui.get('nbsp3'), State = True) + self.nbsp4 = self._addWidget('nbsp4', 'CheckBox', x, y+45, 85, nHeight, Label = ui.get('nbsp4'), State = True) + self.nbsp5 = self._addWidget('nbsp5', 'CheckBox', x, y+55, 85, nHeight, Label = ui.get('nbsp5'), State = True) + self.nbsp6 = self._addWidget('nbsp6', 'CheckBox', x, y+65, 85, nHeight, Label = ui.get('nbsp6'), State = True) + self.nnbsp1 = self._addWidget('nnbsp1', 'CheckBox', x+85, y+15, 30, nHeight, Label = ui.get('nnbsp'), HelpText = ui.get('nnbsp_help'), State = False) + self.nnbsp2 = self._addWidget('nnbsp2', 'CheckBox', x+85, y+25, 30, nHeight, Label = ui.get('nnbsp'), State = False) + self.nnbsp4 = self._addWidget('nnbsp4', 'CheckBox', x+85, y+45, 30, nHeight, Label = ui.get('nnbsp'), State = False) self.nbsp1_res = self._addWidget('nbsp1_res', 'FixedText', nPosRes, y+15, 20, nHeight, Label = "", Align = 2) self.nbsp2_res = self._addWidget('nbsp2_res', 'FixedText', nPosRes, y+25, 20, nHeight, Label = "", Align = 2) self.nbsp3_res = self._addWidget('nbsp3_res', 'FixedText', nPosRes, y+35, 20, nHeight, Label = "", Align = 2) self.nbsp4_res = self._addWidget('nbsp4_res', 'FixedText', nPosRes, y+45, 20, nHeight, Label = "", Align = 2) self.nbsp5_res = self._addWidget('nbsp5_res', 'FixedText', nPosRes, y+55, 20, nHeight, Label = "", Align = 2) self.nbsp6_res = self._addWidget('nbsp6_res', 'FixedText', nPosRes, y+65, 20, nHeight, Label = "", Align = 2) # group box // deletion y = y + 75 - self.delete = self._addWidget('delete', 'CheckBox', x, y+2, nWidth, nHeight, Label = self.dUI.get('delete', "#err"), FontDescriptor = xFD1, \ + self.delete = self._addWidget('delete', 'CheckBox', x, y+2, nWidth, nHeight, Label = ui.get('delete'), FontDescriptor = xFD1, \ FontRelief = 1, TextColor = nColor, State = True) self._addWidget("section7", 'FixedLine', nRightLimit1-(nWidth//2), y, nWidth//2, nHeight) - self.delete1 = self._addWidget('delete1', 'CheckBox', x, y+15, nWidth, nHeight, Label = self.dUI.get('delete1', "#err"), State = True) - self.delete2 = self._addWidget('delete2', 'CheckBox', x, y+25, nWidth, nHeight, Label = self.dUI.get('delete2', "#err"), State = True) - self.delete2a = self._addWidget('delete2a', 'RadioButton', x+10, y+35, 50, nHeight, Label = self.dUI.get('delete2a', "#")) - self.delete2b = self._addWidget('delete2b', 'RadioButton', x+60, y+35, 60, nHeight, Label = self.dUI.get('delete2b', "#"), State = True) - self.delete2c = self._addWidget('delete2c', 'RadioButton', x+120, y+35, 40, nHeight, Label = self.dUI.get('delete2c', "#"), \ - HelpText = self.dUI.get('delete2c_help', "#err")) + self.delete1 = self._addWidget('delete1', 'CheckBox', x, y+15, nWidth, nHeight, Label = ui.get('delete1'), State = True) + self.delete2 = self._addWidget('delete2', 'CheckBox', x, y+25, nWidth, nHeight, Label = ui.get('delete2'), State = True) + self.delete2a = self._addWidget('delete2a', 'RadioButton', x+10, y+35, 50, nHeight, Label = ui.get('delete2a')) + self.delete2b = self._addWidget('delete2b', 'RadioButton', x+60, y+35, 60, nHeight, Label = ui.get('delete2b'), State = True) + self.delete2c = self._addWidget('delete2c', 'RadioButton', x+120, y+35, 40, nHeight, Label = ui.get('delete2c'), \ + HelpText = ui.get('delete2c_help')) self.delete1_res = self._addWidget('delete1_res', 'FixedText', nPosRes, y+15, 20, nHeight, Label = "", Align = 2) self.delete2_res = self._addWidget('delete2_res', 'FixedText', nPosRes, y+25, 20, nHeight, Label = "", Align = 2) # group box // typographical marks y = 10 nPosRes = nRightLimit2 - 20 - self.typo = self._addWidget('typo', 'CheckBox', x2, y+2, nWidth, nHeight, Label = self.dUI.get('typo', "#err"), FontDescriptor = xFD1, \ + self.typo = self._addWidget('typo', 'CheckBox', x2, y+2, nWidth, nHeight, Label = ui.get('typo'), FontDescriptor = xFD1, \ FontRelief = 1, TextColor = nColor, State = True) self._addWidget("section4", 'FixedLine', nRightLimit2-(nWidth//5), y, nWidth//5, nHeight) - self.typo1 = self._addWidget('typo1', 'CheckBox', x2, y+15, nWidth, nHeight, Label = self.dUI.get('typo1', "#err"), State = True) - self.typo2 = self._addWidget('typo2', 'CheckBox', x2, y+25, nWidth, nHeight, Label = self.dUI.get('typo2', "#err"), State = True) - self.typo3 = self._addWidget('typo3', 'CheckBox', x2, y+35, nWidth, nHeight, Label = self.dUI.get('typo3', "#err"), State = True) - self.typo3a = self._addWidget('typo3a', 'RadioButton', x2+10, y+45, nWidthHalf, nHeight, Label = self.dUI.get('emdash', "#err")) - self.typo3b = self._addWidget('typo3b', 'RadioButton', x2+70, y+45, nWidthHalf, nHeight, Label = self.dUI.get('endash', "#err"), State = True) - self.typo4 = self._addWidget('typo4', 'CheckBox', x2, y+55, nWidth, nHeight, Label = self.dUI.get('typo4', "#err"), State = True) - self.typo4a = self._addWidget('typo4a', 'RadioButton', x2+10, y+65, nWidthHalf, nHeight, Label = self.dUI.get('emdash', "#err"), State = True) - self.typo4b = self._addWidget('typo4b', 'RadioButton', x2+70, y+65, nWidthHalf, nHeight, Label = self.dUI.get('endash', "#err")) - self.typo5 = self._addWidget('typo5', 'CheckBox', x2, y+75, nWidth, nHeight, Label = self.dUI.get('typo5', "#err"), State = True) - self.typo6 = self._addWidget('typo6', 'CheckBox', x2, y+85, nWidth, nHeight, Label = self.dUI.get('typo6', "#err"), State = True) - self.typo7 = self._addWidget('typo7', 'CheckBox', x2, y+95, nWidth, nHeight, Label = self.dUI.get('typo7', "#err"), State = True) - self.typo8 = self._addWidget('typo8', 'CheckBox', x2, y+105, 35, nHeight, Label = self.dUI.get('typo8', "#err"), \ - HelpText = self.dUI.get('typo8_help', "#err"), State = True) - self.typo8a = self._addWidget('typo8a', 'RadioButton', x2+45, y+105, 30, nHeight, Label = self.dUI.get('typo8a', "#err")) - self.typo8b = self._addWidget('typo8b', 'RadioButton', x2+75, y+105, 35, nHeight, Label = self.dUI.get('typo8b', "#err"), State = True) - self.typo_ff = self._addWidget('typo_ff', 'CheckBox', x2+10, y+115, 18, nHeight, Label = self.dUI.get('typo_ff', "#err"), State = True) - self.typo_fi = self._addWidget('typo_fi', 'CheckBox', x2+28, y+115, 18, nHeight, Label = self.dUI.get('typo_fi', "#err"), State = True) - self.typo_ffi = self._addWidget('typo_ffi', 'CheckBox', x2+46, y+115, 20, nHeight, Label = self.dUI.get('typo_ffi', "#err"), State = True) - self.typo_fl = self._addWidget('typo_fl', 'CheckBox', x2+66, y+115, 18, nHeight, Label = self.dUI.get('typo_fl', "#err"), State = True) - self.typo_ffl = self._addWidget('typo_ffl', 'CheckBox', x2+84, y+115, 20, nHeight, Label = self.dUI.get('typo_ffl', "#err"), State = True) - self.typo_ft = self._addWidget('typo_ft', 'CheckBox', x2+104, y+115, 18, nHeight, Label = self.dUI.get('typo_ft', "#err"), State = True) - self.typo_st = self._addWidget('typo_st', 'CheckBox', x2+122, y+115, 18, nHeight, Label = self.dUI.get('typo_st', "#err"), State = True) + self.typo1 = self._addWidget('typo1', 'CheckBox', x2, y+15, nWidth, nHeight, Label = ui.get('typo1'), State = True) + self.typo2 = self._addWidget('typo2', 'CheckBox', x2, y+25, nWidth, nHeight, Label = ui.get('typo2'), State = True) + self.typo3 = self._addWidget('typo3', 'CheckBox', x2, y+35, nWidth, nHeight, Label = ui.get('typo3'), State = True) + self.typo3a = self._addWidget('typo3a', 'RadioButton', x2+10, y+45, nWidthHalf, nHeight, Label = ui.get('emdash')) + self.typo3b = self._addWidget('typo3b', 'RadioButton', x2+70, y+45, nWidthHalf, nHeight, Label = ui.get('endash'), State = True) + self.typo4 = self._addWidget('typo4', 'CheckBox', x2, y+55, nWidth, nHeight, Label = ui.get('typo4'), State = True) + self.typo4a = self._addWidget('typo4a', 'RadioButton', x2+10, y+65, nWidthHalf, nHeight, Label = ui.get('emdash'), State = True) + self.typo4b = self._addWidget('typo4b', 'RadioButton', x2+70, y+65, nWidthHalf, nHeight, Label = ui.get('endash')) + self.typo5 = self._addWidget('typo5', 'CheckBox', x2, y+75, nWidth, nHeight, Label = ui.get('typo5'), State = True) + self.typo6 = self._addWidget('typo6', 'CheckBox', x2, y+85, nWidth, nHeight, Label = ui.get('typo6'), State = True) + self.typo7 = self._addWidget('typo7', 'CheckBox', x2, y+95, nWidth, nHeight, Label = ui.get('typo7'), State = True) + self.typo8 = self._addWidget('typo8', 'CheckBox', x2, y+105, 35, nHeight, Label = ui.get('typo8'), \ + HelpText = ui.get('typo8_help'), State = True) + self.typo8a = self._addWidget('typo8a', 'RadioButton', x2+45, y+105, 30, nHeight, Label = ui.get('typo8a')) + self.typo8b = self._addWidget('typo8b', 'RadioButton', x2+75, y+105, 35, nHeight, Label = ui.get('typo8b'), State = True) + self.typo_ff = self._addWidget('typo_ff', 'CheckBox', x2+10, y+115, 18, nHeight, Label = ui.get('typo_ff'), State = True) + self.typo_fi = self._addWidget('typo_fi', 'CheckBox', x2+28, y+115, 18, nHeight, Label = ui.get('typo_fi'), State = True) + self.typo_ffi = self._addWidget('typo_ffi', 'CheckBox', x2+46, y+115, 20, nHeight, Label = ui.get('typo_ffi'), State = True) + self.typo_fl = self._addWidget('typo_fl', 'CheckBox', x2+66, y+115, 18, nHeight, Label = ui.get('typo_fl'), State = True) + self.typo_ffl = self._addWidget('typo_ffl', 'CheckBox', x2+84, y+115, 20, nHeight, Label = ui.get('typo_ffl'), State = True) + self.typo_ft = self._addWidget('typo_ft', 'CheckBox', x2+104, y+115, 18, nHeight, Label = ui.get('typo_ft'), State = True) + self.typo_st = self._addWidget('typo_st', 'CheckBox', x2+122, y+115, 18, nHeight, Label = ui.get('typo_st'), State = True) self.typo1_res = self._addWidget('typo1_res', 'FixedText', nPosRes, y+15, 20, nHeight, Label = "", Align = 2) self.typo2_res = self._addWidget('typo2_res', 'FixedText', nPosRes, y+25, 20, nHeight, Label = "", Align = 2) self.typo3_res = self._addWidget('typo3_res', 'FixedText', nPosRes, y+35, 20, nHeight, Label = "", Align = 2) self.typo4_res = self._addWidget('typo4_res', 'FixedText', nPosRes, y+55, 20, nHeight, Label = "", Align = 2) self.typo5_res = self._addWidget('typo5_res', 'FixedText', nPosRes, y+75, 20, nHeight, Label = "", Align = 2) @@ -201,40 +201,40 @@ self.typo7_res = self._addWidget('typo7_res', 'FixedText', nPosRes, y+95, 20, nHeight, Label = "", Align = 2) self.typo8_res = self._addWidget('typo8_res', 'FixedText', nPosRes, y+105, 20, nHeight, Label = "", Align = 2) # group box // misc. y = y + 125 - self.misc = self._addWidget('misc', 'CheckBox', x2, y+2, nWidth, nHeight, Label = self.dUI.get('misc', "#err"), FontDescriptor = xFD1, \ + self.misc = self._addWidget('misc', 'CheckBox', x2, y+2, nWidth, nHeight, Label = ui.get('misc'), FontDescriptor = xFD1, \ FontRelief = 1, TextColor = nColor, State = True) self._addWidget("section5", 'FixedLine', nRightLimit2-(nWidth//2), y, nWidth//2, nHeight) - self.misc1 = self._addWidget('misc1', 'CheckBox', x2, y+15, 80, nHeight, Label = self.dUI.get('misc1', "#err"), State = True) - self.misc1a = self._addWidget('misc1a', 'CheckBox', x2+80, y+15, 30, nHeight, Label = self.dUI.get('misc1a', "#err"), State = True) - self.misc2 = self._addWidget('misc2', 'CheckBox', x2, y+25, nWidth, nHeight, Label = self.dUI.get('misc2', "#err"), State = True) - self.misc3 = self._addWidget('misc3', 'CheckBox', x2, y+35, nWidth, nHeight, Label = self.dUI.get('misc3', "#err"), State = True) - #self.misc4 = self._addWidget('misc4', 'CheckBox', x2, y+45, nWidth, nHeight, Label = self.dUI.get('misc4', "#err"), State = True) - self.misc5 = self._addWidget('misc5', 'CheckBox', x2, y+45, nWidth, nHeight, Label = self.dUI.get('misc5', "#err"), State = True) - self.misc5b = self._addWidget('misc5b', 'CheckBox', x2+10, y+55, nWidth-40, nHeight, Label = self.dUI.get('misc5b', "#err"), State = False) - self.misc5c = self._addWidget('misc5c', 'CheckBox', x2+nWidth-25, y+55, 30, nHeight, Label = self.dUI.get('misc5c', "#err"), State = False) - self.misccustom = self._addWidget('misccustom', "CheckBox", x2, y+65, nWidth-40, nHeight, Label = self.dUI.get('misccustom', "#err"), State = False) - self.beditor = self._addWidget('editor', 'Button', x2+95, y+64, 30, 9, Label = self.dUI.get('editor', "#err"), \ - HelpText = self.dUI.get('editor_help', "#err"), FontDescriptor = xFDsmall) + self.misc1 = self._addWidget('misc1', 'CheckBox', x2, y+15, 80, nHeight, Label = ui.get('misc1'), State = True) + self.misc1a = self._addWidget('misc1a', 'CheckBox', x2+80, y+15, 30, nHeight, Label = ui.get('misc1a'), State = True) + self.misc2 = self._addWidget('misc2', 'CheckBox', x2, y+25, nWidth, nHeight, Label = ui.get('misc2'), State = True) + self.misc3 = self._addWidget('misc3', 'CheckBox', x2, y+35, nWidth, nHeight, Label = ui.get('misc3'), State = True) + #self.misc4 = self._addWidget('misc4', 'CheckBox', x2, y+45, nWidth, nHeight, Label = ui.get('misc4'), State = True) + self.misc5 = self._addWidget('misc5', 'CheckBox', x2, y+45, nWidth, nHeight, Label = ui.get('misc5'), State = True) + self.misc5b = self._addWidget('misc5b', 'CheckBox', x2+10, y+55, nWidth-40, nHeight, Label = ui.get('misc5b'), State = False) + self.misc5c = self._addWidget('misc5c', 'CheckBox', x2+nWidth-25, y+55, 30, nHeight, Label = ui.get('misc5c'), State = False) + self.misccustom = self._addWidget('misccustom', "CheckBox", x2, y+65, nWidth-40, nHeight, Label = ui.get('misccustom'), State = False) + self.beditor = self._addWidget('editor', 'Button', x2+95, y+64, 25, 9, Label = ui.get('editor'), \ + HelpText = ui.get('editor_help'), FontDescriptor = xFDsmall) self.misc1_res = self._addWidget('misc1_res', 'FixedText', nPosRes, y+15, 20, nHeight, Label = "", Align = 2) self.misc2_res = self._addWidget('misc2_res', 'FixedText', nPosRes, y+25, 20, nHeight, Label = "", Align = 2) self.misc3_res = self._addWidget('misc3_res', 'FixedText', nPosRes, y+35, 20, nHeight, Label = "", Align = 2) #self.misc4_res = self._addWidget('misc4_res', 'FixedText', nPosRes, y+45, 20, nHeight, Label = "", Align = 2) self.misc5_res = self._addWidget('misc5_res', 'FixedText', nPosRes, y+45, 20, nHeight, Label = "", Align = 2) - self.misccustom_res = self._addWidget('misccustom_res', 'FixedText', nPosRes, y+55, 20, nHeight, Label = "", Align = 2) + self.misccustom_res = self._addWidget('misccustom_res', 'FixedText', nPosRes, y+65, 20, nHeight, Label = "", Align = 2) # group box // restructuration y = y + 75 - self.struct = self._addWidget('struct', 'CheckBox', x2, y+2, nWidth, nHeight, Label = self.dUI.get('struct', "#err"), FontDescriptor = xFD1, \ - FontRelief = 1, TextColor = nColor, HelpText = self.dUI.get('struct_help', "#err"), State = False) + self.struct = self._addWidget('struct', 'CheckBox', x2, y+2, nWidth, nHeight, Label = ui.get('struct'), FontDescriptor = xFD1, \ + FontRelief = 1, TextColor = nColor, HelpText = ui.get('struct_help'), State = False) self._addWidget("section6", 'FixedLine', nRightLimit2-(nWidth//3), y, nWidth//3, nHeight) - self.struct1 = self._addWidget('struct1', 'CheckBox', x2, y+15, nWidth, nHeight, Label = self.dUI.get('struct1', "#err"), State = True, Enabled = False) - self.struct2 = self._addWidget('struct2', 'CheckBox', x2, y+25, nWidth, nHeight, Label = self.dUI.get('struct2', "#err"), State = True, Enabled = False) - self.struct3 = self._addWidget('struct3', 'CheckBox', x2, y+35, nWidth, nHeight, Label = self.dUI.get('struct3', "#err"), \ - HelpText = self.dUI.get('struct3_help', "#err"), State = False, Enabled = False) + self.struct1 = self._addWidget('struct1', 'CheckBox', x2, y+15, nWidth, nHeight, Label = ui.get('struct1'), State = True, Enabled = False) + self.struct2 = self._addWidget('struct2', 'CheckBox', x2, y+25, nWidth, nHeight, Label = ui.get('struct2'), State = True, Enabled = False) + self.struct3 = self._addWidget('struct3', 'CheckBox', x2, y+35, nWidth, nHeight, Label = ui.get('struct3'), \ + HelpText = ui.get('struct3_help'), State = False, Enabled = False) self.struct1_res = self._addWidget('struct1_res', 'FixedText', nPosRes, y+15, 20, nHeight, Label = "", Align = 2) self.struct2_res = self._addWidget('struct2_res', 'FixedText', nPosRes, y+25, 20, nHeight, Label = "", Align = 2) self.struct3_res = self._addWidget('struct3_res', 'FixedText', nPosRes, y+35, 20, nHeight, Label = "", Align = 2) # dialog height @@ -262,19 +262,20 @@ self.pbar.ProgressValueMax = 32 # time counter self.time_res = self._addWidget('time_res', 'FixedText', self.xDialog.Width-80, self.xDialog.Height-15, 20, nHeight, Label = "", Align = 2) # buttons - self.bdefault = self._addWidget('default', 'Button', 5, self.xDialog.Height-19, 15, 15, Label = self.dUI.get('default', "#err"), \ - HelpText = self.dUI.get('default_help', "#err"), FontDescriptor = xFD2, TextColor = 0x444444) - #self.bsel = self._addWidget('bsel', 'CheckBox', x2, self.xDialog.Height-40, nWidth-55, nHeight, Label = self.dUI.get('bsel', "#err")) - self.bapply = self._addWidget('apply', 'Button', self.xDialog.Width-55, self.xDialog.Height-19, 50, 15, Label = self.dUI.get('apply', "#err"), \ + self.bdefault = self._addWidget('default', 'Button', 5, self.xDialog.Height-19, 15, 15, Label = ui.get('default'), \ + HelpText = ui.get('default_help'), FontDescriptor = xFD2, TextColor = 0x444444) + #self.bsel = self._addWidget('bsel', 'CheckBox', x2, self.xDialog.Height-40, nWidth-55, nHeight, Label = ui.get('bsel')) + self.bapply = self._addWidget('apply', 'Button', self.xDialog.Width-55, self.xDialog.Height-19, 50, 15, Label = ui.get('apply'), \ FontDescriptor = xFD2, TextColor = 0x004400) - self.binfo = self._addWidget('info', 'Button', self.xDialog.Width-15, 0, 10, 9, Label = self.dUI.get('info', "#err"), \ - HelpText = self.dUI.get('infotitle', "#err"), FontDescriptor = xFDsmall, TextColor = 0x444444) + self.binfo = self._addWidget('info', 'Button', self.xDialog.Width-15, 0, 10, 9, Label = ui.get('info'), \ + HelpText = ui.get('infotitle'), FontDescriptor = xFDsmall, TextColor = 0x444444) # load configuration + self.dTransRules = {} self.xGLOptionNode = helpers.getConfigSetting("/org.openoffice.Lightproof_${implname}/Other/", True) self._loadConfig("${lang}") ## container self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx) @@ -365,27 +366,33 @@ xDialog.run(self.sLang) elif xActionEvent.ActionCommand == 'Info': xDesktop = self.xSvMgr.createInstanceWithContext('com.sun.star.frame.Desktop', self.ctx) xDoc = xDesktop.getCurrentComponent() xWindow = xDoc.CurrentController.Frame.ContainerWindow - MessageBox (xWindow, self.dUI.get('infomsg', "#err"), self.dUI.get('infotitle', "#err")) + MessageBox(xWindow, ui.get('infomsg'), ui.get('infotitle')) else: print("Wrong command: " + xActionEvent.ActionCommand) except: traceback.print_exc() def _loadConfig (self, sLang): try: dOpt = tf_options.dDefaultOpt.copy() xChild = self.xGLOptionNode.getByName("o_"+sLang) + # selected options sTFOptionsJSON = xChild.getPropertyValue("tf_options") if sTFOptionsJSON: dOpt.update(json.loads(sTFOptionsJSON)) self._setConfig(dOpt) + # transformation rules + sTFEditorOptions = xChild.getPropertyValue("tfe_rules") + if sTFEditorOptions: + self.dTransRules = json.loads(sTFEditorOptions) except: traceback.print_exc() self._setConfig(tf_options.dDefaultOpt) + self.misccustom.State = False def _setConfig (self, dOpt): for sKey, val in dOpt.items(): try: w = getattr(self, sKey) @@ -419,15 +426,15 @@ w.Enabled = wGroupCheckbox.State def _setApplyButtonLabel (self): if self.ssp.State or self.space.State or self.nbsp.State or self.delete.State or self.typo.State or self.misc.State or self.struct.State: self.bClose = False - self.bapply.Label = self.dUI.get('apply', "#err") + self.bapply.Label = ui.get('apply') self.bapply.TextColor = 0x004400 else: self.bClose = True - self.bapply.Label = self.dUI.get('close', "#err") + self.bapply.Label = ui.get('close') self.bapply.TextColor = 0x440000 self.xContainer.setVisible(True) def _replaceAll (self, xElem): try: @@ -674,11 +681,11 @@ if self.misc5c.State: n += self._replaceList(xElem, "misc5c") self.misc5_res.Label = str(n) self.pbar.ProgressValue += 1 if self.misccustom.State: - n = self._replaceList(xElem, "misccustom") + n = self._replaceCustom(xElem) self.misccustom_res.Label = str(n) self.pbar.ProgressValue += 1 self.misc.State = False self._switchCheckBox(self.misc) self.pbar.ProgressValue = self.pbar.ProgressValueMax @@ -703,10 +710,21 @@ n += self._replaceText(xElem, sPattern, sRepl, bRegex, bCaseSensitive) except: print("# Error with "+sList) traceback.print_exc() return n + + def _replaceCustom (self, xElem): + n = 0 + try: + for sRuleName, dRule in sorted(self.dTransRules.items()): + #print(sRuleName, dRule["sPattern"], dRule["sRepl"], dRule["bRegex"], dRule["bCaseSens"]) + n += self._replaceText(xElem, dRule["sPattern"], dRule["sRepl"], dRule["bRegex"], dRule["bCaseSens"]) + except: + print("# Error with custom transformation rules") + traceback.print_exc() + return n def _replaceText (self, xElem, sPattern, sRepl, bRegex, bCaseSensitive=False): try: xRD = xElem.createReplaceDescriptor() xRD.SearchString = sPattern Index: gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py +++ gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py @@ -128,58 +128,57 @@ # Add self._addWidget("new_entry", 'FixedLine', nX, nY1, nWidth, nHeight, Label = ui.get("new_entry"), FontDescriptor = xFDTitle) self._addWidget('newnamelbl', 'FixedText', nX, nY1+10, 60, nHeight, Label = ui.get("name")) - self._addWidget('newreplacelbl', 'FixedText', nX+65, nY1+10, 130, nHeight, Label = ui.get("replace")) - self._addWidget('newbylbl', 'FixedText', nX+200, nY1+10, 100, nHeight, Label = ui.get("by")) - - self.xNewname = self._addWidget('newname', 'Edit', nX, nY1+20, 60, 10, FontDescriptor = xFDMono) - self.xNewreplace = self._addWidget('newreplace', 'Edit', nX+65, nY1+20, 130, 10, FontDescriptor = xFDMono) - self.xNewby = self._addWidget('newby', 'Edit', nX+200, nY1+20, 100, 10, FontDescriptor = xFDMono) - self.xNewregex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help")) - self.xNewcasesens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True) + self._addWidget('newreplacelbl', 'FixedText', nX+65, nY1+10, 130, nHeight, Label = ui.get("pattern")) + self._addWidget('newbylbl', 'FixedText', nX+200, nY1+10, 100, nHeight, Label = ui.get("repl")) + + self.xNewName = self._addWidget('newname', 'Edit', nX, nY1+20, 60, 10, FontDescriptor = xFDMono) + self.xNewPattern = self._addWidget('newreplace', 'Edit', nX+65, nY1+20, 130, 10, FontDescriptor = xFDMono) + self.xNewRepl = self._addWidget('newby', 'Edit', nX+200, nY1+20, 100, 10, FontDescriptor = xFDMono) + self.xNewRegex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help")) + self.xNewCaseSens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True) self._addWidget('add', 'Button', self.xDialog.Width-50, nY1+31, 40, 11, Label = ui.get('add')) lColumns = [ {"Title": ui.get("name"), "ColumnWidth": 80}, - {"Title": ui.get("replace"), "ColumnWidth": 140}, - {"Title": ui.get("by"), "ColumnWidth": 140}, + {"Title": ui.get("pattern"), "ColumnWidth": 140}, + {"Title": ui.get("repl"), "ColumnWidth": 140}, {"Title": ui.get("regex"), "ColumnWidth": 60}, {"Title": ui.get("casesens"), "ColumnWidth": 60}, ] self.xGridModel = self._addGrid("list_grid", nX, nY1+45, nWidth, 150, lColumns) # Modify self._addWidget("edit_entry", 'FixedLine', nX, nY2, nWidth, nHeight, Label = ui.get("edit_entry"), FontDescriptor = xFDTitle) - self._addWidget('editnamelbl', 'FixedText', nX, nY2+10, 60, nHeight, Label = ui.get("name")) - self._addWidget('editreplacelbl', 'FixedText', nX+65, nY2+10, 130, nHeight, Label = ui.get("replace")) - self._addWidget('editbylbl', 'FixedText', nX+200, nY2+10, 100, nHeight, Label = ui.get("by")) - - self.xEditname = self._addWidget('editname', 'Edit', nX, nY2+20, 60, 10, FontDescriptor = xFDMono, Enabled = False) - self.xEditreplace = self._addWidget('editreplace', 'Edit', nX+65, nY2+20, 130, 10, FontDescriptor = xFDMono, Enabled = False) - self.xEditby = self._addWidget('editby', 'Edit', nX+200, nY2+20, 100, 10, FontDescriptor = xFDMono, Enabled = False) - self.xEditregex = self._addWidget('editregex', 'CheckBox', nX+305, nY2+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help"), Enabled = False) - self.xEditcasesens = self._addWidget('editcasesens', 'CheckBox', nX+340, nY2+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), Enabled = False) + self._addWidget('editreplacelbl', 'FixedText', nX+65, nY2+10, 130, nHeight, Label = ui.get("pattern")) + self._addWidget('editbylbl', 'FixedText', nX+200, nY2+10, 100, nHeight, Label = ui.get("repl")) + + self.xEditName = self._addWidget('editname', 'Edit', nX, nY2+20, 60, 10, FontDescriptor = xFDMono, Enabled = False) + self.xEditPattern = self._addWidget('editreplace', 'Edit', nX+65, nY2+20, 130, 10, FontDescriptor = xFDMono, Enabled = False) + self.xEditRepl = self._addWidget('editby', 'Edit', nX+200, nY2+20, 100, 10, FontDescriptor = xFDMono, Enabled = False) + self.xEditRegex = self._addWidget('editregex', 'CheckBox', nX+305, nY2+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help"), Enabled = False) + self.xEditCaseSens = self._addWidget('editcasesens', 'CheckBox', nX+340, nY2+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), Enabled = False) self.xDeleteButton = self._addWidget('delete', 'Button', nX, nY2+31, 40, 11, Label = ui.get('delete'), TextColor = 0xAA0000, Enabled = False) self.xApplyButton = self._addWidget('apply', 'Button', nX + (self.xDialog.Width/2)-20, nY2+31, 40, 11, Label = ui.get('apply'), HelpText="apply_help", TextColor = 0x0000AA, Enabled = False) + self.xApplyRes = self._addWidget('apply_res', 'FixedText', nX + (self.xDialog.Width/2)+30, nY2+33, 60, 10, Label = "", Align = 2, Enabled = False) self.xModifyButton = self._addWidget('modify', 'Button', self.xDialog.Width-50, nY2+31, 40, 11, Label = ui.get('modify'), TextColor = 0x00AA00, Enabled = False) # import, export, save, close - self._addWidget("buttons_line", 'FixedLine', nX, self.xDialog.Height-35, nWidth, nHeight) - self._addWidget('import', 'Button', nX, self.xDialog.Height-25, 50, 14, Label = ui.get('import'), FontDescriptor = xFDTitle, TextColor = 0x0000AA) - self._addWidget('export', 'Button', nX+60, self.xDialog.Height-25, 50, 14, Label = ui.get('export'), FontDescriptor = xFDTitle, TextColor = 0x00AA00) - self._addWidget('save', 'Button', self.xDialog.Width-120, self.xDialog.Height-25, 50, 14, Label = ui.get('save'), FontDescriptor = xFDTitle, TextColor = 0x00AA00) - self._addWidget('close', 'Button', self.xDialog.Width-60, self.xDialog.Height-25, 50, 14, Label = ui.get('close'), FontDescriptor = xFDTitle, TextColor = 0xAA0000) + self._addWidget("buttons_line", 'FixedLine', nX, self.xDialog.Height-30, nWidth, nHeight) + self._addWidget('import', 'Button', nX, self.xDialog.Height-20, 50, 14, Label = ui.get('import'), FontDescriptor = xFDTitle, TextColor = 0x0000AA) + self._addWidget('export', 'Button', nX+55, self.xDialog.Height-20, 50, 14, Label = ui.get('export'), FontDescriptor = xFDTitle, TextColor = 0x00AA00) + self._addWidget('delete_all', 'Button', nX + (self.xDialog.Width/2)-35, self.xDialog.Height-20, 70, 14, Label = ui.get('delete_all'), FontDescriptor = xFDTitle, TextColor = 0xAA0000) + self._addWidget('save_and_close', 'Button', self.xDialog.Width-110, self.xDialog.Height-20, 100, 14, Label = ui.get('save_and_close'), FontDescriptor = xFDTitle, TextColor = 0x00AA00) # data self.dRules = {} self.iSelectedRow = -1 - # load configuration self.xGLOptionNode = helpers.getConfigSetting("/org.openoffice.Lightproof_${implname}/Other/", True) self.loadRules() @@ -190,20 +189,22 @@ self.xGridControl.addSelectionListener(self) self.xContainer.getControl('add').addActionListener(self) self.xContainer.getControl('add').setActionCommand('Add') self.xContainer.getControl('delete').addActionListener(self) self.xContainer.getControl('delete').setActionCommand('Delete') + self.xContainer.getControl('apply').addActionListener(self) + self.xContainer.getControl('apply').setActionCommand('Apply') self.xContainer.getControl('modify').addActionListener(self) self.xContainer.getControl('modify').setActionCommand('Modify') self.xContainer.getControl('import').addActionListener(self) self.xContainer.getControl('import').setActionCommand('Import') self.xContainer.getControl('export').addActionListener(self) self.xContainer.getControl('export').setActionCommand('Export') - self.xContainer.getControl('save').addActionListener(self) - self.xContainer.getControl('save').setActionCommand('Save') - self.xContainer.getControl('close').addActionListener(self) - self.xContainer.getControl('close').setActionCommand('Close') + self.xContainer.getControl('delete_all').addActionListener(self) + self.xContainer.getControl('delete_all').setActionCommand('DeleteAll') + self.xContainer.getControl('save_and_close').addActionListener(self) + self.xContainer.getControl('save_and_close').setActionCommand('SaveAndClose') self.xContainer.setVisible(False) # True for non modal dialog xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx) self.xContainer.createPeer(xToolkit, None) self.xContainer.execute() @@ -215,18 +216,19 @@ elif xActionEvent.ActionCommand == "Delete": self.deleteRule() elif xActionEvent.ActionCommand == "Modify": self.modifyRule() elif xActionEvent.ActionCommand == "Apply": - self.apply() - elif xActionEvent.ActionCommand == "Save": - self.saveRules() + self.applyRule() elif xActionEvent.ActionCommand == "Import": self.importRules() elif xActionEvent.ActionCommand == "Export": self.exportRules() - elif xActionEvent.ActionCommand == "Close": + elif xActionEvent.ActionCommand == "DeleteAll": + self.deleteAll() + elif xActionEvent.ActionCommand == "SaveAndClose": + self.saveRules() self.xContainer.endExecute() # Modal dialog except: traceback.print_exc() # XGridSelectionListener @@ -233,106 +235,110 @@ def selectionChanged (self, xGridSelectionEvent): try: aRows = self.xGridControl.getSelectedRows() if aRows and len(aRows) == 1: self.iSelectedRow = aRows[0] - self.sSelectedRuleName, sReplace, sBy, sRegex, sCaseSens = self.xGridModel.GridDataModel.getRowData(self.iSelectedRow) + self.sSelectedRuleName, sPattern, sRepl, sRegex, sCaseSens = self.xGridModel.GridDataModel.getRowData(self.iSelectedRow) # fill fields - self.xEditname.Text = self.sSelectedRuleName - self.xEditreplace.Text = sReplace - self.xEditby.Text = sBy - self.xEditregex.State = sRegex == "True" - self.xEditcasesens.State = sCaseSens == "True" + self.xEditName.Text = self.sSelectedRuleName + self.xEditPattern.Text = sPattern + self.xEditRepl.Text = sRepl + self.xEditRegex.State = sRegex == "True" + self.xEditCaseSens.State = sCaseSens == "True" # enable widgets - self.xEditname.Enabled = True - self.xEditreplace.Enabled = True - self.xEditby.Enabled = True - self.xEditregex.Enabled = True - self.xEditcasesens.Enabled = True + self.xEditName.Enabled = True + self.xEditPattern.Enabled = True + self.xEditRepl.Enabled = True + self.xEditRegex.Enabled = True + self.xEditCaseSens.Enabled = True self.xDeleteButton.Enabled = True self.xApplyButton.Enabled = True self.xModifyButton.Enabled = True + self.xApplyRes.Enabled = True + self.xApplyRes.Label = "" except: self._clearEditFields() traceback.print_exc() # Code def _clearAddFields (self): - self.xNewname.Text = "" - self.xNewreplace.Text = "" - self.xNewby.Text = "" - self.xNewregex.State = False - self.xNewcasesens.State = True + self.xNewName.Text = "" + self.xNewPattern.Text = "" + self.xNewRepl.Text = "" + self.xNewRegex.State = False + self.xNewCaseSens.State = True def _clearEditFields (self): - self.xEditname.Text = "" - self.xEditreplace.Text = "" - self.xEditby.Text = "" - self.xEditregex.State = False - self.xEditcasesens.State = True + self.xEditName.Text = "" + self.xEditPattern.Text = "" + self.xEditRepl.Text = "" + self.xEditRegex.State = False + self.xEditCaseSens.State = True # disable widgets - self.xEditname.Enabled = False - self.xEditreplace.Enabled = False - self.xEditby.Enabled = False - self.xEditregex.Enabled = False - self.xEditcasesens.Enabled = False + self.xEditName.Enabled = False + self.xEditPattern.Enabled = False + self.xEditRepl.Enabled = False + self.xEditRegex.Enabled = False + self.xEditCaseSens.Enabled = False self.xDeleteButton.Enabled = False self.xApplyButton.Enabled = False self.xModifyButton.Enabled = False + self.xApplyRes.Enabled = False + self.xApplyRes.Label = "" def addRule (self): - if not self._checkRuleName(self.xNewname.Text): + if not self._checkRuleName(self.xNewName.Text): MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX) return - if not self.xNewname.Text or not self.xNewreplace.Text: + if not self.xNewName.Text or not self.xNewPattern.Text: MessageBox(self.xDocument, ui.get("name_and_replace_error"), ui.get("name_and_replace_error_title"), ERRORBOX) return - sRuleName = self.xNewname.Text + sRuleName = self.xNewName.Text if sRuleName in self.dRules: MessageBox(self.xDocument, ui.get('add_name_error'), ui.get("add_name_error_title"), ERRORBOX) return self.dRules[sRuleName] = { - "sReplace": self.xNewreplace.Text, - "sBy": self.xNewby.Text, - "bRegex": self.xNewregex.State == 1, - "bCaseSens": self.xNewcasesens.State == 1 + "sPattern": self.xNewPattern.Text, + "sRepl": self.xNewRepl.Text, + "bRegex": self.xNewRegex.State == 1, + "bCaseSens": self.xNewCaseSens.State == 1 } xGridDataModel = self.xGridModel.GridDataModel xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName)) self._clearAddFields() def _getValuesForRow (self, sRuleName): - return (sRuleName, self.dRules[sRuleName]["sReplace"], self.dRules[sRuleName]["sBy"], str(self.dRules[sRuleName]["bRegex"]), str(self.dRules[sRuleName]["bCaseSens"])) + return (sRuleName, self.dRules[sRuleName]["sPattern"], self.dRules[sRuleName]["sRepl"], str(self.dRules[sRuleName]["bRegex"]), str(self.dRules[sRuleName]["bCaseSens"])) def _checkRuleName (self, sRuleName): return re.search(r"^\w[\w_#.,;!?-]*$", sRuleName) def modifyRule (self): - if not self._checkRuleName(self.xEditname.Text): + if not self._checkRuleName(self.xEditName.Text): MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX) return - sRuleName = self.xEditname.Text - if self.iSelectedRow < 0 or not sRuleName or not self.xEditreplace.Text: + sRuleName = self.xEditName.Text + if self.iSelectedRow < 0 or not sRuleName or not self.xEditPattern.Text: MessageBox(self.xDocument, ui.get("name_and_replace_error"), ui.get("name_and_replace_error_title"), ERRORBOX) return if sRuleName != self.sSelectedRuleName and sRuleName in self.dRules: MessageBox(self.xDocument, ui.get("modify_name_error"), ui.get("modify_name_error_title"), ERRORBOX) return try: self.dRules[sRuleName] = { - "sReplace": self.xEditreplace.Text, - "sBy": self.xEditby.Text, - "bRegex": self.xEditregex.State == 1, - "bCaseSens": self.xEditcasesens.State == 1 + "sPattern": self.xEditPattern.Text, + "sRepl": self.xEditRepl.Text, + "bRegex": self.xEditRegex.State == 1, + "bCaseSens": self.xEditCaseSens.State == 1 } aColumns = (0, 1, 2, 3, 4) self.xGridModel.GridDataModel.updateRowData(aColumns, self.iSelectedRow, self._getValuesForRow(sRuleName)) except: traceback.print_exc() def deleteRule (self): - if self.sSelectedRuleName != self.xEditname.Text: + if self.sSelectedRuleName != self.xEditName.Text: MessageBox(self.xDocument, ui.get('delete_name_error'), ui.get("delete_name_error_title"), ERRORBOX) return sRuleName = self.sSelectedRuleName if not sRuleName or sRuleName not in self.dRules: return @@ -342,13 +348,28 @@ self.iSelectedRow = -1 del self.dRules[sRuleName] except: traceback.print_exc() + def deleteAll (self): + self.dRules.clear() + self.xGridModel.GridDataModel.removeAllRows() + @_waitPointer - def apply (self): - pass + def applyRule (self): + if self.xEditPattern.Text == "": + return + try: + xRD = self.xDocument.createReplaceDescriptor() + xRD.SearchString = self.xEditPattern.Text + xRD.ReplaceString = self.xEditRepl.Text + xRD.SearchRegularExpression = self.xEditRegex.State + xRD.SearchCaseSensitive = self.xEditCaseSens.State + n = self.xDocument.replaceAll(xRD) + self.xApplyRes.Label = str(n) + " " + ui.get("modif") + except: + traceback.print_exc() def loadRules (self): try: xChild = self.xGLOptionNode.getByName("o_${lang}") sTFEditorOptions = xChild.getPropertyValue("tfe_rules") Index: gc_lang/fr/oxt/TextFormatter/tf_strings.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/tf_strings.py +++ gc_lang/fr/oxt/TextFormatter/tf_strings.py @@ -1,10 +1,23 @@ +# strings for text formatter + + +sUI = "fr" + -def getUI (sLang): +def selectLang (sLang): + global sUI if sLang in dStrings: - return dStrings[sLang] - return dStrings["fr"] + sUI = sLang + + +def get (sMsgCode): + try: + return dStrings[sUI].get(sMsgCode, sMsgCode) + except: + return "#error" + dStrings = { "fr": { "title": "Grammalecte · Formateur de texte [Français]", Index: gc_lang/fr/oxt/TextFormatter/tfe_strings.py ================================================================== --- gc_lang/fr/oxt/TextFormatter/tfe_strings.py +++ gc_lang/fr/oxt/TextFormatter/tfe_strings.py @@ -20,30 +20,31 @@ dStrings = { "fr": { "title": "Grammalecte · Éditeur des transformations personnalisées", "name": "Nom de la règle", - "replace": "Remplacer", - "by": "par", + "pattern": "Motif de remplacement", + "repl": "par", "regex": "Regex", "regex_help": "Une expression régulière est une forme de syntaxe décrivant un motif de recherche de caractères", "casesens": "Casse rigide", "casesens_help": "La casse des caractères sera respectée telle quelle.", "new_entry": "Nouvelle entrée", - "edit_entry": "Édition de l’entrée sélectionnée", + "edit_entry": "Entrée sélectionnée", "add": "Ajouter", "delete": "Supprimer", "modify": "Modifier", "apply": "Appliquer", "apply_help": "Appliquer cette règle sur le texte", + "modif": "modifications", - "save": "Enregistrer", "import": "Importer", "export": "Exporter", - "close": "Fermer", + "delete_all": "Tout supprimer", + "save_and_close": "Enregistrer et fermer", "name_error": "Pour le nom des règles, utilisez uniquement les lettres, les nombres et les caractères parmi ‹_-#.,;!?›.", "name_error_title": "Le nom de la règle n’est pas conforme.", "name_and_replace_error": "Ni le nom de la règle, ni ce qui doit être remplacé ne peut être vide. Veuillez remplir les champs requis.", @@ -62,35 +63,35 @@ "import_title": "Importation d’un fichier de règles de transformation", "error": "Erreur", "file_not_found": "Fichier introuvable : ", }, - "en": { "title": "Grammalecte · Editor for custom transformations", "name": "Rule name", - "replace": "Replace", - "by": "by", + "pattern": "Replacement pattern", + "repl": "by", "regex": "Regex", "regex_help": "A regular expression is a kind of syntax describing a search pattern of characters", "casesens": "Case sensitivity", "casesens_help": "Characters case will be treated as written.", "new_entry": "New entry", - "edit_entry": "Edition for selected entry", + "edit_entry": "Selected entry", "add": "Add", "delete": "Delete", "modify": "Modify", "apply": "Apply", "apply_help": "Apply this rule on the text", + "modif": "modifications", - "save": "Save", "import": "Import", "export": "Export", - "close": "Close", + "delete_all": "Delete all", + "save_and_close": "Save and close", "name_error": "For rules names, only use letters, numbers et characters among ‹_-#.,;!?›", "name_error_title": "Le nom de la règle n’est pas conforme.", "name_and_replace_error": "Neither the rule name, neither what has to be replaced can be empty. Please, fill the required fields.",