Jump to content

Module does not detect Back-Office Language


smark04

Recommended Posts

Hello all,

 

I have created a fully functioning Module for PrestaShop 1.4.7.0.

 

I have externalized all strings as per the Developer Guide and translated the strings in the Tools > Translations > Translation of Installed Modules > Country Flag section.

 

I addressed an issue whereby my translations were not being saved when i pressed the update button and now I have a de.php file with all the translations in place.

 

On the Front-Office side my translated strings in the .tpl are functioning perfectly.

 

I have created an admin user with German as the default language and logged in. The PrestaShop interface displays in German as expected. However, on the Module tab, my Module name/description is not translated. What's more, when i have installed my Module, none of the module content appears translated either.

 

- It has been externalized and translated

- The de.php is present.

- I have tried setting the locale in the browser to de_DE

- I have cleared the cache

- I have uninstalled and re-installed the Module

 

Do I need to make an addition to my code to detect and set the language or is this implemented in PrestShop?

 

Any help would be greatly appreciated.

 

Thanks in advance,

Steven

Link to comment
Share on other sites

When i start developing modules i've got the same issue. The solution - for me - is in apostrophe sign in $this->l("sample text here");

as you see - I use " - its wrong! you must always use ' sign like here: $this->l('sample text here');

 

I do not know if this will help you - it helped me long time ago :)

maybe your problem is completely different, but just in case you can see how you implement language ($this->l) feature.

Edited by vekia (see edit history)
  • Like 1
Link to comment
Share on other sites

Thanks vekia for the speedy reply. Unfortunately I have been using the correct syntax - I have checked all instance of "$this->l" within my module source files to verify this.

 

I wish I had been doing it wrong and your suggestion had then fixed the issue :D

Link to comment
Share on other sites

I don't think my employer would approve of me sharing the source code in it's entirety. But on a personal level, I really appreciate the offer anyway, thanks! :)

 

sure, you're right. Maybe you can test module in different shops? do you tried it?

Link to comment
Share on other sites

I am running a Vanilla install of Prestashop purely for testing this module. I have tried installing it on the original VM that i cloned this one from originally (returning to the original state post-install) and my colleague has also tested it on his machine with his install of Prestashop.

 

Both attempts are giving the same issue as detailed in my first post.

Link to comment
Share on other sites

The .tpl file translates fine. It is just the .php files.

 

Here are examples of externalized strings in echo'ed paragraph and label tags:

 

echo '<p style="color:red">'.$this->l('Error adding link. Invalid URL format').' </p>';

echo '<label>'.$this->l('URL:').'</label>';

 

Here's an example in the fieldsDisplay for a column heading in a results table:

 

 

$this->fieldsDisplay = array(

'product_id' => array(

'title' => $this->l('Product ID'),

'align' => 'center',

'width' => 25),

);

 

The syntax looks OK to me and it displays correctly in English in the build as well as showing up as externalized on the BO Translation screen. I can also update the translation changes, generating the necessary de.php. The colour coding in my editor (Notepad++) doesn't indicate unclosed tags, brackets, quotes or apostrophes anywhere.

 

I think I'm going to come back at this with fresh eyes tomorrow.... before I lose my hair today ;)

Edited by smark04 (see edit history)
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...