t() function - get specific language As twig does render templates in the UI language instead of the content language, all the t() functions deliver the default language. In my case this is wrong as the ui language is german but the content language can vary.

Can I tell the t() function to deliver the translation for Spanish for example?
You can choose the target language, see more information in the API. 

In code it would look like this.

$variables['string_in_spanish'] = t(
  'Hello World',
  [], // (The args in the string)
  ['langcode' =&gt; 'es'] //  The options
);


note that when using the t() function, the source language has to be English.