Prestashop: Translation not display if we add new line in string Module class l() function

Created on 30 Nov 2018  路  13Comments  路  Source: PrestaShop/PrestaShop

Describe the bug
If we add a new line to the l() function like
$this->l(
'This is a test translation'
);
a function can have arguments with a single line with the PSR-2 standard.

Then,
It will not display in Module back-office translation page, see screenshot.

Why we need a new line?
Because if we want to fix 120 line PSR-2 issues sometimes it helps.

Screenshots
download 13

Fix line Code
This is because of this regex which excluding \n newline string,
https://github.com/PrestaShop/PrestaShop/blob/develop/controllers/admin/AdminTranslationsController.php#L1268

Additionnal information
PrestaShop version: V1.6.x.x, V1.7.x.x and also in V1.7.5.0 beta
PHP version: 7

1.7.4.4 1.7.5.0 1.7.6.0 BO Bug Fixed Minor Modules Translations waiting for dev

All 13 comments

Hi @dheerajwebkul,

This issue should be fixed by this PR: https://github.com/PrestaShop/PrestaShop/pull/11345.
It is fixed in the next stable version 1.7.5.0.
Thanks to check & feedback.
For more details about the translation system in Prestashop, you can follow this link
Thanks!

@khouloudbelguith thanks,
But are you sure this fix for the third party module translations? because PrestaShop module translation and third-party module translation have a different way to translate.

@dheerajwebkul, public PrestaShop 1.7.x nightly builds are available! This way, it should be easier for anyone who wants to contribute to the project to work with a recent build. Also, it means that merged pull requests will be in a build the next day for testing.
So, you can check if this issue occurs with the last prestashop-core-nightly.
THanks!

Hi @dheerajwebkul,

Any news about your issue?
The last version PS1.7.5.0 is released, did you check your issue with PS1.7.5.0?
Thanks!

Hello @khouloudbelguith

A very Happy New Year...

Yes, I checked this on PrestaShop V1.7.5.0. this issue is still in this version.
You can check this normally as I explained.

Thanks,

Hi @dheerajwebkul,

Happy New Year, wish you all the best.
I did not manage to reproduce the issue with PS1.7.5.0, I tried with this module
translationbug.zip
It is fixed with this PR: https://github.com/PrestaShop/PrestaShop/pull/10735
Thanks to check & feedback.

Hello @khouloudbelguith

Your translatiobug module does not have condition to produce this issue.
Please upload this

translationbug.zip

module. where I have added $this->displayName translatable text with a new line and 'bla bla bla' with a new line. Now you can not see these text in the International->translation page while translating this module.

Thanks,

@khouloudbelguith

PR: #10735 is totally different with this issue.

Hi @dheerajwebkul,

Thanks for this clarifications.
I manage to reproduce the issue with PS1.7.5.0 & PS1.7.4.4.
When we have $this->l(' ') translatable text with a new line we will can not see these text in the International->translation page.
We will see how to fix it.
Thanks!

Hi @dheerajwebkul

This can be considered fixed as of 1.7.6.0 thanks to #13504, but keep in mind that you will have to update your module to opt-in to the new translator (read the Pull Request description)

Was this page helpful?
0 / 5 - 0 ratings