14
14
# limitations under the License.
15
15
16
16
from os .path import abspath , dirname , join
17
-
17
+ import builtins
18
18
import wx
19
19
from wx import Colour
20
20
from wx .lib .masked import NumCtrl
31
31
except ImportError : # Pygments is not installed
32
32
robotframeworklexer = None
33
33
34
+ _ = wx .GetTranslation # To keep linter/code analyser happy
35
+ builtins .__dict__ ['_' ] = wx .GetTranslation
36
+
37
+
34
38
ID_SAVELOADSETTINGS = wx .NewIdRef ()
35
39
ID_LOAD = 5551
36
40
ID_SAVE = 5552
37
41
ID_CANCEL = - 1
38
- TEXT_BACKGROUND = 'Text background'
42
+ TEXT_BACKGROUND = _ ( 'Text background' )
39
43
LIGHT_GRAY = 'light gray'
40
44
FIXED_FONT = 'fixed font'
41
45
@@ -75,8 +79,8 @@ def __init__(self, settings, *args, **kwargs):
75
79
colors_sizer = self .create_colors_sizer ()
76
80
main_sizer = wx .FlexGridSizer (rows = 6 , cols = 1 , vgap = 10 , hgap = 10 )
77
81
buttons_sizer = wx .BoxSizer (orient = wx .HORIZONTAL )
78
- reset = wx .Button (self , wx .ID_ANY , 'Reset colors to default' )
79
- saveloadsettings = wx .Button (self , ID_SAVELOADSETTINGS , 'Save or Load settings' )
82
+ reset = wx .Button (self , wx .ID_ANY , _ ( 'Reset colors to default' ) )
83
+ saveloadsettings = wx .Button (self , ID_SAVELOADSETTINGS , _ ( 'Save or Load settings' ) )
80
84
main_sizer .Add (font_editor )
81
85
main_sizer .Add (colors_sizer )
82
86
buttons_sizer .Add (reset )
@@ -115,7 +119,7 @@ def _get_path():
115
119
116
120
def _create_font_editor (self ):
117
121
f = IntegerChoiceEditor (
118
- self ._settings , 'font size' , 'Font Size' ,
122
+ self ._settings , 'font size' , _ ( 'Font Size' ) ,
119
123
[str (i ) for i in range (8 , 16 )])
120
124
sizer = wx .FlexGridSizer (rows = 3 , cols = 2 , vgap = 10 , hgap = 30 )
121
125
l_size = f .label (self )
@@ -127,19 +131,19 @@ def _create_font_editor(self):
127
131
fixed_font = False
128
132
if 'zoom factor' in self ._settings :
129
133
z = SpinChoiceEditor (
130
- self ._settings , 'zoom factor' , 'Zoom Factor' , (- 10 , 20 ))
134
+ self ._settings , 'zoom factor' , _ ( 'Zoom Factor' ) , (- 10 , 20 ))
131
135
l_zoom = z .label (self )
132
136
if IS_WINDOWS :
133
137
set_colors (l_zoom , background_color , foreground_color )
134
138
sizer .AddMany ([l_zoom , z .chooser (self )])
135
139
if FIXED_FONT in self ._settings :
136
- l_ff , editor = boolean_editor (self , self ._settings , FIXED_FONT , 'Use fixed width font' )
140
+ l_ff , editor = boolean_editor (self , self ._settings , FIXED_FONT , _ ( 'Use fixed width font' ) )
137
141
if IS_WINDOWS :
138
142
set_colors (l_ff , background_color , foreground_color )
139
143
sizer .AddMany ([l_ff , editor ])
140
144
fixed_font = self ._settings [FIXED_FONT ]
141
145
if 'font face' in self ._settings :
142
- s = StringChoiceEditor (self ._settings , 'font face' , 'Font Face' , read_fonts (fixed_font ))
146
+ s = StringChoiceEditor (self ._settings , 'font face' , _ ( 'Font Face' ) , read_fonts (fixed_font ))
143
147
l_font = s .label (self )
144
148
if IS_WINDOWS :
145
149
set_colors (l_font , background_color , foreground_color )
@@ -151,11 +155,12 @@ def create_colors_sizer(self):
151
155
152
156
153
157
class TextEditorPreferences (EditorPreferences ):
154
- location = ("Text Editor" ,)
155
- title = "Text Editor Settings"
156
- name = "Text Edit"
158
+ location = (_ ("Text Editor" ),)
157
159
158
160
def __init__ (self , settings , * args , ** kwargs ):
161
+ self .location = (_ ("Text Editor" ),)
162
+ self .title = _ ("Text Editor Settings" )
163
+ self .name = "Text Edit"
159
164
super (TextEditorPreferences , self ).__init__ (
160
165
settings [self .name ], * args , ** kwargs )
161
166
@@ -165,23 +170,23 @@ def create_colors_sizer(self):
165
170
row = 0
166
171
if robotframeworklexer :
167
172
settings = (
168
- ('argument' , 'Argument foreground' ),
169
- ('comment' , 'Comment foreground' ),
170
- ('error' , 'Error foreground' ),
171
- ('gherkin' , 'Gherkin keyword foreground' ),
172
- ('heading' , 'Heading foreground' ),
173
- ('import' , 'Import foreground' ),
174
- ('variable' , 'Variable foreground' ),
175
- ('tc_kw_name' , 'Keyword definition foreground' ),
176
- ('keyword' , 'Keyword call foreground' ),
177
- ('separator' , 'Separator' ),
178
- ('setting' , 'Setting foreground' ),
179
- ('syntax' , 'Syntax characters' ),
173
+ ('argument' , _ ( 'Argument foreground' ) ),
174
+ ('comment' , _ ( 'Comment foreground' ) ),
175
+ ('error' , _ ( 'Error foreground' ) ),
176
+ ('gherkin' , _ ( 'Gherkin keyword foreground' ) ),
177
+ ('heading' , _ ( 'Heading foreground' ) ),
178
+ ('import' , _ ( 'Import foreground' ) ),
179
+ ('variable' , _ ( 'Variable foreground' ) ),
180
+ ('tc_kw_name' , _ ( 'Keyword definition foreground' ) ),
181
+ ('keyword' , _ ( 'Keyword call foreground' ) ),
182
+ ('separator' , _ ( 'Separator' ) ),
183
+ ('setting' , _ ( 'Setting foreground' ) ),
184
+ ('syntax' , _ ( 'Syntax characters' ) ),
180
185
('background' , TEXT_BACKGROUND ),
181
186
)
182
187
else :
183
188
settings = (
184
- ('setting' , 'Text foreground' ),
189
+ ('setting' , _ ( 'Text foreground' ) ),
185
190
('background' , TEXT_BACKGROUND ),
186
191
)
187
192
background_color = Colour (LIGHT_GRAY )
@@ -221,40 +226,41 @@ def on_reset(self, event):
221
226
222
227
223
228
class GridEditorPreferences (EditorPreferences ):
224
- location = ("Grid Editor" ,)
225
- title = "Grid Editor Settings"
226
- name = "Grid"
229
+ location = (_ ("Grid Editor" ),)
227
230
228
231
def __init__ (self , settings , * args , ** kwargs ):
232
+ self .location = (_ ("Grid Editor" ),)
233
+ self .title = _ ("Grid Editor Settings" )
234
+ self .name = "Grid"
229
235
super (GridEditorPreferences , self ).__init__ (
230
236
settings [self .name ], * args , ** kwargs )
231
237
self .Sizer .Add (self ._create_grid_config_editor ())
232
238
233
239
def _create_grid_config_editor (self ):
234
240
settings = self ._settings
235
241
sizer = wx .FlexGridSizer (rows = 6 , cols = 2 , vgap = 10 , hgap = 10 )
236
- l_col_size = self ._label_for ('Default column size' )
242
+ l_col_size = self ._label_for (_ ( 'Default column size' ) )
237
243
background_color = Colour (LIGHT_GRAY )
238
244
foreground_color = Colour ("black" )
239
245
if IS_WINDOWS :
240
246
set_colors (l_col_size , background_color , foreground_color )
241
247
sizer .Add (l_col_size )
242
248
sizer .Add (self ._number_editor (settings , 'col size' ))
243
- l_auto_size , editor = boolean_editor (self , settings , 'auto size cols' , 'Auto size columns' )
249
+ l_auto_size , editor = boolean_editor (self , settings , 'auto size cols' , _ ( 'Auto size columns' ) )
244
250
if IS_WINDOWS :
245
251
set_colors (l_auto_size , background_color , foreground_color )
246
252
sizer .AddMany ([l_auto_size , editor ])
247
- l_max_size = self ._label_for ('Max column size\n (applies when auto size is on)' )
253
+ l_max_size = self ._label_for (_ ( 'Max column size\n (applies when auto size is on)' ) )
248
254
if IS_WINDOWS :
249
255
set_colors (l_max_size , background_color , foreground_color )
250
256
sizer .Add (l_max_size )
251
257
sizer .Add (self ._number_editor (settings , 'max col size' ))
252
- l_word_wrap , editor = boolean_editor (self , settings , 'word wrap' , 'Word wrap and auto size rows' )
258
+ l_word_wrap , editor = boolean_editor (self , settings , 'word wrap' , _ ( 'Word wrap and auto size rows' ) )
253
259
if IS_WINDOWS :
254
260
set_colors (l_word_wrap , background_color , foreground_color )
255
261
sizer .AddMany ([l_word_wrap , editor ])
256
262
l_auto_suggest , editor = boolean_editor (self , settings , 'enable auto suggestions' ,
257
- 'Enable auto suggestions' )
263
+ _ ( 'Enable auto suggestions' ) )
258
264
if IS_WINDOWS :
259
265
set_colors (l_auto_suggest , background_color , foreground_color )
260
266
sizer .AddMany ([l_auto_suggest , editor ])
@@ -292,13 +298,13 @@ def create_colors_sizer(self):
292
298
def _create_foreground_pickers (self , colors_sizer ):
293
299
row = 0
294
300
for key , label in (
295
- ('text user keyword' , 'User Keyword Foreground' ),
296
- ('text library keyword' , 'Library Keyword Foreground' ),
297
- ('text variable' , 'Variable Foreground' ),
298
- ('text unknown variable' , 'Unknown Variable Foreground' ),
299
- ('text commented' , 'Comments Foreground' ),
300
- ('text string' , 'Default Foreground' ),
301
- ('text empty' , 'Empty Foreground' ),
301
+ ('text user keyword' , _ ( 'User Keyword Foreground' ) ),
302
+ ('text library keyword' , _ ( 'Library Keyword Foreground' ) ),
303
+ ('text variable' , _ ( 'Variable Foreground' ) ),
304
+ ('text unknown variable' , _ ( 'Unknown Variable Foreground' ) ),
305
+ ('text commented' , _ ( 'Comments Foreground' ) ),
306
+ ('text string' , _ ( 'Default Foreground' ) ),
307
+ ('text empty' , _ ( 'Empty Foreground' ) ),
302
308
):
303
309
lbl = wx .StaticText (self , wx .ID_ANY , label )
304
310
if IS_WINDOWS :
@@ -319,14 +325,14 @@ def _create_background_pickers(self, colors_sizer):
319
325
background_color = Colour (LIGHT_GRAY )
320
326
foreground_color = Colour ("black" )
321
327
for key , label in (
322
- ('background assign' , 'Variable Background' ),
323
- ('background keyword' , 'Keyword Background' ),
324
- ('background mandatory' , 'Mandatory Field Background' ),
325
- ('background optional' , 'Optional Field Background' ),
326
- ('background must be empty' , 'Mandatory Empty Field Background' ),
327
- ('background unknown' , 'Unknown Background' ),
328
- ('background error' , 'Error Background' ),
329
- ('background highlight' , 'Highlight Background' )
328
+ ('background assign' , _ ( 'Variable Background' ) ),
329
+ ('background keyword' , _ ( 'Keyword Background' ) ),
330
+ ('background mandatory' , _ ( 'Mandatory Field Background' ) ),
331
+ ('background optional' , _ ( 'Optional Field Background' ) ),
332
+ ('background must be empty' , _ ( 'Mandatory Empty Field Background' ) ),
333
+ ('background unknown' , _ ( 'Unknown Background' ) ),
334
+ ('background error' , _ ( 'Error Background' ) ),
335
+ ('background highlight' , _ ( 'Highlight Background' ) )
330
336
):
331
337
lbl = wx .StaticText (self , wx .ID_ANY , label )
332
338
if IS_WINDOWS :
@@ -352,14 +358,15 @@ def on_save_load_settings(self, event):
352
358
353
359
354
360
class TestRunnerPreferences (EditorPreferences ):
355
- location = ("Test Runner" ,)
356
- title = "Test Runner Settings"
357
- name = "Test Runner"
361
+ location = (_ ("Test Runner" ),)
358
362
359
363
def __init__ (self , settings , * args , ** kwargs ):
364
+ self .location = (_ ("Test Runner" ),)
365
+ self .title = _ ("Test Runner Settings" )
366
+ self .name = "Test Runner"
360
367
super (TestRunnerPreferences , self ).__init__ (
361
368
settings ['Plugins' ][self .name ], * args , ** kwargs )
362
- self .Sizer .Add (wx .StaticText (self , wx .ID_ANY , "Colors will be active after next RIDE restart." ))
369
+ self .Sizer .Add (wx .StaticText (self , wx .ID_ANY , _ ( "Colors will be active after next RIDE restart." ) ))
363
370
self .Sizer .Add (self ._create_test_runner_config_editor ())
364
371
365
372
def _create_test_runner_config_editor (self ):
@@ -373,9 +380,9 @@ def _create_test_runner_config_editor(self):
373
380
else :
374
381
add_colors = "-C on"
375
382
l_usecolor , usecolor = boolean_editor (self , settings , 'use colors' ,
376
- f"Shows console colors set by { add_colors } " )
383
+ f"{ _ ( ' Shows console colors set by' ) } { add_colors } " )
377
384
l_confirm , editor = boolean_editor (self , settings , 'confirm run' ,
378
- 'Asks for confirmation to run all tests if none selected ' )
385
+ _ ( 'Asks for confirmation to run all tests if none selected ' ) )
379
386
if IS_WINDOWS :
380
387
background_color = Colour (LIGHT_GRAY )
381
388
foreground_color = Colour ("black" )
@@ -392,12 +399,12 @@ def create_colors_sizer(self):
392
399
background_color = Colour (LIGHT_GRAY )
393
400
foreground_color = Colour ("black" )
394
401
for settings_key , label_text in (
395
- ('foreground' , 'Text foreground' ),
402
+ ('foreground' , _ ( 'Text foreground' ) ),
396
403
('background' , TEXT_BACKGROUND ),
397
- ('error' , 'Error foreground' ),
398
- ('fail color' , 'Fail foreground' ),
399
- ('pass color' , 'Pass foreground' ),
400
- ('skip color' , 'Skip foreground' ),
404
+ ('error' , _ ( 'Error foreground' ) ),
405
+ ('fail color' , _ ( 'Fail foreground' ) ),
406
+ ('pass color' , _ ( 'Pass foreground' ) ),
407
+ ('skip color' , _ ( 'Skip foreground' ) ),
401
408
):
402
409
if column == 4 :
403
410
column = 0
0 commit comments