Grammalecte  Check-in [bc1a6556d3]

Overview
Comment:[fr] Extension dictionnaires: mise à jour du sélecteur
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fr
Files: files | file ages | folders
SHA3-256: bc1a6556d3c53cd747266fba5e749729db29e99e6bbf46bb6e4cea978b5b67b1
User & Date: olr on 2018-10-30 00:22:24
Other Links: manifest | tags
Context
2018-11-01
08:52
[fr] nr: forme impérative avec trait d’union, nr: jour + matin/soir check-in: e65d9ee9d9 user: olr tags: trunk, fr
2018-10-30
00:22
[fr] Extension dictionnaires: mise à jour du sélecteur check-in: bc1a6556d3 user: olr tags: trunk, fr
2018-10-29
09:52
[fr] mise à jour du dictionnaire (WTF? tabulations devenues des espaces?!) check-in: c7d498227a user: olr tags: trunk, fr
Changes

Modified gc_lang/fr/dictionnaire/_templates/ooo/DictionarySwitcher.py from [9680ccdc4b] to [f27daf2fda].

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
        # It is assumed that those who need to use the French dictionaries understand French and may not understand English.
        xSettings = getConfigSetting("/org.openoffice.Setup/L10N", False)
        sLocale = xSettings.getByName("ooLocale")  # Note: look at ooSetupSystemLocale value ?
        if sLocale[0:2] in ds_strings.dStrings:
            self.dUI = ds_strings.dStrings[sLocale[0:2]]
        else:
            self.dUI = ds_strings.dStrings["fr"]
        
    def addWidget (self, name, wtype, x, y, w, h, **kwargs):
        xWidget = self.dialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
        xWidget.Name = name
        xWidget.PositionX = x
        xWidget.PositionY = y
        xWidget.Width = w
        xWidget.Height = h
        for k, w in kwargs.items():
            setattr(xWidget, k, w)
        self.dialog.insertByName(name, xWidget)
        return xWidget

    def run (self):
        # what is the current dictionary
        xSettings = getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", False)
        xLocations = xSettings.getByName("Locations")
        m = re.search(r"fr-(\w*)\.(?:dic|aff)", xLocations[0])
        self.sCurrentDic = m.group(1)
        
        # dialog
        self.dialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
        self.dialog.Width = 200
        self.dialog.Height = 290
        self.dialog.Title = self.dUI.get('title', "#title#")
        xWindowSize = getWindowSize()
        self.dialog.PositionX = int((xWindowSize.Width / 2) - (self.dialog.Width / 2))
        self.dialog.PositionY = int((xWindowSize.Height / 2) - (self.dialog.Height / 2))
        
        # xWidgets
        padding = 10
        hspace = 60
        posY1 = 20; posY2 = posY1 + hspace; posY3 = posY2 + hspace; posY4 = posY3 + hspace; posY5 = posY4 + hspace + 10;
        nLblWidth = 170
        nLblHeight = 20
        nDescWidth = 170
        nDescHeight = 40
        
        xFD1 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFD1.Height = 12
        xFD1.Name = "Verdana"
        
        xFD2 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFD2.Height = 11
        xFD2.Name = "Verdana"
        
        xFD3 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFD3.Height = 10
        xFD3.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
        xFD3.Name = "Verdana"
        
        gbm = self.addWidget('groupbox', 'GroupBox', 5, 5, 190, 260, Label = self.dUI.get('choose', "#choose#"), FontDescriptor = xFD1, FontRelief = 1, TextColor = 0xAA2200)
        
        # Note: the only way to group RadioButtons is to create them successively
        rbm_m = self.addWidget('rb-moderne', 'RadioButton', padding, posY1, nLblWidth, nLblHeight, Label = self.dUI.get('moderne', "#moderne#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        self.xRB_m = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        self.xRB_m.setModel(rbm_m)
        rbm_c = self.addWidget('rb-classique', 'RadioButton', padding, posY2, nLblWidth, nLblHeight, Label = self.dUI.get('classique', "#classique#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        self.xRB_c = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        self.xRB_c.setModel(rbm_c)
        rbm_r = self.addWidget('rb-reforme1990', 'RadioButton', padding, posY3, nLblWidth, nLblHeight, Label = self.dUI.get('reforme1990', "#reforme1990#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        self.xRB_r = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        self.xRB_r.setModel(rbm_r)
        rbm_t = self.addWidget('rb-toutesvariantes', 'RadioButton', padding, posY4, nLblWidth, nLblHeight, Label = self.dUI.get('toutesvariantes', "#toutesvariantes#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        self.xRB_t = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        self.xRB_t.setModel(rbm_t)
        
        label_m = self.addWidget('label_m', 'FixedText', 20, posY1+10, nDescWidth, nDescHeight, Label = self.dUI.get('descModern', "#descModern#"), MultiLine = True)
        label_c = self.addWidget('label_c', 'FixedText', 20, posY2+10, nDescWidth, nDescHeight, Label = self.dUI.get('descClassic', "#descClassic#"), MultiLine = True)
        label_r = self.addWidget('label_r', 'FixedText', 20, posY3+10, nDescWidth, nDescHeight, Label = self.dUI.get('descReform', "#descReform#"), MultiLine = True)
        label_t = self.addWidget('label_t', 'FixedText', 20, posY4+10, nDescWidth, nDescHeight, Label = self.dUI.get('descAllvar', "#descAllvar#"), MultiLine = True)
        
        if self.sCurrentDic:
            self.setRadioButton(self.sCurrentDic)
            sMsgLabel = self.dUI.get('restart', "#restart#")
            bButtonActive = True
        else:
            sMsgLabel = self.dUI.get('error', "#error#")
            bButtonActive = False
        
        label_info = self.addWidget('label_info', 'FixedText', 10, posY4+50, 180, 10, Label = sMsgLabel, TextColor = 0xAA2200, MultiLine = True)
        button = self.addWidget('select', 'Button', padding+40, posY5, 100, 14, Label = self.dUI.get('select', "#select#"), FontDescriptor = xFD3, TextColor = 0x004400, Enabled = bButtonActive)
        
        # container
        self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
        self.xContainer.setModel(self.dialog)
        self.xContainer.getControl('select').addActionListener(self)
        self.xContainer.setVisible(False)
        toolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
        self.xContainer.createPeer(toolkit, None)
        self.xContainer.execute()
    
    def setRadioButton (self, sDic):
        if sDic == 'moderne':
            self.xRB_m.setState(True)

        elif sDic == 'classique':
            self.xRB_c.setState(True)
        elif sDic == 'reforme1990':
            self.xRB_r.setState(True)
        elif sDic == 'toutesvariantes':
            self.xRB_t.setState(True)
        else:
            pass
        
    def actionPerformed (self, actionEvent):
        try:
            if self.xRB_m.getState():
                self.sSelectedDic = 'moderne'
            elif self.xRB_c.getState():
                self.sSelectedDic = 'classique'
            elif self.xRB_r.getState():
                self.sSelectedDic = 'reforme1990'
            elif self.xRB_t.getState():
                self.sSelectedDic = 'toutesvariantes'
            else:
                # no dictionary selected
                pass
            self.xContainer.endExecute()
        except:
            traceback.print_exc()
    
    def trigger (self, args):
        try:
            dialog = FrenchDictionarySwitcher(self.ctx)
            dialog.run()
            if dialog.sSelectedDic and dialog.sSelectedDic != dialog.sCurrentDic :
                # Modify the registry
                xSettings = getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", True)







|


















|



|




|



|




|



|



|




|
|
|

|
|
|
|


|


|


|
|
|
|
|
|







|
|
|
|








|


|
>








|


|
|
|











|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
        # It is assumed that those who need to use the French dictionaries understand French and may not understand English.
        xSettings = getConfigSetting("/org.openoffice.Setup/L10N", False)
        sLocale = xSettings.getByName("ooLocale")  # Note: look at ooSetupSystemLocale value ?
        if sLocale[0:2] in ds_strings.dStrings:
            self.dUI = ds_strings.dStrings[sLocale[0:2]]
        else:
            self.dUI = ds_strings.dStrings["fr"]

    def addWidget (self, name, wtype, x, y, w, h, **kwargs):
        xWidget = self.dialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
        xWidget.Name = name
        xWidget.PositionX = x
        xWidget.PositionY = y
        xWidget.Width = w
        xWidget.Height = h
        for k, w in kwargs.items():
            setattr(xWidget, k, w)
        self.dialog.insertByName(name, xWidget)
        return xWidget

    def run (self):
        # what is the current dictionary
        xSettings = getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", False)
        xLocations = xSettings.getByName("Locations")
        m = re.search(r"fr-(\w*)\.(?:dic|aff)", xLocations[0])
        self.sCurrentDic = m.group(1)

        # dialog
        self.dialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
        self.dialog.Width = 200
        self.dialog.Height = 230
        self.dialog.Title = self.dUI.get('title', "#title#")
        xWindowSize = getWindowSize()
        self.dialog.PositionX = int((xWindowSize.Width / 2) - (self.dialog.Width / 2))
        self.dialog.PositionY = int((xWindowSize.Height / 2) - (self.dialog.Height / 2))

        # xWidgets
        padding = 10
        hspace = 60
        posY1 = 20; posY2 = posY1 + hspace; posY3 = posY2 + hspace; posY4 = posY3 + hspace + 10
        nLblWidth = 170
        nLblHeight = 20
        nDescWidth = 170
        nDescHeight = 40

        xFD1 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFD1.Height = 12
        xFD1.Name = "Verdana"

        xFD2 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFD2.Height = 11
        xFD2.Name = "Verdana"

        xFD3 = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFD3.Height = 10
        xFD3.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
        xFD3.Name = "Verdana"

        gbm = self.addWidget('groupbox', 'GroupBox', 5, 5, 190, 200, Label = self.dUI.get('choose', "#choose#"), FontDescriptor = xFD1, FontRelief = 1, TextColor = 0xAA2200)

        # Note: the only way to group RadioButtons is to create them successively
        #rbm_m = self.addWidget('rb-moderne', 'RadioButton', padding, posY1, nLblWidth, nLblHeight, Label = self.dUI.get('moderne', "#moderne#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        #self.xRB_m = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        #self.xRB_m.setModel(rbm_m)
        rbm_c = self.addWidget('rb-classique', 'RadioButton', padding, posY1, nLblWidth, nLblHeight, Label = self.dUI.get('classique', "#classique#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        self.xRB_c = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        self.xRB_c.setModel(rbm_c)
        rbm_r = self.addWidget('rb-reforme1990', 'RadioButton', padding, posY2, nLblWidth, nLblHeight, Label = self.dUI.get('reforme1990', "#reforme1990#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        self.xRB_r = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        self.xRB_r.setModel(rbm_r)
        rbm_t = self.addWidget('rb-toutesvariantes', 'RadioButton', padding, posY3, nLblWidth, nLblHeight, Label = self.dUI.get('toutesvariantes', "#toutesvariantes#"), FontDescriptor = xFD2, FontRelief = 1, TextColor = 0x0022AA)
        self.xRB_t = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlRadioButton', self.ctx)
        self.xRB_t.setModel(rbm_t)

        #label_m = self.addWidget('label_m', 'FixedText', 20, posY1+10, nDescWidth, nDescHeight, Label = self.dUI.get('descModern', "#descModern#"), MultiLine = True)
        label_c = self.addWidget('label_c', 'FixedText', 20, posY1+10, nDescWidth, nDescHeight, Label = self.dUI.get('descClassic', "#descClassic#"), MultiLine = True)
        label_r = self.addWidget('label_r', 'FixedText', 20, posY2+10, nDescWidth, nDescHeight, Label = self.dUI.get('descReform', "#descReform#"), MultiLine = True)
        label_t = self.addWidget('label_t', 'FixedText', 20, posY3+10, nDescWidth, nDescHeight, Label = self.dUI.get('descAllvar', "#descAllvar#"), MultiLine = True)

        if self.sCurrentDic:
            self.setRadioButton(self.sCurrentDic)
            sMsgLabel = self.dUI.get('restart', "#restart#")
            bButtonActive = True
        else:
            sMsgLabel = self.dUI.get('error', "#error#")
            bButtonActive = False

        label_info = self.addWidget('label_info', 'FixedText', 10, posY3+50, 180, 10, Label = sMsgLabel, TextColor = 0xAA2200, MultiLine = True)
        button = self.addWidget('select', 'Button', padding+40, posY4, 100, 14, Label = self.dUI.get('select', "#select#"), FontDescriptor = xFD3, TextColor = 0x004400, Enabled = bButtonActive)

        # container
        self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
        self.xContainer.setModel(self.dialog)
        self.xContainer.getControl('select').addActionListener(self)
        self.xContainer.setVisible(False)
        toolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
        self.xContainer.createPeer(toolkit, None)
        self.xContainer.execute()

    def setRadioButton (self, sDic):
        if sDic == 'moderne':
            #self.xRB_m.setState(True)
            self.xRB_c.setState(True)
        elif sDic == 'classique':
            self.xRB_c.setState(True)
        elif sDic == 'reforme1990':
            self.xRB_r.setState(True)
        elif sDic == 'toutesvariantes':
            self.xRB_t.setState(True)
        else:
            pass

    def actionPerformed (self, actionEvent):
        try:
            #if self.xRB_m.getState():
            #    self.sSelectedDic = 'moderne'
            if self.xRB_c.getState():
                self.sSelectedDic = 'classique'
            elif self.xRB_r.getState():
                self.sSelectedDic = 'reforme1990'
            elif self.xRB_t.getState():
                self.sSelectedDic = 'toutesvariantes'
            else:
                # no dictionary selected
                pass
            self.xContainer.endExecute()
        except:
            traceback.print_exc()

    def trigger (self, args):
        try:
            dialog = FrenchDictionarySwitcher(self.ctx)
            dialog.run()
            if dialog.sSelectedDic and dialog.sSelectedDic != dialog.sCurrentDic :
                # Modify the registry
                xSettings = getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", True)

Modified gc_lang/fr/dictionnaire/_templates/ooo/ds_strings.py from [b148ee2b72] to [1b96bf685a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- encoding: UTF-8 -*-

dStrings = {
    "fr": {
            "title": u"Orthographe française",
            "choose": u"Choisissez un dictionnaire",
            "select": u"Utiliser ce dictionnaire",
            
            "moderne": u"“Moderne”",
            "classique": u"“Classique” (recommandé)",
            "reforme1990": u"“Réforme 1990”",
            "toutesvariantes": u"“Toutes variantes”",

            "descModern": u"Ce dictionnaire propose l’orthographe telle qu’elle est écrite aujourd’hui le plus couramment. Cest le dictionnaire recommandé si le français n’est pas votre langue maternelle ou si vous ne désirez qu’une seule graphie correcte par mot.",
            "descClassic": u"Il s’agit du dictionnaire “Moderne”, avec des graphies classiques en sus, certaines encore communément utilisées, d’autres désuètes. C’est le dictionnaire recommandé si le français est votre langue maternelle.",
            "descReform": u"Avec ce dictionnaire, seule l’orthographe réformée est reconnue. Attendu que bon nombre de graphies réformées sont considérées comme erronées par beaucoup, ce dictionnaire est déconseillé. Les graphies passées dans l’usage sont déjà incluses dans le dictionnaire “Moderne”.",
            "descAllvar": u"Ce dictionnaire contient les variantes graphiques, classiques, réformées, ainsi que d’autres plus rares encore. Ce dictionnaire est déconseillé à ceux qui ne connaissent pas très bien la langue française.",

            "restart": u"Le changement ne sera effectif qu’après le redémarrage du logiciel.",
            "error": u"Erreur : impossible de savoir quel dictionnaire est actif."
          },
    "en": {
            "title": u"French spelling",
            "choose": u"Choose a dictionary",
            "select": u"Use this dictionary",
            
            "moderne": u"“Modern”",
            "classique": u"“Classic” (recommended)",
            "reforme1990": u"“Reform 1990”",
            "toutesvariantes": u"“All variants”",
            
            "descModern": u"This dictionary offers the French spelling as it is written nowadays most often. This is the recommended dictionary if French is not your mother tongue or if you want only one correct spelling per word.",
            "descClassic": u"This is the “Modern” dictionary plus classical spellings, some of them still widely used, others obsolete. This is the recommended dictionary if French is your native language.",
            "descReform": u"With this dictionary, only the reformed spelling is recognized. As many of reformed spellings are considered erronous for many people, this dictionary is unadvised. Reformed spellings commonly used are already included in the “Modern” dictionary.",
            "descAllvar": u"This dictionary contains all spelling variants, classical and reformed, and some others even rarer. This dictionary is unadvised for those who doesn’t know very well the French language.",

            "restart": u"The modification will be effective only after restarting the software.",
            "error": u"Error: enable to retrieve information about the current dictionary."
          }
}









|
<




|
<
|
|








|
<



|
|
<
|
|







1
2
3
4
5
6
7
8

9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29

30
31
32
33
34
35
36
37
38
# -*- encoding: UTF-8 -*-

dStrings = {
    "fr": {
            "title": u"Orthographe française",
            "choose": u"Choisissez un dictionnaire",
            "select": u"Utiliser ce dictionnaire",


            "classique": u"“Classique” (recommandé)",
            "reforme1990": u"“Réforme 1990”",
            "toutesvariantes": u"“Toutes variantes”",

            "descClassic": u"Ce dictionnaire propose l’orthographe telle qu’elle est écrite aujourd’hui le plus couramment. Toutefois, ont été intégrées quelques graphies acceptées par la réforme principalement pour des raisons de cohérence. Il sagit de graphies rectifiant des erreurs ou des oublis dans les réformes précédentes.",

            "descReform": u"Avec ce dictionnaire, seule l’orthographe réformée est reconnue. Attendu que bon nombre de graphies réformées sont considérées comme erronées par beaucoup, ce dictionnaire est déconseillé. Les graphies passées dans l’usage sont déjà incluses dans le dictionnaire “Classique”.",
            "descAllvar": u"Ce dictionnaire contient les variantes graphiques classiques et “réformées. Ce dictionnaire est déconseillé à ceux qui ne connaissent pas très bien la langue française.",

            "restart": u"Le changement ne sera effectif qu’après le redémarrage du logiciel.",
            "error": u"Erreur : impossible de savoir quel dictionnaire est actif."
          },
    "en": {
            "title": u"French spelling",
            "choose": u"Choose a dictionary",
            "select": u"Use this dictionary",


            "classique": u"“Classic” (recommended)",
            "reforme1990": u"“Reform 1990”",
            "toutesvariantes": u"“All variants”",

            "descClassic": u"This dictionary offers the French spelling as it is written nowadays most commonly. However, some of the spellings accepted by the reform have been incorporated mainly for reasons of coherence. These are spellings that rectify errors or omissions in previous reforms.",

            "descReform": u"With this dictionary, only the reformed spelling is recognized. As many of reformed spellings are considered erronous by many people, this dictionary is unadvised. Reformed spellings commonly used are already included in the “Classic” dictionary.",
            "descAllvar": u"This dictionary contains all spelling variants, classical and reformed. This dictionary is unadvised for those who don’t know very well the French language.",

            "restart": u"The modification will be effective only after restarting the software.",
            "error": u"Error: enable to retrieve information about the current dictionary."
          }
}