Templates and Translations

I hope this is the right section for posting my question - please excuse if not.

When I want to output translatable text from a service, I inject the OCPIL10N class into my service and call return $this->l->t('Hello');
(Section l10n.html of the developer manual)
The output text can be translated in the traditional way using *.pot files.

But how do I do make a template translateable?

The preferred way of outputting text there is <?php p('Hello');?>. How does this combine with translations?

Mabe I must keep localized copies of the templates for each language? But that would be rather inconvenient in case of a design change.

Or is the preferred way to pass to the template an array of (translated) strings?

I peeked into other apps and found some do it like this <?php p($l->t('Hello')); ?>, which I probably should have guessed.

Is this the preferred way?

1 Like

Looks good.

These days we rarely have any php templates, hence I think it’s not so well documented. Most of the UI elements are now done with javascript.