Skip to content

[FeatureRequest] Allow setting a specific domain for #TranslationKey #1351

Open
@apfelbox

Description

@apfelbox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions