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

Get rid of Translate->getPreferredTranslation() #460

hmpf opened this issue Sep 6, 2016 · 3 comments

Get rid of Translate->getPreferredTranslation() #460

hmpf opened this issue Sep 6, 2016 · 3 comments


Copy link

@hmpf hmpf commented Sep 6, 2016

Find a way to use t() instead. For #455

@hmpf hmpf added this to the 1.15.0 milestone Sep 6, 2016
Copy link
Contributor Author

@hmpf hmpf commented Oct 28, 2016

This method receives an array of langcode => translation pairs, for some unknown tag. We will need a new version of this somewhere, for dynamically loaded translations. It is however necessary to move all uses of this out of the template and into the calling page. Make a note where doing so would be very tricky.

An alternative is to send in the array in the context, have the currently set language as a langcode in the default context, and look up the translation directly: {{ dynamicstatus[langcode] }} for instance.

Copy link

@jaimeperez jaimeperez commented Jul 19, 2017

I'd say the best option, in this case, is to have a static method somewhere (SimpleSAML\Locale\Translate, maybe?) that we can add to the Twig context as a filter, so that we can do something like:

{{ variable_holding_translations|translate }}

We could even tell the filter to default to some language:

{{ variable_holding_translations|translate('en') }}

Or we could default ourselves to some given string:

{{ variable_holding_translations|translate|default('Our preferred translation') }}
@jaimeperez jaimeperez added the started label Jul 19, 2017
@jaimeperez jaimeperez modified the milestones: v1.16, 1.15.0 Aug 3, 2017
@thijskh thijskh modified the milestones: 1.16, 1.17 May 28, 2018
@tvdijen tvdijen modified the milestones: 1.17, 1.18 Oct 11, 2018
@thijskh thijskh modified the milestones: 1.18, 2.0 Nov 20, 2018
Copy link

@tvdijen tvdijen commented Jun 13, 2019

Isn't \SimpleSAML\Locale\Translate::translateFromArray() exactly what we need? It is already available as a Twig filter..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants