Skip to content

Conversation

@carlos-granados
Copy link
Contributor

Adds a simple memory cache so that we don't have to call the trans function in the translator if we already have translated the current definition, should improve performance in the cases where steps are used many times

Fixes #1452

{
$assetsId = $suite->getName();
$pattern = $definition->getPattern();
$cacheKey = sprintf('%s|%s|%s', $assetsId, $pattern, $language ?? '');
Copy link
Member

Choose a reason for hiding this comment

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

this should use $this->translator->getLocale() as default locale, not the empty string, so that an explicit locale and the usage of the default locale with the same locale share the same cache key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout, updated

@carlos-granados carlos-granados requested a review from stof November 25, 2025 14:53
Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @carlos-granados

@carlos-granados carlos-granados merged commit 64fa3e5 into Behat:3.x Nov 26, 2025
21 checks passed
@carlos-granados carlos-granados deleted the translation-cache branch November 26, 2025 07:41
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.

Skip or improve translation process

3 participants