Jump to content

Not all my module's Strings appear in the translations page


sari

Recommended Posts

Hi,

 

I'm developing a basic module, and trying out the translations thing.
What I don't understand is that Only on translatable field is being shown in the modules translations page. 

I have this basic module:

<?php

if (!defined('_PS_VERSION_')) {
    exit;
}

class Warranty extends Module {

    public function __construct() {
        $this->bootstrap = true;
        $this->name = "warranty";
        $this->tab = 'front_office_features';
        $this->version = '1.0';
        $this->author = 'XXX';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = array('min' => '1.5');
        parent::__construct();
        $this->displayName = $this->l("Warranty Registration");
        $this->description = $this->l("Allow your customers to register their warranty.");
        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
    }

    public function install() {
        if (!parent::install()) {
            return false;
        }
        return true;
    }
    public function uninstall() {
       if (!parent::uninstall()) {
            return false;
        }
        return true;
    }
}

?>

And a ModuleFrontController the uses this for the translatable strings:

$this->module->l("Please fill all rquired fields");

The only thing I see under "warranty" in the translations page is "Are you sure you want to uninstall?".

What am I doing wrong?

Edited by sari (see edit history)
Link to comment
Share on other sites

have you tried this instead?

$this->module->l('Please fill all rquired fields', 'name of controller');

Two things

1) use single quotes instead of double quotes

2) add the name of your controller as a second parameter.  So if the name of the modules controller is WarrantyValidationModuleFrontController, then use 'validation' as the second parameter.

  • Like 1
Link to comment
Share on other sites

Thanks, the single quote fixed it.
But I see that:
 

$this->module->l

works even without the controller name, it shows under the controller section in the Translation page, whats the purpose for the controller name?

Link to comment
Share on other sites

you need to use $this->module->l() if you are doing this from a module controller. 

 

The ModuleFrontController, FrontController, and Controller classes do not have a function named l.  So you cannot do $this->l() as it would result in a function does not exist error

Link to comment
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
×
×
  • Create New...