-
-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot format number when Intl polyfill is dynamically loaded #477
Comments
@kazupon If you approve the proposed fix, I can make the corresponding PR. |
Not sure if this is really a solution that will work for you, but I do the following:
And then I load my en fallback:
When I lazy load a new language later I use this (in a router.beforeEach):
(This is using Quasar, btw.) |
A workaround is to change values of if (!global.Intl) {
// Adding polyfill for browsers without support Intl
require.ensure([
'intl',
'intl/locale-data/jsonp/en.js',
'intl/locale-data/jsonp/ru.js'
], function (require) {
require('intl');
require('intl/locale-data/jsonp/en.js');
require('intl/locale-data/jsonp/ru.js');
VueI18n.availabilities.dateTimeFormat = VueI18n.availabilities.numberFormat = true;
...
});
} |
@kazupon has funded $20.00 to this issue. See it on IssueHunt |
@issuehuntfest has funded $20.00 to this issue. See it on IssueHunt |
@gamtiq Are you still considering to open a PR for this? |
@exoego I'm going to make a PR at this weekend. |
@gamtiq has submitted a pull request. See it on IssueHunt |
@kazupon has rewarded $28.00 to @gamtiq. See it on IssueHunt
|
vue & vue-i18n version
vue - 2.5.17
vue-i18n - 8.3.2
What is actually happening?
When browser does not support Intl API (for example, Opera 12 or browser on an old Smart TV) and Intl.js polyfill is dynamically loaded via webpack's require.ensure, vue-i18n does not format numbers because value for VueI18n.availabilities is determined once upon loading of vue-i18n which is included in vendors chunk and loaded before application code where the polyfill is requested. As a result
VueI18n.availabilities.dateTimeFormat
andVueI18n.availabilities.numberFormat
are set tofalse
and _n method always returns empty string.A possible fix is to define getter for
VueI18n.availabilities
:The text was updated successfully, but these errors were encountered: