Luca Reghellin
Luca Reghellin

Reputation: 8101

how to use translations in prestashop controllers?

normally templates have a smarty function like this: {l s="string"} while modules just use $this->l('string');. On controllers the l() function seems not to be available, so qhat if I want to set up some text to be translated from backoffice?

Upvotes: 2

Views: 3402

Answers (2)

madeye
madeye

Reputation: 1406

It is available in controllers You just need to add module object in play.

You should do this

$this->module->l('Your string to translate', 'file_name');

For example if you are in validation.php your 'file_name' should be just 'validation'

So full example looks like this

$this->module->l('Your string to translate', 'validation');

Upvotes: 3

Serge P
Serge P

Reputation: 1863

in both cases there is used methods from class Translate e.g. for module translations Translate::getModuleTranslation(...), you can check classes/Transalte.php and find there static method getAdminTranslation(...) and in AdminController child classes available l() method that use it.

Upvotes: 0

Related Questions