Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Translator] Empty string #33427

Copy link
Copy link
Closed
Closed
Copy link
@sylfabre

Description

@sylfabre
Issue body actions

Symfony version(s) affected: 4.3.4

Description
We have a service that calls the translator with dynamically created key and we sometimes have to use empty strings (or the translator will return the key if the key is not found in the translation file).

But using an empty string throws an exception as per https://bugs.php.net/bug.php?id=78484

How to reproduce

# test+intl-icu.yaml
empty: ''
$translator->trans('fr_FR', 'empty', 'test');

Root cause to reproduce the IntlException: Constructor failed exception

new MessageFormatter('fr_FR', '');

Possible Solution
I don't know if the PHP core team plans to change this behavior but it can easily worked around in Symfony\Component\Translation\Translator::trans(): if $catalogue->get($id, $domain) returns an empty string then just return an empty string instead of calling $this->formatter->formatIntl() or $this->formatter->format().

I can submit a PR is needed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.