Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow absolute messages in PrefixedTranslator using "//" #83

Closed
JanMikes opened this issue Aug 7, 2015 · 5 comments · Fixed by #93
Closed

Allow absolute messages in PrefixedTranslator using "//" #83

JanMikes opened this issue Aug 7, 2015 · 5 comments · Fixed by #93

Comments

@JanMikes
Copy link
Contributor

JanMikes commented Aug 7, 2015

This is just idea about behavior, when using prefixed translator, snippet of code will say more then 1000 words:

If you agree with this, i can send PR and cover with tests.

$prefixedTranslator = $translator->domain("some.domain");
$prefixedTranslator->translate("//namespace.xx"); // result $translator->translate("namespace.xx")

// What i have to do is:
$prefixedTranslator->unwrap()->translate("namespace.xx");

There is 1 very good usecase, i wanted to use global translation required message in config.neon:

forms:
    messages:
        FILLED: "forms.required"

But afterwards i can not use prefixed translator in forms like this:

$form->setTranslator($this->translator->domain("forms.signIn");
$input->setRequired(); // Result is $translator->translate("forms.signIn.forms.required") instead of just "form.required"
@JanMikes JanMikes changed the title Access global translator in PrefixedTranslator using "//" in message Allow absolute messages in PrefixedTranslator using "//" Aug 7, 2015
@fprochazka
Copy link
Member

I like the idea 👍

@JanMikes
Copy link
Contributor Author

Ok, i will go for it!

@JanMikes
Copy link
Contributor Author

Implemented by #88

@fprochazka
Copy link
Member

But it's not merged yet :)

@zraly
Copy link

zraly commented Jun 24, 2016

It seems, that absolute domain does not work properly, if a macro is defined later. Example:

@layout.latte:

<title>{block title}{/block}</title>

template1.latte:

{translator cup.fork /}
<h2>{block title}{_//cup.fork.header}{/block}</h2>

Translates the header right in template1.latte, but does not translate the title in @layout.latte. Debug bar says, that translation domain is //cup and keeps it untranslated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants