Skip to content

Conversation

@antagoony
Copy link
Contributor

@antagoony antagoony commented Nov 29, 2025

🤔 What's changed?

Following the discussion of Getting knowledge about the current Locale within any custom @DefaultParameterTransformer I think this is the best solution to propose. It simply adds a getter-method to the current language value for Scenario (and necessarily for TestCase and TestCaseState). Doing so, any glue code class can provide a simple @Before method including a Scenario argument, and by this get access to the current language. In result, any transformer method (either @DefaultParameterTransformer, @DefaultDataTableEntryTransformer, @DefaultDataTableCellTransformer) or type method (@ParameterType, @DataTableType) can provide locale-aware behaviour. (An example is given within this comment.)

⚡️ What's your motivation?

See issue "Getting knowledge about the current Locale within any custom @DefaultParameterTransformer" (cucumber/cucumber-expressions#376).

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

Please let me know, if you want me to add some documentation into section "Default Transformers" and/or section "Parameter Type" giving an example of a locale-aware type transform.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.
@mpkorstanje mpkorstanje changed the title Adding a Scenario Language-Getter Add Scenario.getLanguage() Dec 1, 2025
@mpkorstanje mpkorstanje merged commit 1596373 into cucumber:main Dec 1, 2025
5 of 6 checks passed
@mpkorstanje
Copy link
Contributor

Oh this is a really elegant solution! Cheers!

Please let me know, if you want me to add some documentation into section "Default Transformers" and/or section "Parameter Type" giving an example of a locale-aware type transform.

That would be appreciated! Please do so on a separate pull request.

@antagoony antagoony deleted the feature/scenario-language-getter branch December 1, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants