Comments (10)
Yes, I see this too, intermittently. I think this is a knock-on from the fix for #48 and #52 made back in February which made loading of the properties files asynchronous at all times.
A workaround for now would be to set gAsyncResourceLoading to false to load the files synchronously. You'll get a "Synchronous XMLHttpRequest" warning in Chrome, but it's only a temporary measure until there's a fix for this.
from webl10n.
Thanks :) my team member told me this workaround works for now.
from webl10n.
SIlly me. On second thoughts, this isn't a bug.
Please see the comment above gAsyncResourceLoading
in the source (which I didn't read before):
Synchronously loading l10n resources significantly minimizes flickering
from displaying the app with non-localized strings and then updating the
strings. Although this will block all script execution on this page, we
expect that the l10n resources are available locally on flash-storage.As synchronous XHR is generally considered as a bad idea, we're still
loading l10n resources asynchronously -- but we keep this in a setting,
just in case... and applications using this library should hide their
content until the `localized' event happens.
So, start your application inside of an event handler for 'localized'. In my case, I have a Backbone application using require.js, so I start my application like so:
document.addEventListener('localized', function () {
require(["app"], function (app) {
Backbone.history.start();
});
});
from webl10n.
Use .ready
instead of the event. This ensures that the callback is called even if the event has already been triggered.
document.webL10n.ready(function() {
require(['app'], function (app) { Backbone.history.start(); });
});
from webl10n.
Thanks Rob. That means this also works (which I prefer, as require is pretty fundamental to the operation of the application!)
require(["app"], function (app) {
document.webL10n.ready(function () { //wait until l10n has finished loading resources
Backbone.history.start();
});
});
from webl10n.
Hmm, I thought webL10n.ready() was working, but it seems not - I'm still seeing the "undefined" warnings from time to time. I've reverted to using the localized event.
from webl10n.
@paulguz I've submitted a patch for your issue, could you check whether it solves your problem, and report back?
from webl10n.
@Rob--W Yes, that does seem to have made a difference. However, it only works if I put my require statement inside the ready() call; if I put the ready call inside the require(), I still see the warnings. So, this works:
document.webL10n.ready(function () { //wait until l10n has finished loading resources
require(["app"], function (app) {
Backbone.history.start();
});
});
But this doesn't:
require(["app"], function (app) {
document.webL10n.ready(function () { //wait until l10n has finished loading resources
Backbone.history.start();
});
});
Thanks.
from webl10n.
@paulguz I have added another commit to #70, assuming that you're loading additional localization files using loadLocale
. If that does not solve your issue, could you share a minimal project that demonstrates your problem?
from webl10n.
Hello again, after a whole year. I've been sidetracked in that time, but found myself looking at this again recently after upgrading dependencies in my project.
It appears that the last commit by @Rob--W has reintroduced the console warnings.
For the record, I'm not using loadLocale
.
Unfortunately I'm too busy right now to put together a sample project.
from webl10n.
Related Issues (20)
- It doesn't recognize es-419 as a variant of [es]
- Hideous synchronous request HOT 1
- Unicode/encoding problem ? HOT 2
- Use of deprecated synchronous request HOT 4
- Callback parameter for setLanguage() HOT 2
- call variable HOT 8
- Add bower support HOT 1
- setLanguage() problem
- Automatically generate locale ids HOT 4
- Multi-line *.property file strings
- Fall back to primary subtag matching if an exact language code match fails
- Versions and releases
- Minify
- bower package HOT 2
- Use webL10n on documentFragment HOT 2
- Mixing plural and properties other than textContent HOT 9
- Plural rules are not updated when setLanguage() executed HOT 1
- Referencing other data-* attributes
- If browser gives ru (not ru-RU) the default language is used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webl10n.