aFarkas / webshim

[DEPRECATED] Webshims Lib is a modular capability-based polyfill-loading library
http://aFarkas.github.com/webshim/demos/index.html
MIT License
1.42k stars 201 forks source link

$.webshims.activeLang('fr'); #320

Closed DanielJomphe closed 10 years ago

DanielJomphe commented 10 years ago

How do you use $.webshims.activeLang('fr');?

After having loaded jQuery and modernizr, I run this on a page:

<script src="/assets/js-webshim/minified/polyfiller.js"></script>
<script>
  $.webshims.activeLang('fr');
  $.webshims.polyfill('forms forms-ext');
</script>
...
<input type="date">

Webshims definitely kicks in to help this date field work in IE 8 for example, but whatever I do, I can't ever get it to use the $.webshims.activeLang() value I setup previously. It always displays the English month names, for example, instead of the French month names.

My browser's default locale is English.

I also tried activating the Javascript console on your demo page to see if I could simply call $.webshims.activeLang('fr'); and see a result, but even there where it works in your demo, my live interactions have no impact on the demo's behavior.

aFarkas commented 10 years ago

First of all your code looks good.

For the demo page please clear your browser cache. For me it works on the demo site. Which browser are you trying? Can you please try webshims.activeLang('de');. And wich version of webshims are you using (see with webshims.version).

aFarkas commented 10 years ago

Could you also try to directly link to the french locale:

<script src="/assets/js-webshim/minified/polyfiller.js"></script>
<script src="/assets/js-webshim/minified/shims/i18n/formcfg-fr.js.js"></script>
<script>
  $.webshims.activeLang('fr');
  $.webshims.polyfill('forms forms-ext');
</script>

Note also, that I recently made some changes to locale loading. (Just in case you made an update (make sure every file is new) or you haven't loaded a stable release).

DanielJomphe commented 10 years ago

Oh, now it works (both in 'de' and in 'fr') on your demo page.

As for my page, it continues ignoring the calls.

I'm testing in Chrome 31. Webshims tells me its version is 1.11.4-RC1.

Hmmm, I'm starting to believe it's because Webshims saw Chrome supports everything correctly and thus doesn't need to polyfill anything. Look at this screenshot, doesn't it look like this is Chrome's native widget? On your demo page, the widget is clearly different.

image

Note that I also tried configuring Webshims to replaceUI and if I remember well, it didn't help. I think I'll try again, although I don't really like the idea of not using the native HTML 5 widgets when they're available. (As long as they do the job!)

DanielJomphe commented 10 years ago

Could you also try to directly link to the french locale:

I tried with the following:

<script src="/assets/js-webshim/minified/polyfiller.js"></script>
<script src="/assets/js-webshim/minified/shims/i18n/formcfg-fr.js"></script>
...

but it didn't help.

Note also, that I recently made some changes to locale loading. (Just in case you made an update (make sure every file is new) or you haven't loaded a stable release).

I downloaded the code this afternoon from this link: http://corrupt-system.de/webshims-stable.zip

DanielJomphe commented 10 years ago

OK, with replaceUI, i18n works but then my previous validators no more work, so I suppose I'll need to learn how to validate that field with Webshims.

Thank you very much for your time, aFarkas.

DanielJomphe commented 10 years ago

@aFarkas, finally, the manual loading of the l18n file is necessary in my situation! If I remove that line, it no longer works.

aFarkas commented 10 years ago

@DanielJomphe

I'm not sure, wether I understand everything correctly. Unfortunatley, you can't switch the locale of native datepickers. So if you want to change the locale you have to use replaceUI for Chrome and Safari mobile. Normally, I'm using replaceUI: true on Desktop and replaceUI: false on mobile browsers. About your validation problem. What do you have to do? Can I help. If it's not a bug just some questions, use http://stackoverflow.com/questions/tagged/webshim

DanielJomphe commented 10 years ago

aFarkas: to solve my issue, I had to use replaceUI: true and <script src="/assets/js-webshim/minified/shims/i18n/formcfg-fr.js"></script>. Without the latter, no l18n changes worked.

If you ever make it so that I no more need to manually load the l18n file(s), I would be very happy if you updated this issue to tell us of the improvement.

As for validation, I've got no issue, just work ahead of me. :)

Thanks again for your time and attention.