Skip to content

Commit

Permalink
Don't require translations to be in title case.
Browse files Browse the repository at this point in the history
This was already done with settings earlier but now also header and
BDD prefix translations can be specified in any case. Fixes #4411.
  • Loading branch information
pekkaklarck committed Jul 19, 2022
1 parent 4e22658 commit 82d428c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
12 changes: 6 additions & 6 deletions atest/testdata/parsing/translations/custom/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@


class Custom(Language):
setting_headers = {'H 1'}
variable_headers = {'H 2'}
test_case_headers = {'H 3'}
task_headers = {'H 4'}
keyword_headers = {'H 5'}
comment_headers = {'H 6'}
setting_headers = {'H S'}
variable_headers = {'H v'}
test_case_headers = {'h te'}
task_headers = {'H Ta'}
keyword_headers = {'H k'}
comment_headers = {'h C'}
library = 'L'
resource = 'R'
variables = 'V'
Expand Down
6 changes: 3 additions & 3 deletions atest/testdata/parsing/translations/custom/resource.resource
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*** h 1 ***
*** h s ***
D Example documentation.

*** h 2 ***
*** H V ***
${RESOURCE FILE} variable in resource file

*** h 5 ***
*** H k ***
Keyword In Resource
No Operation
6 changes: 3 additions & 3 deletions atest/testdata/parsing/translations/custom/tasks.robot
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
*** H 1 ***
*** h s ***
Ta S Task Setup
Ta Tea Task Teardown
ta tem Task Template
TA TI 1 minute
Ta Ta task tags

*** h 4 ***
*** h ta ***
Task without settings
Nothing to see here

Expand All @@ -18,7 +18,7 @@ Task with settings
[Ti] NONE
Log Nothing to see here

*** H 5 ***
*** H K ***
Task Setup
No Operation

Expand Down
10 changes: 5 additions & 5 deletions atest/testdata/parsing/translations/custom/tests.robot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*** H 1 ***
*** H S ***
D Suite documentation.
M Metadata Value
S S Suite Setup
Expand All @@ -13,10 +13,10 @@ L OperatingSystem
R resource.resource
V ../../variables.py

*** H 2 ***
*** h v ***
${VARIABLE} variable value

*** H 3 ***
*** H TE ***
Test without settings
Nothing to see here

Expand All @@ -29,7 +29,7 @@ Test with settings
[ti] NONE
Keyword ${VARIABLE}

*** H 5 ***
*** h K ***
Suite Setup
Directory Should Exist ${CURDIR}

Expand All @@ -56,5 +56,5 @@ Keyword
Should Be Equal ${arg} ${VARIABLE}
[TEA] No Operation

*** H 6 ***
*** H C ***
Ignored comments.
21 changes: 11 additions & 10 deletions src/robot/conf/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ def __init__(self, languages):
self.settings = {}
self.bdd_prefixes = set()
for lang in self.languages:
self.setting_headers |= lang.setting_headers
self.variable_headers |= lang.variable_headers
self.test_case_headers |= lang.test_case_headers
self.task_headers |= lang.task_headers
self.keyword_headers |= lang.keyword_headers
self.comment_headers |= lang.comment_headers
self.settings.update(lang.settings)
self.bdd_prefixes |= lang.bdd_prefixes
self.setting_headers |= {h.title() for h in lang.setting_headers}
self.variable_headers |= {h.title() for h in lang.variable_headers}
self.test_case_headers |= {h.title() for h in lang.test_case_headers}
self.task_headers |= {h.title() for h in lang.task_headers}
self.keyword_headers |= {h.title() for h in lang.keyword_headers}
self.comment_headers |= {h.title() for h in lang.comment_headers}
self.settings.update(
{name.title(): lang.settings[name] for name in lang.settings if name}
)
self.bdd_prefixes |= {p.title() for p in lang.bdd_prefixes}

def _get_languages(self, languages):
languages = self._resolve_languages(languages)
Expand Down Expand Up @@ -113,7 +115,7 @@ class Language:

@property
def settings(self):
settings = {
return {
self.library: En.library,
self.resource: En.resource,
self.variables: En.variables,
Expand All @@ -139,7 +141,6 @@ def settings(self):
self.timeout: En.timeout,
self.arguments: En.arguments,
}
return {name.title(): settings[name] for name in settings if name}


class En(Language):
Expand Down

0 comments on commit 82d428c

Please sign in to comment.