Skip to content

Getting knowledge about the current Locale within any custom @DefaultParameterTransformerΒ #376

@ghostcity

Description

@ghostcity

πŸ€” What's the problem you're trying to solve?

Hi, I've seen that the BuiltInParameterTransformer is instanziated during the initial ramp-up:

io.cucumber.core.runtime.Runtime#executePickle(Pickle)
calls io.cucumber.core.runner.Runner#runPickle(Pickle)
calls io.cucumber.core.runner.CachingGlue#prepareGlue(Locale)
instanciates io.cucumber.core.stepexpression.StepTypeRegistry#StepTypeRegistry(Locale)
instanciates io.cucumber.cucumberexpressions.ParameterTypeRegistry#ParameterTypeRegistry(Locale)
instanciates io.cucumber.cucumberexpressions.BuiltInParameterTransformer#BuiltInParameterTransformer(Locale)

Doing so, the BuiltInParameterTransformer is aware of the language declaration of the current Feature file, and thus can parse numbers accordingly to the English/French/German/... number delimiters etc.

In opposite, any method annotated with @DefaultParameterTransformer does not know about this current Locale. The locale information is neither injected into the transform method nor is it injected into the constructor of the class declaring the @DefaultParameterTransformer-annotated method.

In result, any custom ParameterTransformer has no chance to do a number transform (or whatever Locale aware transform) similar to what the BuiltInParameterTransformeris able to do. Actually, I do not see a chance to bring the Locale information into the custom transformation. However, I would like to add such feature -- I just don't know, what would be the preferred way.

✨ What's your proposed solution?

Can you give me a hint, where I should cache the current Feature's locale information and where this Locale should be injected into the transform process of the custom ParameterTransformer?

Giving me such a hint would help me to create an MR. (That is my proposed solution: Id like to implement that missing code and create a MR.)

Or in general, what do you think about my feature request. Is this a proper idea?

⛏ Have you considered any alternatives or workarounds?

Yes, but I do not see any proper way to gain access to the Locale that has been found within the current Pickle processed by the Cucumber-runner.

πŸ“š Any additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions