Some strings still cannot be translated. The string is not found in the translation catalog.
[Update by @eternoendless]
When the wording you're trying to translate is NOT present in a template within that theme, then it may not show up in the translation interface.
https://github.com/PrestaShop/PrestaShop/issues/15075#issuecomment-523841355
Example
"Guest order tracking" - Shop.Theme.Checkout
Setup
Install some other template, like classic-rocket.
Prestashop 1.7.6
Hi @Hlavtox,
Does your new theme inherit the classic theme provided by Prestashop?
@mariem-abid I don't know. It's the classic-rocket theme from your repository.
@Hlavtox that's tiny bug... try to translate Wordpress plugin! xDDDDDDDDDDDDDDDD
Hi @Hlavtox,
Thank you to specify us in which file you put this translation?
@mariem-abid I try to edit the translation normally via backoffice.
@PrestaShark Wordpress translations require Poedit, but never had a problem :D The same with Prestashop 1.6. Everything worked beautifully. You just added a string anywhere and it instantly popped in translations ready to be translated. Every theme, every module, no problems.
Hi @Hlavtox,
I did not manage to reproduce the issue with the last version PS 1.7.6.0
I attached a video record.
https://drive.google.com/file/d/1_rK3FgE1BHpToDruechEt6bmbjuzupcg/view
Thanks for check and feedback.
@mariem-abid
It seems it doesn't work for all strings that are passed to the template as a variable.
@Hlavtox, can you tell us the language selected at the installation of your shop?
@mariem-abid Czech
I cannot translate
$this->getTranslator()->trans('Search results', array(), 'Shop.Theme.Catalog'); from SearchController
$this->getTranslator()->trans('Guest order tracking', array(), 'Shop.Theme.Checkout'), from GuestTrackingController
and other strings like that.
Other strings, that are called from the TPL, I can translate just fine. Like To track your order, please enter the following information:
The same goes for custom strings in TPL. I just add a new string to the TPL and it instantly pops up in BO > Translations > Theme.
I tried to add the translation to the database manually, but it doesnt work and still shows the default string.
@eternoendless Is this related with your PR with module translations or a separate problem?
Maybe you could have a look on it when you are on it 🙃
@Hlavtox, in which exact page, this expression is displayed "Výsledek hledání'" ("Search results")?
Do you want to translate the Back office in this case? (the classic theme is used or the classic rocket theme?)
Thanks!
@khouloudbelguith
I said everything before.
I am translating a theme, normally, via Translations page in BO.
Theme used is classic-rocket (I provided a link). I cannot translate all strings that are passed to the template from controller layer. Examples provided before.
If the translation is called from the TPL, it works. Even for a custom new string, which is not in the xlf.
Read my previous comments. I even tried to add it to the database manually and it doesnt work, it doesnt load the string in FO.
@Hlavtox, I attached a video record
https://drive.google.com/file/d/1TctfIGyFJYNJh9inpB-hFNPNXk-fJL25/view
Thanks to check & feedback
Once again, for a third time.
Try to translate A STRING THAT IS CALLED FROM A CONTROLLER.
For example. Try to translate items in product-list sorting options. Or the strings I explicitly said above. Try to translate “Výsledek vyhledávání” from search results page and will not work.
@Hlavtox, thanks for these clarifications.
I tried with this expression VÝSLEDEK HLEDÁNÍ
doesn't exist.
https://drive.google.com/file/d/140bt9ITsH3osCSuWEPfavOD-eKT2CXVk/view
I tried with this expression: Guest order tracking
, it is displayed into Shop > Theme > Customeraccount
and not into Shop.Theme.Checkout
& it is well translated.
https://drive.google.com/file/d/1VzxsoxFvkxgzJF5udybIAniynJNMwXWf/view
PS: I installed PS1.7.6.0 with Čeština (Czech) language.
Thanks!
@khouloudbelguith
Yes, but Guest order tracking
from Shop.Theme.Customeraccount
is a different string which is working. The one from Shop.Theme.Checkout
is not working.
Now try to translate for example this items:
Or, try to go to Brands page (/znacky) and try to translate page title or the breadcrumb, will not work.
Tell some of your developers and they will know what I am talking about.
@Hlavtox,
This expression Důležitost
doesn't exist & the expression ZNAČKY
is well translated.
I attached a screen record
https://drive.google.com/file/d/1YyigFbav0BdjOytNZ-u2njoxmz2CcETU/view
Thanks!
Hi @Hlavtox
If the wording you're trying to translate is NOT present in a template within that theme, then it may not show up in the translation interface.
Theme translation currently works by analyzing the theme's code and pulling out the translations it uses. So only the wordings that appear somewhere in the theme's templates show up on the interface. This means that if the theme inherits templates through the parent-child theme feature, or if it uses core wordings, then those wordings may not be translatable through the interface, because they won't show up there when translating said theme, and translations performed on the classic theme won't be applied to other themes.
Fortunately, there's a workaround for this. If the wordings you want to translate appear on the classic theme translations then you can translate them there, then modify them on the database in the ps_translation
table so that the theme
field is set to your theme instead of "classic". You'll have to clear the cache afterwards.
Sorry about this mess. The translation interface must be refactored in 1.7.7 because currently it's needlessly complex and bug-prone.
@eternoendless
I tried to do the workaround, see my previous comments, but the translation is not loaded from some reason. See, I have correct wording, correct domain, correct theme name.
I am using classic-rocket template, renamed to “trendo” (our company name).
As you say, all strings, even new ones, which are present in the templates are loaded and recognized correctly, can be translated and are working.
But the strings, that are passed to the template as variables, cannot be translated, nor loaded after manual insertion to the translation table.
That's weird. Try manually removing the translator cache in var/cache/dev/translations
or var/cache/prod/translations
.
If this doesn't work it may be related to the theme not having been renamed properly. Try dumping the content of Context::getContext()->shop->theme->getName()
. Is it "trendo"? Does it match the theme name on ps_translation
exactly?
Do you find the expected wordings when you run this SQL? (replace <your_language_id>
with your language id)
SELECT `key`, `translation`, `domain`
FROM `ps_translation`
WHERE `id_lang` = <your_language_id>
AND theme = 'trendo'
@eternoendless WORKS!!!!!
You must manually empty the cache folder and the translation gets loaded from the database.
Cache clearing doesn't work, but apparently no one cares... :-) #14611 closed
Awesome news!
@eternoendless @khouloudbelguith
Hi guys, tried with 1.7.6.1 and still the same.
Just to clarify:
Hi @Hlavtox,
This issue is not fixed yet.
It is still open & it is added to our bug roadmap.
Thanks!
Should be fixed by #19487
@eternoendless @khouloudbelguith All of this is fixed in 1.7.7! 🚀 Tested strings in breadcrumbs and other fields that didn!t work. All is good, awesome!
Most helpful comment
@eternoendless WORKS!!!!!
You must manually empty the cache folder and the translation gets loaded from the database.
Cache clearing doesn't work, but apparently no one cares... :-) #14611 closed