idea-php-symfony2-plugin
idea-php-symfony2-plugin copied to clipboard
[FeatureRequest] Allow setting a specific domain for #TranslationKey
Hi,
first up: thanks for your great plugin.
When building a generic, but scoped translator, like this one, that automatically translates all messages in the backend
domain:
use Symfony\Contracts\Translation\TranslatorInterface;
class BackendTranslator
{
private $translator;
public function __construct (TranslatorInterface $translator)
{
$this->translator = $translator;
}
public function trans (string $id, array $parameters = [], ?string $locale = null) : string
{
return $this->translator->trans($id, $parameters, "backend", $locale);
}
}
it would be great if the method parameter via hashtags could support setting a (static) domain as well, something like:
/**
* Translates the given message as backend text.
*
* @param $id #TranslationKey@backend
* @param array $parameters
* @param null $locale
*
* @return string
*/
public function trans (string $id, array $parameters = [], ?string $locale = null) : string
or something similar.
On the link you provide there's a note at the bottom of the page:
TranslationKey are filtered on a TranslationDomain parameter, when provided else fallback to
messages
You should better use defined parameter on signatures which are docblock independent
I've got no idea how to interpret this note. Anybody got an idea what this means? Is it already possible to add a domain to the #TranslationKey hash?