OFFLINE-GmbH / oc-mall-plugin

:convenience_store: E-commerce solution for October CMS
https://offline-gmbh.github.io/oc-mall-plugin
MIT License
167 stars 113 forks source link

|trans twig filter does not work #1011

Open webBook-cz opened 1 year ago

webBook-cz commented 1 year ago

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 commented 1 year ago

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

Do you see any errors? Anything in the logs?

webBook-cz commented 1 year ago

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

tobias-kuendig commented 1 year ago

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

webBook-cz commented 1 year ago

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 commented 1 year ago

Any chance to solve it?

tobias-kuendig commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Yes, exactly

On 18.05.2023 10:30, Tobias Kündig wrote:

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|?

— Reply to this email directly, view it on GitHub https://github.com/OFFLINE-GmbH/oc-mall-plugin/issues/1011#issuecomment-1552721192, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNKWV6SO2PKH2WZN7KRJZLXGXM27ANCNFSM6AAAAAAXUAZ2KQ. You are receiving this because you authored the thread.Message ID: @.***>

chocolata commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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