gadicc / meteor-messageformat

MessageFormat i18n support for Meteor, with reactive templates
55 stars 22 forks source link

Intl polyfill #163

Open gadicc opened 9 years ago

gadicc commented 9 years ago

In v2 we handle date/number/currency formatting, but it relies on native browser support. mf should provide a polyfill to be used by older browsers.

miri-am commented 8 years ago

+1 plurals not working in safari

gadicc commented 8 years ago

Can you try msgfmt:core@2.0.0-preview.21 and confirm if it fixes this?

From the updated README:

Intl polyfill

In v2 we handle date/number/currency formatting, but it relies on native browser support. We rely on the Intl polyfill served via cdn.polyfill.io to provide this support in earlier browsers, requesting all the locales you currently offer. (No, we don't lazy load locales for the polyfill)

This results in an extra external request to the CDN on each initial page load. polyfill.io is served from the fastly world-wide CDN, and looks at the browser's user-agent to only send the polyfill if needed. However, if the extra request bothers you, you can turn it off with:

msgfmt.init('en', {
  disableIntlPolyfill: true
});
miri-am commented 8 years ago

Wow. Thanks! Works in Safari browser, did not test in cordova so far, but will report later.

gadicc commented 8 years ago

Awesome, thanks, been wanting to close this for a while, thanks for the nudge :>

miri-am commented 8 years ago

seems to be working in cordova/ios as well. Think this cone can be closed :)

gadicc commented 8 years ago

Amazing! Thanks for reporting back. One more milestone done.

miri-am commented 8 years ago

@gadicc Somehow I am now receiving a Injected object was undefined, this is most likely a Cordova session in my xcode log when running via meteor run ios-device. This causes Intl to be unavailable. I fixed this temporarily by adding <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.de,Intl.~locale.en"></script> to the <head>.

Any idea?

gadicc commented 8 years ago

I don't use Cordova but I understood from other users that this kind of issue can be fixed with the instructions at https://github.com/gadicc/meteor-messageformat#cordova.

miri-am commented 8 years ago

I followed these instructions and Message-Format is working fine with cordova. The issue seems only to be the injection of the intl-polyfill code. I suspect this is only the case when running directly from localhost, as I am under the impression that it has worked fine before (when I used testflight and a remote server). I will test again and report back.

gadicc commented 8 years ago

No I think you're right, I'll take another look at this.