Permalink
Browse files

[-] CORE: Fix #PSCSX-4270, do not write empty translations

  • Loading branch information...
gRoussac committed Jan 12, 2015
1 parent eadba50 commit 9e27137fc1f1d57d4da9fc3fc1a63bba23c9a422
Showing with 6 additions and 4 deletions.
  1. +4 −4 classes/Translate.php
  2. +2 −0 controllers/admin/AdminTranslationsController.php
View
@@ -172,13 +172,13 @@ public static function getModuleTranslation($module, $string, $source, $sprintf
$default_key_file = strtolower('<{'.$name.'}prestashop>'.$file).'_'.$key;
}
if (isset($current_key_file) && isset($_MODULES[$current_key_file]))
if (isset($current_key_file) && !empty($_MODULES[$current_key_file]))
$ret = stripslashes($_MODULES[$current_key_file]);
elseif (isset($default_key_file) && isset($_MODULES[$default_key_file]))
elseif (isset($default_key_file) && !empty($_MODULES[$default_key_file]))
$ret = stripslashes($_MODULES[$default_key_file]);
elseif (isset($_MODULES[$current_key]))
elseif (!empty($_MODULES[$current_key]))
$ret = stripslashes($_MODULES[$current_key]);
elseif (isset($_MODULES[$default_key]))
elseif (!empty($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);
// if translation was not found in module, look for it in AdminController or Helpers
elseif (!empty($_LANGADM))
@@ -954,6 +954,8 @@ protected function findAndWriteTranslationsIntoFile($file_name, $files, $theme_n
if (array_key_exists($post_key, $_POST) && !in_array($pattern, $array_check_duplicate))
{
if ($_POST[$post_key] == '')
continue;
$array_check_duplicate[] = $pattern;
$str_write .= '$_MODULE['.$pattern.'] = \''.pSQL(str_replace(array("\r\n", "\r", "\n"), ' ', $_POST[$post_key])).'\';'."\n";
$this->total_expression++;

24 comments on commit 9e27137

@kpodemski

This comment has been minimized.

Show comment
Hide comment
@kpodemski

kpodemski Jan 14, 2015

Contributor

oh, this is epic fail, most of our modules has no translations now thanks to this issue :D 👎

Contributor

kpodemski replied Jan 14, 2015

oh, this is epic fail, most of our modules has no translations now thanks to this issue :D 👎

@gRoussac

This comment has been minimized.

Show comment
Hide comment
@gRoussac

gRoussac Jan 14, 2015

Contributor

Hi,

What is the issue with this ?

Thanks. Regards

Contributor

gRoussac replied Jan 14, 2015

Hi,

What is the issue with this ?

Thanks. Regards

@kpodemski

This comment has been minimized.

Show comment
Hide comment
@kpodemski

kpodemski Jan 14, 2015

Contributor

Hi,

Before this change all of non-translated modules has empty names, descriptions and other strings in {l s=''}, for example even if I have english description, on german language string shows up empty, here's example from one of my module:
https://addons.prestashop.com/upload/54b4d2f0e9c0a.png

This commit solved this issue but we need to save translations after replacing these two files. Really "fatal" error :)

Contributor

kpodemski replied Jan 14, 2015

Hi,

Before this change all of non-translated modules has empty names, descriptions and other strings in {l s=''}, for example even if I have english description, on german language string shows up empty, here's example from one of my module:
https://addons.prestashop.com/upload/54b4d2f0e9c0a.png

This commit solved this issue but we need to save translations after replacing these two files. Really "fatal" error :)

@gRoussac

This comment has been minimized.

Show comment
Hide comment
@gRoussac

gRoussac Jan 14, 2015

Contributor

Ok because you said "has no translations now", so the bug is fixed now ?

Regards

Contributor

gRoussac replied Jan 14, 2015

Ok because you said "has no translations now", so the bug is fixed now ?

Regards

@kpodemski

This comment has been minimized.

Show comment
Hide comment
@kpodemski

kpodemski Jan 14, 2015

Contributor

Yes, yes, bug is fixed thanks to these changes in this commit. Any ETA for release this to official package? 1.6.0.12?

Contributor

kpodemski replied Jan 14, 2015

Yes, yes, bug is fixed thanks to these changes in this commit. Any ETA for release this to official package? 1.6.0.12?

@gRoussac

This comment has been minimized.

Show comment
Hide comment
@gRoussac

gRoussac Jan 14, 2015

Contributor

asap !

Contributor

gRoussac replied Jan 14, 2015

asap !

@bbergmark

This comment has been minimized.

Show comment
Hide comment
@bbergmark

bbergmark Jan 17, 2015

I had the same problem for Swedish language. Partly modules were missing text and descriptions.

In my version of Prestashop the code looked slightly different, but changing the code as suggested fixed this issue for me too.

Using 1.6.0.11

bbergmark replied Jan 17, 2015

I had the same problem for Swedish language. Partly modules were missing text and descriptions.

In my version of Prestashop the code looked slightly different, but changing the code as suggested fixed this issue for me too.

Using 1.6.0.11

@ang3lx

This comment has been minimized.

Show comment
Hide comment
@ang3lx

ang3lx Jan 19, 2015

ok.. we know that is easy to fix.. but...release 1.6.0.11.1 with fix please 👍

ang3lx replied Jan 19, 2015

ok.. we know that is easy to fix.. but...release 1.6.0.11.1 with fix please 👍

@tendrecalin

This comment has been minimized.

Show comment
Hide comment
@tendrecalin

tendrecalin Jan 26, 2015

Hello,
I'm prestashop 1.6.0.11, I made the change for AdminTranslationsController.php file is OK. For Translate.php file, it affiiche on my website. Unless the file date not corecton (/ * * 2007-2014 PrestaShop * * NOTICE OF LICENSE * *) that need to change?
Best Regards.

tendrecalin replied Jan 26, 2015

Hello,
I'm prestashop 1.6.0.11, I made the change for AdminTranslationsController.php file is OK. For Translate.php file, it affiiche on my website. Unless the file date not corecton (/ * * 2007-2014 PrestaShop * * NOTICE OF LICENSE * *) that need to change?
Best Regards.

@rednoise71

This comment has been minimized.

Show comment
Hide comment
@rednoise71

rednoise71 Feb 4, 2015

Hi, I've added this code on Prestashop 1.6.0.11 (classes/Translate.php) and fix it all Front End translations...But when I go to my backend and click on Translations button it shows me a blank page!
How to solve this???

I hope your help...Thanx!

rednoise71 replied Feb 4, 2015

Hi, I've added this code on Prestashop 1.6.0.11 (classes/Translate.php) and fix it all Front End translations...But when I go to my backend and click on Translations button it shows me a blank page!
How to solve this???

I hope your help...Thanx!

@prestamodule

This comment has been minimized.

Show comment
Hide comment
@prestamodule

prestamodule Feb 5, 2015

Contributor

Hi,

This is a major issue, which prevent any addons to work correctly after a translation is made.
24 days since it has been fixed, but it should have been released for a while.

We've new customer case coming each day and we don't have any solution for them except to provide them the latest file from this repo...

Regards,

Contributor

prestamodule replied Feb 5, 2015

Hi,

This is a major issue, which prevent any addons to work correctly after a translation is made.
24 days since it has been fixed, but it should have been released for a while.

We've new customer case coming each day and we don't have any solution for them except to provide them the latest file from this repo...

Regards,

@guestisp

This comment has been minimized.

Show comment
Hide comment
@guestisp

guestisp Feb 5, 2015

Contributor

Yes, there are many issue fixed but never released in prestashop. Very strange.

Contributor

guestisp replied Feb 5, 2015

Yes, there are many issue fixed but never released in prestashop. Very strange.

@AlexGidarakos

This comment has been minimized.

Show comment
Hide comment
@AlexGidarakos

AlexGidarakos Feb 5, 2015

IMHO:

  1. This is one of the so-called "showstopper bugs"
  2. When something like this happens, PS should immediately release fixed versions with only the relevant fixes and no other unrelated patches included

AlexGidarakos replied Feb 5, 2015

IMHO:

  1. This is one of the so-called "showstopper bugs"
  2. When something like this happens, PS should immediately release fixed versions with only the relevant fixes and no other unrelated patches included
@Hrusdik

This comment has been minimized.

Show comment
Hide comment
@Hrusdik

Hrusdik Feb 5, 2015

Hi, like @turisma I am using PrestaShop 1.6.0.11, and my Translate.php has

if (isset($_MODULES[$current_key]))

instead of

if (isset($current_key_file) && isset($_MODULES[$current_key_file]))

What's the status of this ? Is there an update ? Should I just refactor my $current_key var ? Any tested solutions ?

Regards,

Hrusdik replied Feb 5, 2015

Hi, like @turisma I am using PrestaShop 1.6.0.11, and my Translate.php has

if (isset($_MODULES[$current_key]))

instead of

if (isset($current_key_file) && isset($_MODULES[$current_key_file]))

What's the status of this ? Is there an update ? Should I just refactor my $current_key var ? Any tested solutions ?

Regards,

@tendrecalin

This comment has been minimized.

Show comment
Hide comment
@tendrecalin

tendrecalin Feb 5, 2015

Hello,
For me it's résolu.J'ai fixed line (233) translate.php missing in the file. Check your file with above file. Hoping help. pascal

tendrecalin replied Feb 5, 2015

Hello,
For me it's résolu.J'ai fixed line (233) translate.php missing in the file. Check your file with above file. Hoping help. pascal

@Hrusdik

This comment has been minimized.

Show comment
Hide comment
@Hrusdik

Hrusdik Feb 5, 2015

Thanks for your help @tendrecalin but I ended up replacing the whole file Translate.php by this version of the file, like @prestamodule said, and it works perfectly.

I totally agree with you guys, this bug not being patched for so long is really weird and annoying to our customers.

Regards,

Hrusdik replied Feb 5, 2015

Thanks for your help @tendrecalin but I ended up replacing the whole file Translate.php by this version of the file, like @prestamodule said, and it works perfectly.

I totally agree with you guys, this bug not being patched for so long is really weird and annoying to our customers.

Regards,

@RazrElite

This comment has been minimized.

Show comment
Hide comment
@RazrElite

RazrElite Feb 5, 2015

Why is this not fixed yet? I've spent at least a couple of hours searching for this solution as my store was practically unusable without it.

RazrElite replied Feb 5, 2015

Why is this not fixed yet? I've spent at least a couple of hours searching for this solution as my store was practically unusable without it.

@gortnav

This comment has been minimized.

Show comment
Hide comment
@gortnav

gortnav Feb 6, 2015

Hi all,
I have to start a new project and before to decide if I will use the last version I'm searching some bugs for this version.
I haven't tested this version but I see the same differences in the files content than @turisma and @Hrusdik and I have one question: Anybody has tested if is possible to solve this bug replacing the total content of the files for the content you can find here? (all the code lines of these files, not only replace the lines are displaying here).
Regards.
Goyo.

gortnav replied Feb 6, 2015

Hi all,
I have to start a new project and before to decide if I will use the last version I'm searching some bugs for this version.
I haven't tested this version but I see the same differences in the files content than @turisma and @Hrusdik and I have one question: Anybody has tested if is possible to solve this bug replacing the total content of the files for the content you can find here? (all the code lines of these files, not only replace the lines are displaying here).
Regards.
Goyo.

@Hrusdik

This comment has been minimized.

Show comment
Hide comment
@Hrusdik

Hrusdik replied Feb 6, 2015

Hi @gortnav,

Yes, i replaced the file with the actual file version showed above (https://github.com/PrestaShop/PrestaShop/blob/9e27137fc1f1d57d4da9fc3fc1a63bba23c9a422/classes/Translate.php).

Regards,

@gortnav

This comment has been minimized.

Show comment
Hide comment
@gortnav

gortnav Feb 7, 2015

Hi @Hrusdik,
at first of this post, @gRoussac suggest to change in two files:
classes/Translate.php, and
controllers/admin/AdminTranslationsController.php

Do you change/replace the total content of these two files or only classes/Translate.php?

The information I have read about this in all the forums is:
This bug only affect if somebody is using a previous version of 1.6.0.11 and upgrade to this version.

The steps to solve the bug are:
Change the content of the files (two files how you can see before)
Logout of BackOffice
Clean cache of the browser you are using
Login one more time in BackOffice and test if the translations are running

In my case, I have a new instalation of the version 1.6.0.11 (no upgrade) and the translations are running normally for all the modules I have tested. Anyway, I have tested to replace the files you can see here and the translations, also, are running.

This is the reason because I suppose the bug is solved.

I hope to help you!!!

Regards.

gortnav replied Feb 7, 2015

Hi @Hrusdik,
at first of this post, @gRoussac suggest to change in two files:
classes/Translate.php, and
controllers/admin/AdminTranslationsController.php

Do you change/replace the total content of these two files or only classes/Translate.php?

The information I have read about this in all the forums is:
This bug only affect if somebody is using a previous version of 1.6.0.11 and upgrade to this version.

The steps to solve the bug are:
Change the content of the files (two files how you can see before)
Logout of BackOffice
Clean cache of the browser you are using
Login one more time in BackOffice and test if the translations are running

In my case, I have a new instalation of the version 1.6.0.11 (no upgrade) and the translations are running normally for all the modules I have tested. Anyway, I have tested to replace the files you can see here and the translations, also, are running.

This is the reason because I suppose the bug is solved.

I hope to help you!!!

Regards.

@Bosky-Web

This comment has been minimized.

Show comment
Hide comment
@Bosky-Web

Bosky-Web Feb 10, 2015

To repair only one file.
prestashop 1.6.0.11
classes/translate.php
line. 169

if (isset($_MODULES[$current_key]))
$ret = stripslashes($_MODULES[$current_key]);
elseif (isset($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);

replace with

if (isset($current_key) && !empty($_MODULES[$current_key]))//Bosky
$ret = stripslashes($_MODULES[$current_key]);
elseif (isset($default_key) && !empty($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);
elseif (!empty($_MODULES[$current_key]))
$ret = stripslashes($_MODULES[$current_key]);
elseif (!empty($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);

It works for me

Bosky-Web replied Feb 10, 2015

To repair only one file.
prestashop 1.6.0.11
classes/translate.php
line. 169

if (isset($_MODULES[$current_key]))
$ret = stripslashes($_MODULES[$current_key]);
elseif (isset($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);

replace with

if (isset($current_key) && !empty($_MODULES[$current_key]))//Bosky
$ret = stripslashes($_MODULES[$current_key]);
elseif (isset($default_key) && !empty($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);
elseif (!empty($_MODULES[$current_key]))
$ret = stripslashes($_MODULES[$current_key]);
elseif (!empty($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);

It works for me

@bellini13

This comment has been minimized.

Show comment
Hide comment
@bellini13

bellini13 Feb 14, 2015

Contributor

gortnav said
The information I have read about this in all the forums is:
This bug only affect if somebody is using a previous version of 1.6.0.11 and upgrade to this version.

This issue is not specific to upgrading of Prestashop. You can easily produce this issue installing a clean version of Prestashop v1.6.0.11 and then try to translate a Payment Module. If you leave a field untranslated, then the field will be blank.

Older versions of Prestashop would use the default language if a field was blank or not translated, however in PS v1.6.0.11, a blank or not translated field will remain blank.

This is particularly bad for payment modules, when the displayName is left untranslated. Since this is a required field when creating an order, you will receive the following error
"property order->payment is empty"

This is because when an order is created, the Payment Modules displayName is used as the orders payment field, which is a required field and cannot be blank.

Contributor

bellini13 replied Feb 14, 2015

gortnav said
The information I have read about this in all the forums is:
This bug only affect if somebody is using a previous version of 1.6.0.11 and upgrade to this version.

This issue is not specific to upgrading of Prestashop. You can easily produce this issue installing a clean version of Prestashop v1.6.0.11 and then try to translate a Payment Module. If you leave a field untranslated, then the field will be blank.

Older versions of Prestashop would use the default language if a field was blank or not translated, however in PS v1.6.0.11, a blank or not translated field will remain blank.

This is particularly bad for payment modules, when the displayName is left untranslated. Since this is a required field when creating an order, you will receive the following error
"property order->payment is empty"

This is because when an order is created, the Payment Modules displayName is used as the orders payment field, which is a required field and cannot be blank.

@stratboy

This comment has been minimized.

Show comment
Hide comment
@stratboy

stratboy Feb 23, 2015

Small thing: copyright dates on header comments are wrong

stratboy replied Feb 23, 2015

Small thing: copyright dates on header comments are wrong

@tomagio

This comment has been minimized.

Show comment
Hide comment
@tomagio

tomagio May 26, 2015

hi i found this thread to resolve my problem which is when i translate few things in prestashop and save, texts in modules disappear. I've copied those two files above and replaced them in my prestashop. Now i get errors. How to get back my shop?

errors in administration :
Fatal error: Class 'Translate' not found in /srv/www/stylovynakup.cz/public/www/classes/controller/AdminController.php on line 2366

error in frontend shop:
www.stylovynakup.cz

Fatal error: Class 'Translate' not found in /srv/www/stylovynakup.cz/public/www/classes/module/Module.php on line 1806

Any help guys?

tomagio replied May 26, 2015

hi i found this thread to resolve my problem which is when i translate few things in prestashop and save, texts in modules disappear. I've copied those two files above and replaced them in my prestashop. Now i get errors. How to get back my shop?

errors in administration :
Fatal error: Class 'Translate' not found in /srv/www/stylovynakup.cz/public/www/classes/controller/AdminController.php on line 2366

error in frontend shop:
www.stylovynakup.cz

Fatal error: Class 'Translate' not found in /srv/www/stylovynakup.cz/public/www/classes/module/Module.php on line 1806

Any help guys?

Please sign in to comment.