coderifous / jquery-localize

a jQuery plugin that makes it easy to internationalize your web site.
465 stars 142 forks source link

Localize not working in Cordova app on Android 6.0 #72

Closed ArkeoSupport closed 7 years ago

ArkeoSupport commented 8 years ago

I have an app that I am building using cordova, and it uses jquery localize to switch between various JSON files in order to show my pages in different languages. The functionality works fine on the web, in iOS, and in previous versions of android. But after upgrading one of my test devices to Android 6.0, the buttons to switch languages no longer work. I hooked up the phone to adb and got this output while debugging:

Here is the error that it throws when the app is first loaded:

03-14 11:51:02.702 27974-27974/? I/chromium﹕ [INFO:CONSOLE(4)] "Uncaught TypeError: Cannot read property 'replace' of undefined", source: file:///android_asset/www/app/vendor/jquery-localize-i18n/dist/jquery.localize.js (4)

And here is the error that it throws every time you click on one of the language buttons:

03-14 11:51:48.323 27974-27974/? I/chromium﹕ [INFO:CONSOLE(469)] "Uncaught TypeError: $(...).localize is not a function", source: file:///android_asset/www/app/js/arkeo-functions.js (469)

The relevant section of code that it's referencing is the LocalizeThis function from arkeo-functions.js Here it is: function localizeThis(lang) { $('#checkLang em').removeClass("fa-check"); $('#checkLang em').addClass("fa-fw"); $('.' + lang + ' em').addClass("fa-check");
$("[data-localize]").localize("i18n/site", { language: lang });
localStorage.setItem('jq-appLang', lang); } I checked and it seems that there may be one other person having this issue with the jquery.localize plugin, but it's very recent and hasn't been resolved.

Beyond this info, I'm not sure what to do. The functionality still works on the web, in iOS, and on older versions of Android. I can't for the life of me figure out what changed. After exhaustively looking into the whitelist plugin as well as content security policies, I don't think that's it at all.

Any insights you have would be super helpful.

shaolin405mi16 commented 8 years ago

How about this? https://github.com/coderifous/jquery-localize/pull/74

ArkeoSupport commented 8 years ago

Yes, your solution worked! Thanks so much for finding a fix!

coderifous commented 7 years ago

Fix merged.