Skip to content

[Translation] Unable to replace Translator class #17957

@althaus

Description

@althaus

Hey,

as we're using Gettext for a project I tried to replace the default Translator class to solve our issues with constraint localization. With Gettext we don't need all the good stuff from the default service. So I wrote a class implementing the Symfony\Component\Translation\TranslatorInterface and configured the app to use it instead of the default:

parameters:
    translator.class: Acme\HelloBundle\Translation\GettextTranslator

Now PHP dies with a missing method error:

Fatal error: Call to undefined method Acme\HelloBundle\Translation\GettextTranslator::setFallbackLocales()

This probably happens due to the app config:

framework:
    translator: { fallback: "en" }

... but removing the fallback setting doesn't fix the issue. For me this is somehow inconsistent. Isn't the interface definition incorrect that way? Do I miss something? The method is called in the dumped cache files at getTranslator_DefaultService.

Edit: Working around that issue leads to a missing TranslatorBagInterface as a complaint from the DataCollector. :(

Cheers
Matthias

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