Skip to content

Update languages.py - #5341

Merged
pekkaklarck merged 1 commit into
robotframework:masterfrom
orenault:fix-5150-5340
Mar 7, 2025
Merged

pekkaklarck merged 1 commit into
robotframework:masterfrom
orenault:fix-5150-5340

Conversation

@orenault

Copy link
Copy Markdown
Contributor

Fix bug on BDD prefix matching failure and add some Gherkin prefix for french localization.

Fixes #5150 (add French Gherkin Localization)
Fixes #5340 (fix bug on bdd prefix matching)

Fix bug on BDD prefix matching failure and add some Gherkin prefix for french localization

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good. Changes aren't exactly related, so it would be better to have separate PRs. Because changes are so simple, splitting the PR now doesn't have any real benefits, though.

See the inline comments for few other notes. I can fix those issues myself as well if needed.

then_prefixes = ['Alors']
and_prefixes = ['Et']
but_prefixes = ['Mais']
given_prefixes = ['Étant donné', 'Étant donné que', "Étant donné qu'", 'Soit', 'Sachant que', "Sachant qu'", 'Sachant', 'Etant donné', 'Etant donné que', "Etant donné qu'", 'Etant donnée', 'Etant données']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this to max 88 chars.

self._bdd_prefix_regexp = re.compile(rf'({prefixes})\s', re.IGNORECASE)
prefixes = sorted(self.bdd_prefixes, key=len, reverse=True)
pattern = '|'.join(prefix.replace(' ', r'\s') for prefix in prefixes).lower()
self._bdd_prefix_regexp = re.compile(rf'({pattern})\s', re.IGNORECASE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add a unit test for this fix in utest/api/test_languages.py .

@pekkaklarck
pekkaklarck merged commit 341ae48 into robotframework:master Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BDD prefixes with same beginning are not handled properly Enhance BDD support (GIVEN/WHEN/THEN) for French language

2 participants