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

|trans twig filter does not work #1011

Open
webBook-cz opened this issue May 3, 2023 · 13 comments
Open

|trans twig filter does not work #1011

webBook-cz opened this issue May 3, 2023 · 13 comments

Comments

@webBook-cz
Copy link

Hi! I use translation strings in my theme (https://docs.octobercms.com/3.x/cms/themes/localization.html#localization-file-structure)
When your plugin is installed the twig filter |trans does not work anymore.

@tobias-kuendig
Copy link
Member

What does "not work anymore" mean in that case?

Do you see any errors? Anything in the logs?

@webBook-cz
Copy link
Author

No, I do not see any errors, just the text is not translated.

@tobias-kuendig
Copy link
Member

Can you share the version details of you setup? (October, Mall)

@webBook-cz
Copy link
Author

Hi Tobias!
try it here please: http://eshop.forfree.cz/backend
login: Tobias
pw: t0b145

on page http://eshop.forfree.cz/en/test are 2 translated vars waiting and client (http://eshop.forfree.cz/cs/test )
If you swich-off your plugin the page works like a charm...

@webBook-cz
Copy link
Author

Any chance to solve it?

@tobias-kuendig
Copy link
Member

tobias-kuendig commented May 15, 2023

I'd have to dig into this myself, but I currently do not have the time.

The problem probably comes from around here: https://github.com/OFFLINE-GmbH/oc-mall-plugin/blob/develop/classes/registration/BootTwig.php#L32

It probably is a RainLab.Translate 2.0 incompatibility. October does register the _ and __ filters in Version 3.0 too (in modules/system/twig/Extension.php#L93), so there might be a conflict.

Try removing the $filters variable in Mall and see if this fixes things.

@tobias-kuendig
Copy link
Member

I see that the problem occurs on your site, but I cannot reproduce it locally. Could you share your translation strings? Are they located in themes/xyz/lang/xx.json?

@webBook-cz
Copy link
Author

webBook-cz commented May 18, 2023 via email

@chocolata
Copy link
Contributor

Hi guys, just upgraded my testenvironment (October CMS v3.3.17, Mall v3.0.18, Translate v2.2.6) and am also experiencing issues with the translations. In my case the translations reside in the lang folder at root level:

image

The content of the lang.php file for example is the following:

<?php

return [
    'components.productsFilter.sortOrder.propertyValues.15' => 'Datum',
    'general_settings.catalogue' => 'Catalogus',
    'components.productsFilter.sortOrder.date' => 'Datum',
    'frontend.stock.checking' => 'Voorraad controleren...',
    'frontend.stock.available' => 'Één artikel op voorraad|:stock op voorraad',
    'stock.unavailable' => 'Geen voorraad meer',
    'stock.many_available' => 'Op voorraad',
    'common.yes' => '✔',
    'common.no' => '✘',
    'reviews.title' => 'Titel',
    'reviews.review' => 'Details',
    'reviews.pros' => 'Goede punten (een per regel)',
    'reviews.cons' => 'Slechte punten (een per regel)',
    'components.productsFilter.sortOrder.bestseller' => 'Best verkocht',
    'components.productsFilter.sortOrder.priceLow' => 'Laagste prijs',
    'components.productsFilter.sortOrder.priceHigh' => 'Hoogste prijs',
    'components.productsFilter.sortOrder.latest' => 'Meest recent',
    'components.productsFilter.sortOrder.oldest' => 'Oudste',
    'components.productsFilter.sortOrder.random' => 'Willekeurig',
    'components.productsFilter.sortOrder.manual' => 'Standaard',
    'components.productsFilter.sortOrder.name' => 'Naam',
    'components.productsFilter.sortOrder.ratings' => 'Best beoordeeld',
    'common.catalogue' => 'Aanbod',
    'common.orders' => 'Bestellingen',
    'common.discounts' => 'Kortingen',
    'common.payments' => 'Betalingen',
    'common.products' => 'Producten',
    'common.categories' => 'Categorieën',
    'common.brands' => 'Merken',
    'common.properties' => 'Eigenschappen',
    'common.services' => 'Diensten',
];

It seems like the translations are not taken into account at all and just revert to their defaults.

I understand some configuration is required after migrating to the Rainlab.Translate v2 plugin, and I think I've followed all the steps. I've set he language code of the primary site to the "nl" language code, and set the language dropdown accordingly:
image

It might not be relevant, but my back-end environment is also set to the "nl" language code.

What is the recommended way of customizing the language strings in combination with the Translate v2 plugin?

As a workaround, could we temporarily downgrade to v1.12 for example? I see that the current version of the Mall plugin required V2 of the translate plugin.

Thanks for looking into this.

@tobias-kuendig
Copy link
Member

@chocolata from the OCMS v3 Upgrade guide:

The lang directory for custom translation overrides has moved to app/lang

You have to move your lang folder in a app folder. Does the issue still persist?

https://octobercms.com/support/article/rn-30#localization-updates

@chocolata
Copy link
Contributor

Hi @tobias-kuendig , thank you for your great support as always.
I've got it working following your instructions:

I've moved the lang folder inside an app folder. And I've moved my nl folder to the lowest level of the lang folder and put the PHP language files in there and I'm glad to report that this works!

The new structure then is as follows:
image

Thank you very much as always!

@tobias-kuendig
Copy link
Member

@webBook-cz Just to be sure, this couldn't be the same problem on your side? I am still unable to reproduce the issue.

@webBook-cz
Copy link
Author

no, The traslation is in theme folder: themes/mytheme/lang/en.json - and without Mall plugin works perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants