Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed $legacyKey in buildTranslationCatalogueFromLegacyFiles() #33807

Merged
merged 1 commit into from Sep 19, 2023

Conversation

Amazzing
Copy link
Contributor

@Amazzing Amazzing commented Sep 1, 2023

Fixed $legacyKey to correctly match translations for original strings containing single quotes.

Questions Answers
Branch? 8.1.x
Description? Translations for strings with single quotes are not recognised in buildTranslationCatalogueFromLegacyFiles(). It happens because of incorrectly hashed $legacyKey. This fix ensures that $legacyKey is hashed correctly, same as in Translate::getModuleTranslation()
Type? bug fix
Category? LO
BC breaks?
Deprecations?
How to test? 1. Find a module that uses legacy translation system
2. Find a translatable text that has a single quote in it. For example $this->l('Don\'t forget to clear cache')
3. Translate that text to FR or any other language, so translation is saved in /fr.php. It doesn't matter if translation has single quotes or not
4. Check output: $container->get('prestashop.translation.external_module_provider')->setModuleName($module_name)->setLocale($locale)->getMessageCatalogue();
Fixed issue or discussion?
Related PRs
Sponsor company

Fixed $legacyKey to correctly match translations for original strings containing single quotes.
@Amazzing Amazzing requested a review from a team as a code owner September 1, 2023 16:14
@prestonBot
Copy link
Collaborator

Hi, thanks for this contribution!

I found some issues with the Pull Request description:

  • Your pull request does not seem to fix any issue, consider creating one (see note below) and linking it by writing Fixes #1234.

Would you mind having a look at it? This will help us understand how interesting your contribution is, thank you very much!

About linked issues

Please consider opening an issue before submitting a Pull Request:

  • If it's a bug fix, it helps maintainers verify that the bug is effectively due to a defect in the code, and that it hasn't been fixed already.
  • It can help trigger a discussion about the best implementation path before a single line of code is written.
  • It may lead the Core Product team to mark that issue as a priority, further attracting the maintainers' attention.

(Note: this is an automated message, but answering it will reach a real human)

@mflasquin
Copy link
Contributor

mflasquin commented Sep 1, 2023

@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label Sep 5, 2023
@kpodemski kpodemski added the Waiting for dev Status: action required, waiting for tech feedback label Sep 5, 2023
@kpodemski
Copy link
Contributor

It has to be tested by a developer. cc @PrestaShop/committers

@MatShir MatShir added this to the 8.1.2 milestone Sep 7, 2023
@nicosomb
Copy link
Contributor

nicosomb commented Sep 7, 2023

Hello @Amazzing. Could you send us a module example?

@nicosomb nicosomb added Waiting for author Status: action required, waiting for author feedback and removed Waiting for QA Status: action required, waiting for test feedback Waiting for dev Status: action required, waiting for tech feedback labels Sep 7, 2023
@kpodemski
Copy link
Contributor

@nicosomb you can use https://github.com/PrestaShop/vatnumber or any other module that uses legacy translations...

@kpodemski kpodemski added Waiting for QA Status: action required, waiting for test feedback Waiting for dev Status: action required, waiting for tech feedback and removed Waiting for author Status: action required, waiting for author feedback labels Sep 13, 2023
@M0rgan01
Copy link
Contributor

@Amazzing hello, could you provide more details for the "how to test" part?

Is there an example module available? (Other than https://github.com/PrestaShop/vatnumber, which is archived and contains nothing in /translations)
I tried it on the autoupgrade module, which has old translations, but I don't see any issues without the PR.
Should we see the result directly in the BO under International/Translations and "Modify translations" for a module?

@M0rgan01 M0rgan01 added Waiting for author Status: action required, waiting for author feedback and removed Waiting for QA Status: action required, waiting for test feedback Waiting for dev Status: action required, waiting for tech feedback labels Sep 18, 2023
@matks
Copy link
Contributor

matks commented Sep 18, 2023

@Amazzing hello, could you provide more details for the "how to test" part?

Is there an example module available? (Other than https://github.com/PrestaShop/vatnumber, which is archived and contains nothing in /translations) I tried it on the autoupgrade module, which has old translations, but I don't see any issues without the PR. Should we see the result directly in the BO under International/Translations and "Modify translations" for a module?

@Amazzing What would be really really useful would be a list of accurate steps to reproduce the problem.

Example:

  • Install prestashop 8.1.1
  • Install module [...] (please submit the module as attachment)
  • Go to backoffice page [...]
  • Do [...] in page
  • Do [...] in page
  • See [...] which is not the correct result, it should be [...] instead

😉

@Amazzing
Copy link
Contributor Author

Amazzing commented Sep 18, 2023

Actually, exact steps are listed in “How to test”.

To make it clear - the problem is not about displaying translations in FO/BO, but about the result returned by $module_provider->getMessageCatalogue();

Currently the display of legacy module translations is controlled by Translate::getModuleTranslation(). That method works independently from $module_provider->getMessageCatalogue(). I am not sure where $module_provider->getMessageCatalogue() is used. It might be planned for later use, or already is used somewhere in BO. So, this fix ensures that it returns a correct value.

You can follow those steps for better understanding:

  1. Install PS 8.1.1
  2. Add French + Some other languages
  3. Install testmodule33807.zip
  4. Review the code of the module and the file structure - You will find that module has 2 translatable strings, and translations for FR are saved in /translations/fr.php
  5. Open module configuration page. There you will find the result returned by $module_provider->getMessageCatalogue()

@prestashop-issue-bot prestashop-issue-bot bot removed Waiting for author Status: action required, waiting for author feedback labels Sep 18, 2023
@M0rgan01
Copy link
Contributor

@Amazzing Thank you for the test module as well as the additional explanations. I tested it with and without the fix, it is good for me. Thanks for the contribution 😃

@M0rgan01 M0rgan01 added the QA ✔️ Status: check done, code approved label Sep 19, 2023
@M0rgan01 M0rgan01 merged commit 114347e into PrestaShop:8.1.x Sep 19, 2023
38 checks passed
@matks
Copy link
Contributor

matks commented Sep 19, 2023

Great work @M0rgan01 and @Amazzing 😉

@kpodemski
Copy link
Contributor

thanks @Amazzing! well done 👏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.1.x Branch Bug fix Type: Bug fix QA ✔️ Status: check done, code approved
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

9 participants