pytest-bdd icon indicating copy to clipboard operation
pytest-bdd copied to clipboard

pytest-bdd should be internationalized

Open jangeroo opened this issue 8 years ago • 11 comments

Cucumber, Behave, and other BDD tools allow you to write your feature files in just about whatever language you want. It would be really handy to have the ability to use keywords other than the English versions.

A useful implementation would be one that allows anyone to create a new language file. Ideally it would also comes bundled with several language files for mainstream languages (i.e. French, Spanish, German, Russian, Chinese, etc.), though this is less useful than the ability to create a new custom language file.

jangeroo avatar Apr 19 '16 17:04 jangeroo

Do you mean having possibility to translate: "Feature, Background, Scenario, Given, When, Then, And"? Can you provide some links where i can see how does it look like?

olegpidsadnyi avatar Apr 20 '16 09:04 olegpidsadnyi

Yes. That's exactly what I mean :)

Here's the wiki for this feature from the cucumber project https://github.com/cucumber/cucumber/wiki/Translations

jangeroo avatar Apr 20 '16 11:04 jangeroo

+1

gilmrjc avatar Jun 13 '16 08:06 gilmrjc

+1

zaz600 avatar Feb 11 '17 09:02 zaz600

+1

AndersonFirmino avatar May 04 '17 12:05 AndersonFirmino

the whole thing can be done just by monkeypatching those https://github.com/pytest-dev/pytest-bdd/blob/master/pytest_bdd/types.py just make sure you monkeypatch it before calling scenario function

bubenkoff avatar May 04 '17 12:05 bubenkoff

@bubenkoff Can you show me an example?

AndersonFirmino avatar May 04 '17 16:05 AndersonFirmino

in the __init__py of the tests folder:

from pytest_bdd import types

types.FEATURE = "italian feature" ....

bubenkoff avatar May 05 '17 14:05 bubenkoff

Actually, patching pytest_bdd.feature.STEP_PREFIXES would be slightly better, as you don't need to alter the types, but rather the parsing. And since a few of those translations are many-to-one-type.

e.g. according to https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin-languages.json#L1138

from pytest_bdd.feature import STEP_PREFIXES
from pytest_bdd import types

STEP_PREFIXES[:] = []  # clear existing translations to avoid conflicts.
STEP_PREFIXES.append(("Quand ", types.WHEN))
STEP_PREFIXES.append(("Lorsque ", types.WHEN))
STEP_PREFIXES.append(("Lorsqu'", types.WHEN))
...

simpoir avatar Nov 14 '17 17:11 simpoir

I have written this in the init.py file of the tests folder and I get a NoScenariosFound exception. Any idea what I did wrong?

ghost avatar Dec 10 '19 15:12 ghost

@MichielPeeters7 In the current implementation of pytest-bdd, you can't just overwrite the STEP_PREFIXES or types, because they are loaded when the plugin loads.

This issue is perhaps duplicated by #397

TheoAndersen avatar Aug 15 '21 20:08 TheoAndersen