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

Open
hmpf opened this Issue Sep 6, 2016 · 2 comments

Comments

4 participants
@hmpf
Contributor

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

@hmpf

This comment has been minimized.

Contributor

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.

@jaimeperez

This comment has been minimized.

Member

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

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