Skip to content

Commit

Permalink
Fix imports localization for test suites using Language (robotframewo…
Browse files Browse the repository at this point in the history
  • Loading branch information
HelioGuilherme66 authored Aug 5, 2024
1 parent 8926bf9 commit b92af78
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Likewise, the current version of wxPython, is 4.2.1, but RIDE is known to work w

`pip install -U robotframework-ride`

(3.8 <= python <= 3.12) Install current development version (**2.1dev63**) with:
(3.8 <= python <= 3.12) Install current development version (**2.1dev64**) with:

`pip install -U https://github.com/robotframework/RIDE/archive/master.zip`

Expand Down
2 changes: 1 addition & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def set_content(self, html_win, content):
<pre class="literal-block">
python -m robotide.postinstall -install
</pre>
<p>RIDE {VERSION} was released on 05/August/2024.</p>
<p>RIDE {VERSION} was released on 06/August/2024.</p>
<!-- <br/>
<h3>May The Fourth Be With You!</h3>
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>
Expand Down
17 changes: 16 additions & 1 deletion src/robotide/editor/listeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

import builtins
import wx
from multiprocessing import shared_memory
from wx import Colour
from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin

from ..context import ctrl_or_cmd, bind_keys_to_evt_menu, IS_WINDOWS
from ..controller import ctrlcommands
from ..lib.compat.parsing.language import get_localized_setting
from ..widgets import PopupMenu, PopupMenuItems, ButtonWithHandler, Font

_ = wx.GetTranslation # To keep linter/code analyser happy
Expand Down Expand Up @@ -198,8 +200,19 @@ def __init__(self, parent, columns, color_foreground='black',
self.SetOwnForegroundColour(Colour(color_foreground))
# self.EnableAlternateRowColours(True)
self._parent = parent
self._doc_language = None
self.set_language()
self.populate(columns, data or [])

def set_language(self):
try:
set_lang = shared_memory.ShareableList(name="language")
except AttributeError: # Unittests fails here
set_lang = []
if not set_lang:
set_lang[0] = ['en']
self._doc_language = set_lang[0]

def populate(self, columns, data):
for i, name in enumerate(columns):
self.InsertColumn(i, name)
Expand All @@ -212,7 +225,9 @@ def insert_data(self, data):
def _insert_data(self, data):
for row, item in enumerate(data):
rowdata = self._parent.get_column_values(item)
self.InsertItem(row, rowdata[0])
data_name = get_localized_setting(self._doc_language, rowdata[0])
# print(f"DEBUG: listeditor.py AutoWidthColumnList _insert_data {row=}:{rowdata[0]} data_name={data_name}")
self.InsertItem(row, data_name)
for i in range(1, len(rowdata)):
data = rowdata[i] is not None and rowdata[i] or ''
self.SetItem(row, i, data)
Expand Down
1 change: 1 addition & 0 deletions src/robotide/lib/compat/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# limitations under the License.

from .validator import ErrorReporter
from .language import get_english_label, get_localized_setting
11 changes: 11 additions & 0 deletions src/robotide/lib/compat/parsing/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,14 @@ def get_english_label(lang, label):
return label
en_label = list(mlang.settings.values())[index]
return en_label


def get_localized_setting(language: [], english_name: str):
if not language:
return english_name
settings = get_settings_for(language, (english_name,))
try:
result = list(settings.keys())[list(settings.values()).index(english_name)]
except ValueError:
return english_name
return result
13 changes: 1 addition & 12 deletions src/robotide/lib/robot/parsing/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,12 @@

from multiprocessing import shared_memory
from robotide.lib.robot.utils import is_string, unicode
from robotide.lib.compat.parsing import language as lang
from robotide.lib.compat.parsing.language import get_localized_setting

from .comments import Comment
from ..version import ALIAS_MARKER


def get_localized_setting(language: [], english_name: str):
if not language:
return english_name
settings = lang.get_settings_for(language, (english_name,))
try:
result = list(settings.keys())[list(settings.values()).index(english_name)]
except ValueError:
return english_name
return result


class Setting(object):
language = None

Expand Down
2 changes: 1 addition & 1 deletion src/robotide/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
#
# Automatically generated by `tasks.py`.

VERSION = 'v2.1dev63'
VERSION = 'v2.1dev64'

0 comments on commit b92af78

Please sign in to comment.