Skip to content

Commit

Permalink
Lang project (#2687)
Browse files Browse the repository at this point in the history
* Fix Edit menu translations.

* Improve dialogs translation, About

* Add unit test for tr_credits

* Fix activation of Release Notes and Changelog

* Improve size of buttons in Text Editor

* Fix unit tests

* Add protection for missing datafile attribute in Text Editor

* Improve sizes of buttons in Settings editors

* Dev version

* Update translations

* Update translations
  • Loading branch information
HelioGuilherme66 authored Jan 15, 2024
1 parent 069316b commit 285593c
Show file tree
Hide file tree
Showing 24 changed files with 959 additions and 532 deletions.
4 changes: 2 additions & 2 deletions src/robotide/action/actioninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def action_info_collection(data, event_handler, data_nt=None, container=None):
continue
elif row.startswith('[') and row.endswith(']'):
menu = row[1:-1].strip()
print(f"DEBUG: actioninfo.py action_info_collection menu={menu}")
# print(f"DEBUG: actioninfo.py action_info_collection menu={menu}")
else:
actions.append(_create_action_info(event_handler, menu, container, row, row_nt))
return actions
Expand All @@ -145,7 +145,7 @@ def _create_action_info(eventhandler, menu, container, row, row_nt):
# if t_menu.startswith('[') and t_menu.endswith(']'):
# t_menu = t_menu[1:-1].strip()
t_row = _(row) # .replace('&', ''))
print(f"DEBUG: actioninfo.py _create_action_info menu={t_menu} t_row={t_row} row_nt={row_nt}")
# print(f"DEBUG: actioninfo.py _create_action_info menu={t_menu} t_row={t_row} row_nt={row_nt}")
if row_nt.startswith('---'):
return SeparatorInfo(menu)
tokens = [t.strip() for t in t_row.split('|')]
Expand Down
19 changes: 12 additions & 7 deletions src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import builtins
import os
import re
import time
Expand All @@ -26,6 +27,9 @@
from ..version import VERSION
from ..widgets import HtmlDialog

_ = wx.GetTranslation # To keep linter/code analyser happy
builtins.__dict__['_'] = wx.GetTranslation

HTML_FOREGROUND = 'foreground text'


Expand All @@ -47,12 +51,12 @@ def __init__(self, application):
self.enable()

def enable(self):
self.application.frame.actions.register_action(ActionInfo('Help', 'Release Notes',
self.application.frame.actions.register_action(ActionInfo(_('Help'), _('Release Notes'),
self.show,
doc='Show the release notes'))
self.application.frame.actions.register_action(ActionInfo('Help', 'Offline Change Log',
doc=_('Show the release notes')))
self.application.frame.actions.register_action(ActionInfo(_('Help'), _('Offline Change Log'),
self.show_changelog,
doc='Show the offline CHANGELOG'))
doc=_('Show the offline CHANGELOG')))
self.show_if_updated()

def show_if_updated(self):
Expand All @@ -64,14 +68,15 @@ def show(self, event=None):
__ = event
if not self._view:
self._view = self._create_view()
self.application.frame.notebook.AddPage(self._view, "Release Notes", select=False)
self.application.frame.notebook.AddPage(self._view, _("Release Notes"), select=False)
self.application.frame.notebook.show_tab(self._view)

def show_changelog(self, event=None):
__ = event
if not self._dialog:
self._dialog = HtmlDialog('Offline Change Log', f"Check the online version at https://github.com/"
f"robotframework/RIDE/blob/{VERSION}/CHANGELOG.adoc")
self._dialog = HtmlDialog(_('Offline Change Log'),
_("Check the online version at ") +
f"https://github.com/robotframework/RIDE/blob/{VERSION}/CHANGELOG.adoc")
self._dialog.SetSize(800, 800)
# DEBUG: If we LoadFile, we cannot change the foreground color
# self._dialog.html_wnd.LoadFile(join(dirname(abspath(__file__)), "CHANGELOG.html"))
Expand Down
42 changes: 39 additions & 3 deletions src/robotide/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import builtins
import os
import sys
import wx
Expand All @@ -22,6 +23,9 @@
from ..robotapi import ROBOT_LOGGER
from ..version import VERSION

_ = wx.GetTranslation # To keep linter/code analyser happy
builtins.__dict__['_'] = wx.GetTranslation

APP = None
LOG = logger.Logger()
ROBOT_LOGGER.unregister_console_logger()
Expand Down Expand Up @@ -51,8 +55,40 @@
POPUP_FOREGROUND = (40, 40, 0) # (255, 255, 187)

pyversion = '.'.join(str(v) for v in sys.version_info[:3])
SYSTEM_INFO = "Started RIDE %s using python version %s with wx version %s in %s." % \
SYSTEM_INFO = _("Started RIDE %s using python version %s with wx version %s in %s.") % \
(VERSION, pyversion, WX_VERSION, sys.platform)


def get_about_ride():
rf = '<a href="https://robotframework.org/">Robot Framework</a>'
ghrf = '<a href="https://github.com/robotframework/RIDE">https://github.com/robotframework/RIDE</a>'
si = '<a href="https://github.com/legacy-icons/famfamfam-silk/">Silk Icons</a>'
# Note: <!-- Originally from http://www.famfamfam.com/lab/icons/silk/ 404 in 10-june-2023-->
mt = '<a href="https://github.com/HelioGuilherme66">Hélio Guilherme</a>'
foundation = '<a href="https://robotframework.org/foundation/">Robot Framework Foundation</a>'
from ..locale.tr_credits import tr_credits
tr = tr_credits()
translators = _("Thanks all RIDE translators: %s") % tr
rfecosys = '<b>Robot Framework Ecosystem Projects 2023</b>'
heading = _("RIDE -- Robot Framework Test Data Editor")
content = []
content += [_("RIDE %s running on Python %s.") % (VERSION, pyversion)]
content += ["<br/>" + _("RIDE is a test data editor for %s.") % rf]
content += [_("For more information, see project pages at %s.") % ghrf]
content += ["<br/>" + _("Some of the icons are from %s.") % si]
maintainer = _("%s the maintainer of the project thanks the original authors and all users and collaborators.") % mt
special = _("A special thanks to %s for having sponsored the development of translated test suites content "
"compatibility with %s Version 6.1, in their %s.") % (foundation, rf, rfecosys)
build_about = []
build_about += [f"<h3>{heading}</h3>"]
build_about += [f"{line}<br/>" for line in content]
build_about += [f"<p><br/>{maintainer}<br/></p>"]
build_about += [f"<p>{special}</p>"]
build_about += [f"<br/><div>{translators}</div>"]

return "".join(build_about)

"""
ABOUT_RIDE = '''<h3>RIDE -- Robot Framework Test Data Editor</h3>
<p>RIDE %s running on Python %s.</p>
<p>RIDE is a test data editor for <a href="https://robotframework.org/">Robot Framework</a>.
Expand All @@ -67,6 +103,7 @@
on">Johnny.H</a></b> the most commited in helping RIDE development and maintenance.
--></p>
''' % (VERSION, pyversion)
"""


def ctrl_or_cmd():
Expand All @@ -84,8 +121,7 @@ def bind_keys_to_evt_menu(target, actions):
target.SetAcceleratorTable(wx.AcceleratorTable(accelrators))


SHORTCUT_KEYS = '''\
<h2>Shortcut keys in RIDE</h2>
SHORTCUT_KEYS = '''<h2>Shortcut keys in RIDE</h2>
<table>
<tr align="left">
<th><b>Shortcut</b></th>
Expand Down
2 changes: 2 additions & 0 deletions src/robotide/controller/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def test_data(source, parent=None, settings=None, language=None):
init_file = os.path.join(source, '__init__.robot')
if os.path.isfile(init_file):
language = lang.check_file_language(init_file)
print(f"DEBUG: Dataloader TestCaseFile init file {init_file=}\n"
f" language={language} {source=}")
data = TestDataDirectoryWithExcludes(parent, source, settings, language)
# print("DEBUG: Dataloader testdata %s\n" % data.name)
data.populate()
Expand Down
16 changes: 8 additions & 8 deletions src/robotide/editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ def get_menudata():


class EditorPlugin(Plugin, TreeAwarePluginMixin):
"""The default editor plugin.

def __init__(self, application):
self.__doc__ = _("""The default editor plugin. Also known as Grid or Cell Editor.
This plugin implements editors for the various items of Robot Framework
test data.
"""

def __init__(self, application):
""")
Plugin.__init__(self, application)
self._tab = None
self.grid_popup_creator = PopupCreator()
Expand Down Expand Up @@ -175,20 +175,20 @@ def on_open_editor(self, event):
self._show_editor()

def on_tab_changed(self, message):
_ = message
__ = message
self._show_editor()

def on_tab_changing(self, message):
if 'Editor' in message.oldtab:
self._tab.save()

def on_save_to_model(self, message):
_ = message
__ = message
if self._tab:
self._tab.save()

def on_file_deleted(self, message):
_ = message
__ = message
self._create_editor()


Expand Down Expand Up @@ -309,7 +309,7 @@ def on_content_assistance(self, event):
self.editor.show_content_assist()

def save(self, message=None):
_ = message
__ = message
if self.editor:
self.editor.save()

Expand Down
5 changes: 2 additions & 3 deletions src/robotide/editor/editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class WelcomePage(HtmlWindow):
= show_content_assist = tree_item_selected = lambda *args: None

def __init__(self, parent):
HtmlWindow.__init__(self, parent, text=context.ABOUT_RIDE)
HtmlWindow.__init__(self, parent, text=context.get_about_ride())

def close(self):
self.Show(False)
Expand Down Expand Up @@ -340,8 +340,7 @@ def _populate(self):
def _create_source_label(self, source):
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add((5, 0))
sizer.Add(Label(self, label=_('Source'), size=(context.SETTING_LABEL_WIDTH,
context.SETTING_ROW_HEIGHT)))
sizer.Add(Label(self, label=_('Source'), size=(context.SETTING_LABEL_WIDTH, context.SETTING_ROW_HEIGHT)))
self._source = wx.TextCtrl(self, style=wx.TE_READONLY | wx.NO_BORDER)
self._source.SetBackgroundColour(Colour(self.color_background))
self._source.SetForegroundColour(Colour(self.color_foreground))
Expand Down
4 changes: 2 additions & 2 deletions src/robotide/editor/listeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@


class ListEditorBase(wx.Panel):
_menu = [_('Edit'), _('Move Up\tCtrl-Up'), _('Move Down\tCtrl-Down'), '---', _('Delete')]
_menu_nt = ['Edit', 'Move Up\tCtrl-Up', 'Move Down\tCtrl-Down', '---', 'Delete']
_buttons = []
_buttons_nt = []

def __init__(self, parent, columns, controller, label=None):
self._menu = [_('Edit'), _('Move Up\tCtrl-Up'), _('Move Down\tCtrl-Down'), '---', _('Delete')]
wx.Panel.__init__(self, parent)
from ..preferences import RideSettings
_settings = RideSettings()
Expand Down Expand Up @@ -77,7 +77,7 @@ def _create_list(self, columns, data):
def _create_buttons(self):
sizer = wx.BoxSizer(wx.VERTICAL)
for label, mk_h in zip(self._buttons, self._buttons_nt):
sizer.Add(ButtonWithHandler(self, label, mk_handler=mk_h, width=120,
sizer.Add(ButtonWithHandler(self, label, mk_handler=mk_h, width=-1, fsize=self.font_size,
color_secondary_foreground=self.color_secondary_foreground,
color_secondary_background=self.color_secondary_background), 0, wx.ALL, 1)
return sizer
Expand Down
39 changes: 25 additions & 14 deletions src/robotide/editor/settingeditors.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,25 @@ def __init__(self, parent, controller, plugin, tree):
def _create_controls(self):
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add((5, 0))
label = Label(
self, label=self._controller.label,
size=(context.SETTING_LABEL_WIDTH, context.SETTING_ROW_HEIGHT)) # Always show the English label as tooltip
width = max(len(self._controller.label), context.SETTING_LABEL_WIDTH)
label = Label(self, label=self._controller.label,
size=(width, context.SETTING_ROW_HEIGHT)) # Always show the English label as tooltip
label.SetToolTip(get_english_label(self._language, self._controller.label))
sizer.Add(label)
self._value_display = self._create_value_display()
self.update_value()
self._tooltip = self._get_tooltip()
sizer.Add(self._value_display, 1, wx.EXPAND)
self._add_edit(sizer)
sizer.Add(ButtonWithHandler(self, _('Clear'), mk_handler='Clear', handler=self.on_clear,
sizer.Add(ButtonWithHandler(self, _('Clear'), mk_handler='Clear', handler=self.on_clear, fsize=self.font_size,
color_secondary_foreground=self.color_secondary_foreground,
color_secondary_background=self.color_secondary_background))
sizer.Layout()
self.SetSizer(sizer)

def _add_edit(self, sizer):
sizer.Add(
ButtonWithHandler(self, _('Edit'), mk_handler='Edit', handler=self.on_edit,
ButtonWithHandler(self, _('Edit'), mk_handler='Edit', handler=self.on_edit, fsize=self.font_size,
color_secondary_foreground=self.color_secondary_foreground,
color_secondary_background=self.color_secondary_background),
flag=wx.LEFT | wx.RIGHT, border=5)
Expand Down Expand Up @@ -476,11 +476,11 @@ def highlight(self, text, expand=False):


class VariablesListEditor(_AbstractListEditor):
_titles = [_('Variable'), _('Value'), _('Comment')]
_buttons = [_('Add Scalar'), _('Add List'), _('Add Dict')]
_buttons_nt = ['Add Scalar', 'Add List', 'Add Dict']

def __init__(self, parent, tree, controller):
self._titles = [_('Variable'), _('Value'), _('Comment')]
self._buttons = [_('Add Scalar'), _('Add List'), _('Add Dict')]
PUBLISHER.subscribe(
self._update_vars, RideVariableAdded)
PUBLISHER.subscribe(
Expand Down Expand Up @@ -564,11 +564,11 @@ def close(self):


class ImportSettingListEditor(_AbstractListEditor):
_titles = [_('Import'), _('Name / Path'), _('Arguments'), _('Comment')]
_buttons = [_('Library'), _('Resource'), _('Variables'), _('Import Failed Help')]
_buttons_nt = ['Library', 'Resource', 'Variables', 'Import Failed Help']

def __init__(self, parent, tree, controller, lang=None):
self._titles = [_('Import'), _('Name / Path'), _('Arguments'), _('Comment')]
self._buttons = [_('Library'), _('Resource'), _('Variables'), _('Import Failed Help')]
self._import_failed_shown = False
try:
self._language = controller.parent.datafile._language
Expand All @@ -582,11 +582,18 @@ def __init__(self, parent, tree, controller, lang=None):

def _create_buttons(self):
sizer = wx.BoxSizer(wx.VERTICAL)
label = _('Add Import')
lsize = len(label) * self.font_size + 4
sizer.Add(Label(
self, label=_('Add Import'), size=wx.Size(120, 20),
self, label=label, size=wx.Size(lsize, 20),
style=wx.ALIGN_CENTER))
# Get max button size
bsize = 0
for x in self._buttons:
bsize = max(bsize, len(x))
bsize = bsize * self.font_size + 4
for label, label_nt in zip(self._buttons, self._buttons_nt):
sizer.Add(ButtonWithHandler(self, label, mk_handler=label_nt, width=120,
sizer.Add(ButtonWithHandler(self, label, mk_handler=label_nt, width=bsize,
color_secondary_foreground=self.color_secondary_foreground,
color_secondary_background=self.color_secondary_background), 0, wx.ALL, 1)
return sizer
Expand Down Expand Up @@ -651,7 +658,7 @@ def on_variables(self, event):
VariablesDialog,
lambda v, c:
self._controller.execute(ctrlcommands.AddVariablesFileImport(v, c)),
title=_('Variables')) # DEBUG
title=_('Variables'))

def on_import_failed_help(self, event):
__ = event
Expand Down Expand Up @@ -704,11 +711,15 @@ def get_column_values(item):


class MetadataListEditor(_AbstractListEditor):
_titles = [_('Metadata'), _('Value'), _('Comment')]
_buttons = [_('Add Metadata')]

_buttons_nt = ['Add Metadata']
_sortable = False

def __init__(self, parent, tree, controller):
self._titles = [_('Metadata'), _('Value'), _('Comment')]
self._buttons = [_('Add Metadata')]
_AbstractListEditor.__init__(self, parent, tree, controller)

def on_edit(self, event):
meta = self._controller[self._selection]
dlg = MetadataDialog(self._controller.datafile, item=meta)
Expand Down
Loading

0 comments on commit 285593c

Please sign in to comment.