concretecms-community-store / community_store

An open, free and community developed eCommerce system for Concrete CMS
https://concretecms-community-store.github.io/community_store/
MIT License
105 stars 66 forks source link

Single quote in some translations cause an error in JS and break some functionalities #882

Open cedric-ES opened 3 months ago

cedric-ES commented 3 months ago

Hello,

Some t() functions, used for translation, are embedded in Javascript code. But some translations have a single quote. Those translations cause an error and break the functionality because words after the single quote are interpreted by JS. That happens in some block edit or some store functionalities in dashboard pages.

I'm facing that in french translations (but can exist in other translations too).

Some examples locations :

$('#availableatts a').click(function (e) {
            e.preventDefault();

            var newitem = '<li data-id="' + $(this).data('id') + '" class="clearfix list-group-item"><a href="#" class="attremove pull-right float-end">&nbsp;&nbsp;<i class="fa fa-times"></i></a><i class="fa fa-arrows-v fa-arrows-alt-v"></i>&nbsp;&nbsp;' + $(this).text();
                if($(this).data('type')==='attr') {
                    newitem += '<select class="form-control form-select input-sm pull-right float-end mb-2" name="invalidHiding[]"><option value="disable">désactiver si invalide</option><option value="hide">cacher si invalide</option></select>';
                    newitem += '<select class="form-control form-select input-sm pull-right float-end mb-2" name="matchingType[]"><option value="or">correspond à n'importe quel</option><option value="and">correspond à tout</option></select>';
                }
Mesuva commented 3 months ago

Thanks for this, I've pushed up a few fixes for this in https://github.com/concretecms-community-store/community_store/commit/025124c75b4d7f3216b92ada59c668d8ae2666d0

You might want to apply them manually to test. Let me know if I've missed anywhere else.

cedric-ES commented 3 months ago

Thanks Ryan for this fast commit. It seems OK to me reading the code but I'll test that and tell you if I find another code to fix.

cedric-ES commented 3 months ago

Another :

https://github.com/concretecms-community-store/community_store/blob/025124c75b4d7f3216b92ada59c668d8ae2666d0/single_pages/dashboard/store/products.php#L1208

Real origin : https://github.com/concretecms-community-store/community_store/blob/025124c75b4d7f3216b92ada59c668d8ae2666d0/single_pages/dashboard/store/products.php#L1150

Mesuva commented 3 months ago

Ah cheers for that - I've pushed up https://github.com/concretecms-community-store/community_store/commit/a56d90b8358f7fb1efe62a5d258488c61bb60959

cedric-ES commented 3 months ago

Thanks, I've tested this fix too. Looks good.