Jump to content

Translating text in php files


umamishop
 Share

Recommended Posts

Hi,
I'm trying to translate my site, and need to change some front-office text located in a .php file. I know in a .tpl file, you use {l s='Your text' mod='yourmodulename'} and then do the translation in Tools > Translations > Module translations.

What about for .php files? How can I translate the text for these files? {l s='Your text' mod='yourmodulename'} and $this->l('Your text') don't seem to work.

Thank you.

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 7 months later...

You can add this line of code:

 

if(!$dontTranslate)

{

$this->displayName = $this->l('My module');

$this->description = $this->l('Description of my module.');

}

 

This will let the dispaly namd and description appear on the Tools > Translations > Module translations screen.

 

But what if we want to translate a text outside the constructor, is there a way?

Share this post


Link to post
Share on other sites

  • 3 years later...

Hi,

I'm trying to translate my site, and need to change some front-office text located in a .php file. I know in a .tpl file, you use {l s='Your text' mod='yourmodulename'} and then do the translation in Tools > Translations > Module translations.

 

What about for .php files? How can I translate the text for these files? {l s='Your text' mod='yourmodulename'} and $this->l('Your text') don't seem to work.

 

Thank you.

 

Hi,

Try this

 

$this->l('My string', 'filename')

 

For instance, in the /bankwire/controllers/front/validation.php file:

die($this->module->l('This payment method is not available.', 'validation'));

 

http://doc.prestashop.com/display/PS16/Module+translation

 

Edited by matin_gh (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More