Prestashop: Translation is not working in a module

Created on 23 May 2019  路  11Comments  路  Source: PrestaShop/PrestaShop

Module https://github.com/friends-of-prestashop/demo-cqrs-hooks-usage-module

We can't make the translations to work.

According to this https://github.com/PrestaShop/PrestaShop/blob/develop/tests/Resources/modules/translations/src/Controller/Admin/ExempleController.php#L36

I should be able to have working translations from my module controller but they just don't work here https://github.com/friends-of-prestashop/demo-cqrs-hooks-usage-module/blob/master/src/Controller/Admin/CustomerReviewController.php#L54

But it works in Translations module

For both Translations module and my sample module the translations does not work in main module file as well https://github.com/friends-of-prestashop/demo-cqrs-hooks-usage-module/blob/master/ps_democqrshooksusage.php#L68

Bug Modules Translations

Most helpful comment

Also, remember that you have to opt-in to the new translation system if you want to be able to translate it using the BO. You need to add this to the main module file:

public function isUsingNewTranslationSystem()
{
    return true;
}

This needs to be documented

All 11 comments

@eternoendless I believe you have worked on this topic ?

This domain is wrong:

Modules.Ps_DemoCQRSHooksUsage

https://github.com/friends-of-prestashop/demo-cqrs-hooks-usage-module/blob/master/src/Controller/Admin/CustomerReviewController.php#L68

It should be:

Modules.Democqrshooksusage.Admin

or

Modules.Democqrshooksusage.Customerreviewcontroller

See: https://github.com/PrestaShop/TranslationToolsBundle/blob/master/Tests/Translation/Helper/DomainHelperTest.php#L61-L87

Also, remember that you have to opt-in to the new translation system if you want to be able to translate it using the BO. You need to add this to the main module file:

public function isUsingNewTranslationSystem()
{
    return true;
}

Also, remember that you have to opt-in to the new translation system if you want to be able to translate it using the BO. You need to add this to the main module file:

public function isUsingNewTranslationSystem()
{
    return true;
}

This needs to be documented

@matks done - yes it deserves some documentation indeed :D

@eternoendless is on a documentation killing spree 馃槃we'll close this issue when we have the docs PR

Hey, i'm currently working on a module too and i've decided it would be a good idea to go use the "new" translation system.
I have 2 questions that i'm not able to figure out by digging through the code.

1: How do i create the xlf files? Everything i've tried with ./bin/console translation:update gave me error messages.
2: I've created a xlf file by hand and placed it in ./app/Resources/translations/de-DE, cleared the cache and the translation worked. However I can't ask the users of the module to install the language files manually. Do i have to copy the language file to this location during the install routine or is there a special file structure i have to use? Everything i tried so far did not work.

we'll close this issue when we have the docs PR

Follow https://github.com/PrestaShop/docs/issues/284

@DerPapst:

How do i create the xlf files?

Unfortunately there's no way to export xlf files for modules yet. This is something that I'd like us to do in 1.7.7. My planned solution is to dump XLF files in the module's translation directory. It's not a lot of work, actually we are already doing it for themes.

Hello @eternoendless @matks I just made some improvements at this level ... could you take a look here https://github.com/PrestaShop/PrestaShop/pull/15871

@matks This has been documented here: https://devdocs.prestashop.com/1.7/modules/creation/module-translation/new-system/

Can we close this issue?

@eternoendless Yes !

Was this page helpful?
0 / 5 - 0 ratings