Skip to content

Commit

Permalink
Fix for #2679 (#2680)
Browse files Browse the repository at this point in the history
* Improve reader. DEBUG

* Improve reader.

* Add check_file_language. Working in project.load_data, but not when opening files.

* Add condition fro lang in model

* First success opening laang_pt and lang_fr tests

* Make unit tests pass

* Improve lang headers, pt and fr

* Add unit tests. All lnguages tests can be opened. Missing lib lang fixes

* Identify where language can be checked from TextEditor

* More tables using language

* Working opening with lang set. Tests for multiple langs

* Working opening directories with different lang files

* Make __init__.robot open with language set. WIP, copy _aliases to _settings

* OK Opens from directories.

* Fixed open test suites directories. Need utests and fix comments

* Fix opening directly __init__.robot

* Cleanup code

* Improve opening of Resource files

* Open pt folder, fail en folder. Failed comment blocks at formatter level

* Add order of sections. Still broken en directories, and missing memory clear on open

* Fix some utests

* Fix unit tests

* Remove inner comments from the en test directory

* Success in multiple Comments sections. Missing isolated comments

* Fix # isolated comments and Comments section

* Settings Dialogs OK. Need localizaation. Variables is debug

* Adjust buttons in table settings to open dialogs for Tests and Tasks

* Fix all settings Edit buttons

* Fix continuation lines in Documentation other than En

* Improve setting of language in TextEditor

* Fix Library translated labels

* I18n colorization (#143)

* Initial modification of pygments. Missing Gerkin

* Remove nolower

* Almost done. Missing Gherkin and Documentation setting color not OK

* Fixed Gherkin calls. Still to fix TestTableSettings Setup/Teardown/Template keywords

* Final fixes for colorization

* Fix error when opening directories with log or report html files

* Update docs and version

* Add validator from RF 6.1.1 to Text Edit. WIP fails to save language files

* Add new validator

* Fix saving modified files with language setting

* Fix help dialog for Pygments

* Add protection to shared_memory language setting

* Remove extra spaces from lines in Comments sections

* Remove support for HTML test files. WIP

* Make own pygments a module

* Fix broken sincronization of changes in Text Editor

* Add minimal protection to RF lower than 6.0

* Add tooltip to settings fields localized names

* Notes about tooltips

* Add language selector to Preferences->General

* Initial structure for localization change

* Add first example de localized strings

* Add test from W2

* Add more debugging for localization

* Fix pause translated commands

* Update translations for TestRunner

* Fix some unit tests

* Fix import failed XML

* Fix unit test

* Fix more translations in in Tests and in Unudrd Keywords

* Fix default ui language, Variables and Metadata editors

* Improvement in language save or RIDE start

* Add pt_BR translation

* DEBUG Save from Text Editor

* Improve reader. DEBUG

* Improve reader.

* Add check_file_language. Working in project.load_data, but not when opening files.

* Working opening with lang set. Tests for multiple langs

* Working opening directories with different lang files

* Fixed open test suites directories. Need utests and fix comments

* Cleanup code

* Add order of sections. Still broken en directories, and missing memory clear on open

* Fix some utests

* Fix unit tests

* Remove inner comments from the en test directory

* Success in multiple Comments sections. Missing isolated comments

* Fix # isolated comments and Comments section

* Add validator from RF 6.1.1 to Text Edit. WIP fails to save language files

* Remove support for HTML test files. WIP

* Add language selector to Preferences->General

* Add first example de localized strings

* Add test from W2

* Add more debugging for localization

* Fix some unit tests

* Fix import failed XML

* Fix more translations in in Tests and in Unudrd Keywords

* Add more PT translations. Debug FileWriter

* Fix adding new tables. Closes #2679
  • Loading branch information
HelioGuilherme66 authored Jan 6, 2024
1 parent 86d7c88 commit e2d384f
Show file tree
Hide file tree
Showing 14 changed files with 371 additions and 49 deletions.
38 changes: 38 additions & 0 deletions src/robotide/lib/robot/parsing/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,44 @@ def __iter__(self):
return iter(self.keywords)


class CommentRow(object):
row = []
is_comments = True

def __init__(self, content):
print(f"DEBUG: RFLib model.py CommentRow init {content=}")
self.add(content[0])

def add(self, row):
self.row.append(row)

def is_set(self):
return False

def is_for_loop(self):
return False

def __iter__(self):
print(f"DEBUG: RFLib model.py CommentRow __iter__ return iter({self.row})")
for r in self.row:
yield r

"""
def as_list(self):
return self.row
def __iter__(self):
print(f"DEBUG: RFLib model.py CommentRow __iter__ return iter({self.row})")
for r in self.row:
yield r
"""
"""
def __iter__(self):
for element in [self.row]:
yield element
"""


class CommentsTable(_Table):
type = 'comments'
is_comments = True
Expand Down
4 changes: 4 additions & 0 deletions src/robotide/lib/robot/parsing/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ class ImportSetting(Setting):

def __init__(self, parent, name, args=None, alias=None, comment=None):
self.parent = parent
if parent:
self.setting_name = get_localized_setting(parent.language, self.type)
else:
self.setting_name = self.type
self.name = name.strip()
Setting.__init__(self, setting_name=self.setting_name, parent=parent, comment=comment)
if args:
Expand Down
12 changes: 11 additions & 1 deletion src/robotide/lib/robot/writer/filewriters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import builtins
try:
import csv
except ImportError:
# csv module is missing from IronPython < 2.7.1
csv = None

import wx

from robotide.lib.robot.utils import HtmlWriter, PY2

from .formatters import TsvFormatter, TxtFormatter, PipeFormatter
from .htmlformatter import HtmlFormatter
from .htmltemplate import TEMPLATE_START, TEMPLATE_END

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


def table_sorter(tables: list) -> list:
sorted_tables = []
prev_tab_line = 0
for idx, tab in enumerate(tables):
sorted_tables.append((tab._lineno, tab))
current_tab_line = tab._lineno if tab._lineno is not None else prev_tab_line + 1
sorted_tables.append((current_tab_line, tab))
prev_tab_line = current_tab_line
# print(f"DEBUG: filewriters.py table_sorter {sorted_tables[:]}")
sorted_result = sorted(sorted_tables)
sorted_tables = [z[1] for z in sorted_result]
return sorted_tables
Expand Down
4 changes: 2 additions & 2 deletions src/robotide/lib/robot/writer/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class TxtFormatter(_DataFileFormatter):
_setting_and_variable_name_width = 14

def _format_row(self, row, table=None):
# print(f"DEBUG: formatters.py format_row ENTER row={row}")
print(f"DEBUG: formatters.py format_row ENTER row={row}")
if table and table.type == 'comments':
return row
# Unit tests failing here with row[0]==None
Expand All @@ -128,7 +128,7 @@ def _aligner_for(self, table):
return NullAligner()

def _format_header(self, header, table):
# print(f"DEBUG: RFLib writer formmaters.py TxtFormatter _format_header headers={header}")
print(f"DEBUG: RFLib writer formmaters.py TxtFormatter _format_header headers={header}")
header = ['*** %s ***' % header[0]] + header[1:]
aligner = self._aligner_for(table)
return aligner.align_row(header)
Expand Down
96 changes: 91 additions & 5 deletions src/robotide/locale/RIDE.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-01-01 19:29+0000\n"
"POT-Creation-Date: 2024-01-04 01:09+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -955,6 +955,9 @@ msgid "Documentation"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/run/configmanagerui.py:101
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:75
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:77
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:226
#: /home/helio/github/RIDE/src/robotide/ui/keywordsearch.py:352
msgid "Name"
msgstr ""
Expand Down Expand Up @@ -1060,6 +1063,7 @@ msgid "Help"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/actiontriggers.py:54
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:93
#: /home/helio/github/RIDE/src/robotide/ui/review.py:140
msgid "File"
msgstr ""
Expand All @@ -1068,6 +1072,88 @@ msgstr ""
msgid "&Help"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:93
msgid "Type"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:93
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:160
msgid "Directory"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:100
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:198
msgid "New Resource File"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:102
#: /home/helio/github/RIDE/src/robotide/ui/preview.py:116
msgid "Format"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:114
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:129
msgid "Parent Directory"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:115
msgid "Choose Parent Directory"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:132
msgid "Created Path"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:185
msgid "New Project"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:212
msgid "Add Suite"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:236
msgid "Add Directory"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:248
msgid "Set Data Format"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:272
msgid "Change recursively"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:291
msgid ""
"Provide format for initialization file in directory\n"
"\"%s\"."
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:305
msgid "Open"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:310
msgid "Robot data (*.robot)|*.robot"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:311
msgid "Robot data (*.txt)|*.txt"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:312
msgid "Robot resource file (*.resource)|*.resource"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:313
msgid "Robot Tab Separated data (*.tsv)|*.tsv"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:315
msgid "All files|*.*"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/keywordsearch.py:35
msgid "<all keywords>"
msgstr ""
Expand Down Expand Up @@ -1260,10 +1346,6 @@ msgstr ""
msgid "Text (Spaces)"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/preview.py:116
msgid "Format"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/preview.py:122
msgid "Print"
msgstr ""
Expand Down Expand Up @@ -1489,3 +1571,7 @@ msgstr ""
msgid "Importing Name"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/validators/__init__.py:150
msgid "%s cannot be empty"
msgstr ""

Binary file modified src/robotide/locale/pt_BR/LC_MESSAGES/RIDE.mo
Binary file not shown.
101 changes: 95 additions & 6 deletions src/robotide/locale/pt_BR/LC_MESSAGES/RIDE.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: RIDE 2.1\n"
"POT-Creation-Date: 2024-01-01 19:29+0000\n"
"POT-Creation-Date: 2024-01-04 00:42+0000\n"
"PO-Revision-Date: 2024-01-01 19:49+0000\n"
"Last-Translator: Hélio Guilherme <[email protected]>\n"
"Language-Team: [email protected]\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
"X-Crowdin-Language: pt-BR\n"
"X-Crowdin-File: RIDE.pot\n"
"X-Crowdin-File-ID: 2\n"
"X-Generator: Poedit 3.4.1\n"
"X-Generator: Poedit 3.4.2\n"

#: /home/helio/github/RIDE/src/robotide/application/application.py:383
msgid "Found Robot Framework version %s from %s."
Expand Down Expand Up @@ -1044,6 +1044,9 @@ msgid "Documentation"
msgstr "Documentação"

#: /home/helio/github/RIDE/src/robotide/run/configmanagerui.py:101
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:75
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:77
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:226
#: /home/helio/github/RIDE/src/robotide/ui/keywordsearch.py:352
msgid "Name"
msgstr "Nome"
Expand Down Expand Up @@ -1164,6 +1167,7 @@ msgid "Help"
msgstr "Ajuda"

#: /home/helio/github/RIDE/src/robotide/ui/actiontriggers.py:54
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:93
#: /home/helio/github/RIDE/src/robotide/ui/review.py:140
msgid "File"
msgstr "Arquivo"
Expand All @@ -1172,6 +1176,91 @@ msgstr "Arquivo"
msgid "&Help"
msgstr "&Ajuda"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:93
msgid "Type"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:93
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:160
msgid "Directory"
msgstr "Diretoria"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:100
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:198
msgid "New Resource File"
msgstr "Novo Arquivo de Recursos"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:102
#: /home/helio/github/RIDE/src/robotide/ui/preview.py:116
msgid "Format"
msgstr "Formato"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:114
#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:129
#, fuzzy
msgid "Parent Directory"
msgstr "Diretoria Raiz"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:115
msgid "Choose Parent Directory"
msgstr "Escolha a Diretoria Raiz"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:132
msgid "Created Path"
msgstr "Criado o Caminho"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:185
msgid "New Project"
msgstr "Novo Projeto"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:212
msgid "Add Suite"
msgstr "Adicionar Suíte"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:236
msgid "Add Directory"
msgstr "Adicionar Diretoria"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:248
msgid "Set Data Format"
msgstr "Definir Formato dos Dados"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:272
msgid "Change recursively"
msgstr ""

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:291
msgid ""
"Provide format for initialization file in directory\n"
"\"%s\"."
msgstr ""
"Indique o formato do arquivo de inicialização na diretoria\n"
"\"%s\"."

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:305
msgid "Open"
msgstr "Abrir"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:310
msgid "Robot data (*.robot)|*.robot"
msgstr "dados de Robot (*.robot)|*.robot"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:311
msgid "Robot data (*.txt)|*.txt"
msgstr "dados de Robot (*.txt)|*.txt"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:312
msgid "Robot resource file (*.resource)|*.resource"
msgstr "arquivo Robot de recursos (*.resource)|*.resource"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:313
msgid "Robot Tab Separated data (*.tsv)|*.tsv"
msgstr "dados de Robot separados por Tabs (*.tsv)|*.tsv"

#: /home/helio/github/RIDE/src/robotide/ui/filedialogs.py:315
msgid "All files|*.*"
msgstr "Todos os arquivos|*.*"

#: /home/helio/github/RIDE/src/robotide/ui/keywordsearch.py:35
msgid "<all keywords>"
msgstr "<todas as palavras-chave>"
Expand Down Expand Up @@ -1403,10 +1492,6 @@ msgstr "Texto (Barras)"
msgid "Text (Spaces)"
msgstr "Texto (Espaços)"

#: /home/helio/github/RIDE/src/robotide/ui/preview.py:116
msgid "Format"
msgstr "Formato"

#: /home/helio/github/RIDE/src/robotide/ui/preview.py:122
msgid "Print"
msgstr "Imprimir"
Expand Down Expand Up @@ -1646,3 +1731,7 @@ msgstr "Importando Localização"
#: /home/helio/github/RIDE/src/robotide/usages/usagesdialog.py:176
msgid "Importing Name"
msgstr "Importando Nome"

#: /home/helio/github/RIDE/src/robotide/validators/__init__.py:150
msgid "%s cannot be empty"
msgstr ""
Binary file modified src/robotide/locale/pt_PT/LC_MESSAGES/RIDE.mo
Binary file not shown.
Loading

0 comments on commit e2d384f

Please sign in to comment.