Skip to content

Commit fbd860f

Browse files
Add translations for Preferences, missing tree items excludes (robotframework#2706)
1 parent 8c46804 commit fbd860f

File tree

16 files changed

+2816
-344
lines changed

16 files changed

+2816
-344
lines changed

src/robotide/localization/RIDE.pot

+517-31
Large diffs are not rendered by default.
0 Bytes
Binary file not shown.

src/robotide/localization/nl/LC_MESSAGES/RIDE.po

+521-44
Large diffs are not rendered by default.
Binary file not shown.

src/robotide/localization/pt_BR/LC_MESSAGES/RIDE.po

+530-32
Large diffs are not rendered by default.
Binary file not shown.

src/robotide/localization/pt_PT/LC_MESSAGES/RIDE.po

+529-35
Large diffs are not rendered by default.
-22 Bytes
Binary file not shown.

src/robotide/localization/uk/LC_MESSAGES/RIDE.po

+531-50
Large diffs are not rendered by default.

src/robotide/preferences/editors.py

+65-58
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515

1616
from os.path import abspath, dirname, join
17-
17+
import builtins
1818
import wx
1919
from wx import Colour
2020
from wx.lib.masked import NumCtrl
@@ -31,11 +31,15 @@
3131
except ImportError: # Pygments is not installed
3232
robotframeworklexer = None
3333

34+
_ = wx.GetTranslation # To keep linter/code analyser happy
35+
builtins.__dict__['_'] = wx.GetTranslation
36+
37+
3438
ID_SAVELOADSETTINGS = wx.NewIdRef()
3539
ID_LOAD = 5551
3640
ID_SAVE = 5552
3741
ID_CANCEL = -1
38-
TEXT_BACKGROUND = 'Text background'
42+
TEXT_BACKGROUND = _('Text background')
3943
LIGHT_GRAY = 'light gray'
4044
FIXED_FONT = 'fixed font'
4145

@@ -75,8 +79,8 @@ def __init__(self, settings, *args, **kwargs):
7579
colors_sizer = self.create_colors_sizer()
7680
main_sizer = wx.FlexGridSizer(rows=6, cols=1, vgap=10, hgap=10)
7781
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'))
8084
main_sizer.Add(font_editor)
8185
main_sizer.Add(colors_sizer)
8286
buttons_sizer.Add(reset)
@@ -115,7 +119,7 @@ def _get_path():
115119

116120
def _create_font_editor(self):
117121
f = IntegerChoiceEditor(
118-
self._settings, 'font size', 'Font Size',
122+
self._settings, 'font size', _('Font Size'),
119123
[str(i) for i in range(8, 16)])
120124
sizer = wx.FlexGridSizer(rows=3, cols=2, vgap=10, hgap=30)
121125
l_size = f.label(self)
@@ -127,19 +131,19 @@ def _create_font_editor(self):
127131
fixed_font = False
128132
if 'zoom factor' in self._settings:
129133
z = SpinChoiceEditor(
130-
self._settings, 'zoom factor', 'Zoom Factor', (-10, 20))
134+
self._settings, 'zoom factor', _('Zoom Factor'), (-10, 20))
131135
l_zoom = z.label(self)
132136
if IS_WINDOWS:
133137
set_colors(l_zoom, background_color, foreground_color)
134138
sizer.AddMany([l_zoom, z.chooser(self)])
135139
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'))
137141
if IS_WINDOWS:
138142
set_colors(l_ff, background_color, foreground_color)
139143
sizer.AddMany([l_ff, editor])
140144
fixed_font = self._settings[FIXED_FONT]
141145
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))
143147
l_font = s.label(self)
144148
if IS_WINDOWS:
145149
set_colors(l_font, background_color, foreground_color)
@@ -151,11 +155,12 @@ def create_colors_sizer(self):
151155

152156

153157
class TextEditorPreferences(EditorPreferences):
154-
location = ("Text Editor",)
155-
title = "Text Editor Settings"
156-
name = "Text Edit"
158+
location = (_("Text Editor"),)
157159

158160
def __init__(self, settings, *args, **kwargs):
161+
self.location = (_("Text Editor"),)
162+
self.title = _("Text Editor Settings")
163+
self.name = "Text Edit"
159164
super(TextEditorPreferences, self).__init__(
160165
settings[self.name], *args, **kwargs)
161166

@@ -165,23 +170,23 @@ def create_colors_sizer(self):
165170
row = 0
166171
if robotframeworklexer:
167172
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')),
180185
('background', TEXT_BACKGROUND),
181186
)
182187
else:
183188
settings = (
184-
('setting', 'Text foreground'),
189+
('setting', _('Text foreground')),
185190
('background', TEXT_BACKGROUND),
186191
)
187192
background_color = Colour(LIGHT_GRAY)
@@ -221,40 +226,41 @@ def on_reset(self, event):
221226

222227

223228
class GridEditorPreferences(EditorPreferences):
224-
location = ("Grid Editor",)
225-
title = "Grid Editor Settings"
226-
name = "Grid"
229+
location = (_("Grid Editor"),)
227230

228231
def __init__(self, settings, *args, **kwargs):
232+
self.location = (_("Grid Editor"),)
233+
self.title = _("Grid Editor Settings")
234+
self.name = "Grid"
229235
super(GridEditorPreferences, self).__init__(
230236
settings[self.name], *args, **kwargs)
231237
self.Sizer.Add(self._create_grid_config_editor())
232238

233239
def _create_grid_config_editor(self):
234240
settings = self._settings
235241
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'))
237243
background_color = Colour(LIGHT_GRAY)
238244
foreground_color = Colour("black")
239245
if IS_WINDOWS:
240246
set_colors(l_col_size, background_color, foreground_color)
241247
sizer.Add(l_col_size)
242248
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'))
244250
if IS_WINDOWS:
245251
set_colors(l_auto_size, background_color, foreground_color)
246252
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)'))
248254
if IS_WINDOWS:
249255
set_colors(l_max_size, background_color, foreground_color)
250256
sizer.Add(l_max_size)
251257
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'))
253259
if IS_WINDOWS:
254260
set_colors(l_word_wrap, background_color, foreground_color)
255261
sizer.AddMany([l_word_wrap, editor])
256262
l_auto_suggest, editor = boolean_editor(self, settings, 'enable auto suggestions',
257-
'Enable auto suggestions')
263+
_('Enable auto suggestions'))
258264
if IS_WINDOWS:
259265
set_colors(l_auto_suggest, background_color, foreground_color)
260266
sizer.AddMany([l_auto_suggest, editor])
@@ -292,13 +298,13 @@ def create_colors_sizer(self):
292298
def _create_foreground_pickers(self, colors_sizer):
293299
row = 0
294300
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')),
302308
):
303309
lbl = wx.StaticText(self, wx.ID_ANY, label)
304310
if IS_WINDOWS:
@@ -319,14 +325,14 @@ def _create_background_pickers(self, colors_sizer):
319325
background_color = Colour(LIGHT_GRAY)
320326
foreground_color = Colour("black")
321327
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'))
330336
):
331337
lbl = wx.StaticText(self, wx.ID_ANY, label)
332338
if IS_WINDOWS:
@@ -352,14 +358,15 @@ def on_save_load_settings(self, event):
352358

353359

354360
class TestRunnerPreferences(EditorPreferences):
355-
location = ("Test Runner",)
356-
title = "Test Runner Settings"
357-
name = "Test Runner"
361+
location = (_("Test Runner"),)
358362

359363
def __init__(self, settings, *args, **kwargs):
364+
self.location = (_("Test Runner"),)
365+
self.title = _("Test Runner Settings")
366+
self.name = "Test Runner"
360367
super(TestRunnerPreferences, self).__init__(
361368
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.")))
363370
self.Sizer.Add(self._create_test_runner_config_editor())
364371

365372
def _create_test_runner_config_editor(self):
@@ -373,9 +380,9 @@ def _create_test_runner_config_editor(self):
373380
else:
374381
add_colors = "-C on"
375382
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} ")
377384
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 '))
379386
if IS_WINDOWS:
380387
background_color = Colour(LIGHT_GRAY)
381388
foreground_color = Colour("black")
@@ -392,12 +399,12 @@ def create_colors_sizer(self):
392399
background_color = Colour(LIGHT_GRAY)
393400
foreground_color = Colour("black")
394401
for settings_key, label_text in (
395-
('foreground', 'Text foreground'),
402+
('foreground', _('Text foreground')),
396403
('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')),
401408
):
402409
if column == 4:
403410
column = 0

src/robotide/preferences/general.py

+26-22
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from functools import lru_cache
1616
from os.path import abspath, dirname, join
17-
17+
import builtins
1818
import wx
1919

2020
from ..ui.preferences_dialogs import (boolean_editor, PreferencesPanel, IntegerChoiceEditor, SpinChoiceEditor,
@@ -27,6 +27,9 @@
2727
except ImportError:
2828
languages = None
2929

30+
_ = wx.GetTranslation # To keep linter/code analyser happy
31+
builtins.__dict__['_'] = wx.GetTranslation
32+
3033
ID_APPLY_TO_PANEL = wx.NewIdRef()
3134
ID_RESET = wx.NewIdRef()
3235
ID_SAVELOADSETTINGS = wx.NewIdRef()
@@ -74,7 +77,7 @@ def __init__(self, settings, *args, **kwargs):
7477
super(GeneralPreferences, self).__init__(*args, **kwargs)
7578
self._settings = settings
7679
self._color_pickers = []
77-
self.name = None
80+
self.name = 'General'
7881
self._apply_to_panels = self._settings.get('apply to panels', False)
7982

8083
# what would make this UI much more usable is if there were a
@@ -87,10 +90,10 @@ def __init__(self, settings, *args, **kwargs):
8790
colors_sizer = self.create_colors_sizer()
8891
main_sizer = wx.FlexGridSizer(rows=6, cols=1, vgap=10, hgap=10)
8992
buttons_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
90-
reset = wx.Button(self, ID_RESET, 'Reset colors to default')
91-
saveloadsettings = wx.Button(self, ID_SAVELOADSETTINGS, 'Save or Load settings')
93+
reset = wx.Button(self, ID_RESET, _('Reset colors to default'))
94+
saveloadsettings = wx.Button(self, ID_SAVELOADSETTINGS, _('Save or Load settings'))
9295
self.cb_apply_to_panels = wx.CheckBox(self, ID_APPLY_TO_PANEL,
93-
label="Apply to Project and File Explorer panels")
96+
label=_("Apply to Project and File Explorer panels"))
9497
self.cb_apply_to_panels.Enable()
9598
self.cb_apply_to_panels.SetValue(self._apply_to_panels)
9699
if IS_WINDOWS:
@@ -135,7 +138,7 @@ def on_save_load_settings(self, event):
135138
# Does not look nice but closes Preferences window, so it comes recolored on next call
136139
# Only working on first use :(
137140
# DEBUG: Only close window when Loading, not when Saving (but return is always 5101)
138-
wx.FindWindowByName("RIDE - Preferences").Close(force=True)
141+
wx.FindWindowByName(_("RIDE - Preferences")).Close(force=True)
139142

140143
def _reload_settings(self):
141144
import os
@@ -186,7 +189,7 @@ def _get_path():
186189

187190
def _create_font_editor(self):
188191
f = IntegerChoiceEditor(
189-
self._settings, 'font size', 'Font Size',
192+
self._settings, 'font size', _('Font Size'),
190193
[str(i) for i in range(8, 16)])
191194
sizer = wx.FlexGridSizer(rows=3, cols=2, vgap=10, hgap=30)
192195
l_size = f.label(self)
@@ -198,19 +201,19 @@ def _create_font_editor(self):
198201
fixed_font = False
199202
if 'zoom factor' in self._settings:
200203
z = SpinChoiceEditor(
201-
self._settings, 'zoom factor', 'Zoom Factor', (-10, 20))
204+
self._settings, 'zoom factor', _('Zoom Factor'), (-10, 20))
202205
l_zoom = z.label(self)
203206
if IS_WINDOWS:
204207
set_colors(l_zoom, background_color, foreground_color)
205208
sizer.AddMany([l_zoom, z.chooser(self)])
206209
if FIXED_FONT in self._settings:
207-
l_ff, editor = boolean_editor(self, self._settings, FIXED_FONT, 'Use fixed width font')
210+
l_ff, editor = boolean_editor(self, self._settings, FIXED_FONT, _('Use fixed width font'))
208211
if IS_WINDOWS:
209212
set_colors(l_ff, background_color, foreground_color)
210213
sizer.AddMany([l_ff, editor])
211214
fixed_font = self._settings[FIXED_FONT]
212215
if 'font face' in self._settings:
213-
s = StringChoiceEditor(self._settings, 'font face', 'Font Face', read_fonts(fixed_font))
216+
s = StringChoiceEditor(self._settings, 'font face', _('Font Face'), read_fonts(fixed_font))
214217
l_font = s.label(self)
215218
if IS_WINDOWS:
216219
set_colors(l_font, background_color, foreground_color)
@@ -223,7 +226,7 @@ def _select_ui_language(self):
223226
background_color = Colour(LIGHT_GRAY)
224227
foreground_color = Colour("black")
225228
if 'ui language' in self._settings:
226-
ll = StringChoiceEditor(self._settings, 'ui language', 'Language', read_languages())
229+
ll = StringChoiceEditor(self._settings, 'ui language', _('Language'), read_languages())
227230
l_lang = ll.label(self)
228231
if IS_WINDOWS:
229232
set_colors(l_lang, background_color, foreground_color)
@@ -236,24 +239,25 @@ def create_colors_sizer(self):
236239

237240

238241
class DefaultPreferences(GeneralPreferences):
239-
location = ("General",)
240-
title = "General Settings"
241-
name = "General"
242+
location = (_("General"),)
242243

243244
def __init__(self, settings, *args, **kwargs):
244-
super(DefaultPreferences, self).__init__(settings[self.name], *args, **kwargs)
245+
self.location = (_("General"),)
246+
self.title = _("General Settings")
247+
self.name = "General"
248+
super(DefaultPreferences, self).__init__(settings[self.name], name_tr=_("General"), *args, **kwargs)
245249

246250
def create_colors_sizer(self):
247251
container = wx.GridBagSizer()
248252
column = 0
249253
row = 0
250254
settings = (
251-
('foreground', 'Foreground'),
252-
('background', 'Background'),
253-
('secondary foreground', 'Secondary Foreground'),
254-
('secondary background', 'Secondary Background'),
255-
('foreground text', 'Text Foreground'),
256-
('background help', 'Help Background')
255+
('foreground', _('Foreground')),
256+
('background', _('Background')),
257+
('secondary foreground', _('Secondary Foreground')),
258+
('secondary background', _('Secondary Background')),
259+
('foreground text', _('Text Foreground')),
260+
('background help', _('Help Background'))
257261
)
258262
background_color = Colour(LIGHT_GRAY)
259263
foreground_color = Colour("black")
@@ -278,4 +282,4 @@ def on_reset(self, event):
278282
for picker in self._color_pickers:
279283
picker.SetColour(defaults[picker.key])
280284
# self.Refresh()
281-
wx.FindWindowByName("RIDE - Preferences").Close(force=True)
285+
wx.FindWindowByName(_("RIDE - Preferences")).Close(force=True)

0 commit comments

Comments
 (0)