Skip to content

Replacements not working in trans_choice function #53413

@voidgraphics

Description

@voidgraphics

Laravel Version

11.30.0

PHP Version

8.3.13

Database Driver & Version

Not relevant

Description

Hello!

The recent change to the trans_choice function replacements (see PR #53331) broke replacements for the count placeholder.

When using the trans_choice function and trying to specify a replacement for :count, it is no longer applied. This worked fine before the PR mentioned above was merged.

Thanks for your consideration

Steps To Reproduce

To use the same example as the PR linked above, consider the following translation:

return [
   'greeting' => '{0} Hello|[1,*] Hello, you have :count unread messages'
];

If you try to specify a replacement for :count, it will not be used, and it will simply inject the count provided as the second parameter instead. The following code:

$count = 2;

trans_choice('general.greeting', $count, ['count' => '<strong>'.$count.'</strong>']);

used to result in the following:

Hello, you have <strong>2</strong> unread messages

and now instead results in:

Hello, you have 2 unread messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions