-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Description
given the fact that the only method defined by TranslatorInterface
allows the user to request that translation be executed using a 'default' target locale, it stands to reason that every concrete implementation of this interface has to define a default locale.
This default locale can be set up via configuration, DI injection and arbitrarily complex logic.
In some scenarios, it would be useful for end-user code, which usually has only access to a single translator instance, to be able to retrieve the current default locale without having to interact with the configuration logic.
Example
When building an app on top of an arbitrary framework based itself on symfony, it is quite common to write code that gets injected a Translator instance.
In some cases, that code will have to interact with an external system which can provide data in a locale-aware manner. Internalizing the translation of said data into the application is not desirable, as it is not in the ownership of the app itself.
In such scenario, it would be quite nice for the code to be able to do something like:
$this->getRemoteData($this->translator->getDefaultLocale();
without having to find out how the default locale is configured and managed by the specific framework in use.