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

fix Twig dynamic translation #1618

Merged
merged 2 commits into from Aug 23, 2017
Merged

fix Twig dynamic translation #1618

merged 2 commits into from Aug 23, 2017

Conversation

ghost
Copy link

@ghost ghost commented Aug 23, 2017

Here is my PR

A little for my poor english, a bit because I thought the solution was not exhaustive (the presence of the other two arguments: array_support and html_out) I hesitated to do this PR. I've done the tests I find necessary, I think it's okay 😄

Copy link
Member

@mahagr mahagr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra if.

@@ -374,6 +374,9 @@ public function translate($args, array $languages = null, $array_support = false
{
if (is_array($args)) {
$lookup = array_shift($args);
if (is_array($args)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$args is still an array, no need to check it again.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, in fact, just the one line with array_shift

Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right?

@rhukster rhukster merged commit 7a7ffd3 into getgrav:develop Aug 23, 2017
@rhukster
Copy link
Member

thanks

@ghost ghost deleted the fix_Twig_dynamic_translation branch August 24, 2017 06:29
@ghost
Copy link
Author

ghost commented Aug 24, 2017

Thank you all

rhukster added a commit that referenced this pull request Aug 28, 2017
rhukster added a commit that referenced this pull request Aug 28, 2017
This addresses issues with the PR.  It uses a new twig filter that gives full access to the langauges->translate() function.
@rhukster
Copy link
Member

Actually I had to revert this as it broke sprintf style text replacement in translations. I've created a new twig filter/function that will allow you to do translations in other languages:

getgrav/grav-learn@95507f1

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

Successfully merging this pull request may close these issues.

2 participants