Closed
Bug 1115773
Opened 9 years ago
Closed 9 years ago
Fallback mechanism keeps loading last locale for each missing entity
Categories
(Firefox OS Graveyard :: Gaia::L10n, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: zbraniecki, Assigned: stas)
References
Details
Attachments
(1 file)
It seems that there's a bug in our code, that I noticed while working on langpacks. When an entity is missing from en-US (defaultLocale), we load it. When the next entity is missing we seem to start loading it again. I didn't debug it yet, but I see in logs that if en-US.json is empty, we load it many times. We should fix it because with misuse of mozL10n.get (for testing if the entity is empty) we will load en-US Locale for each call. :/
Assignee | ||
Comment 1•9 years ago
|
||
Without any own debugging yet I wonder if it's the mutation observer that you see in the logs? When we localize the HTML, the mutation observer calls getEntity, which starts loading the fallback locale. Could it be that the next mutation is processed before en-US.json loads? The loading should be synchronous but I'm not sure if I remember how exactly the mutation microtasks are executed.
Reporter | ||
Comment 2•9 years ago
|
||
idk. I'll try to reproduce it today.
Assignee | ||
Comment 3•9 years ago
|
||
I started debugging this earlier today and all I was seeing was telling me our sync XHR isn't sync. After exploring many possible reasons (I suspected Gecko changes) I had a closer look at our io.loadJSON method: https://github.com/mozilla-b2g/gaia/blob/2a39e2f4fb9785ce6dd5a914f9b844021d59a5f6/shared/js/l10n.js#L52 It's always async :) I'll have a patch when I'm back tonight. I noticed that we can't override the MIME type to JSON anymore in sync requests ("InvalidAccessError: A parameter or an operation is not supported by the underlying object") so we'll need to JSON.parse manually, I think.
Reporter | ||
Comment 4•9 years ago
|
||
Gosh, thanks! I was considering panicking. :)
Assignee | ||
Comment 5•9 years ago
|
||
Assignee: nobody → stas
Attachment #8545548 -
Flags: review?(gandalf)
Reporter | ||
Comment 6•9 years ago
|
||
Comment on attachment 8545548 [details] [review] Allow loadJSON to be async I think there's still a major benefit in most common scenario to use responseType json. I'd like to preserve that. Can we just check if it's sync and skip responseType and JSON.parse in the callback?
Assignee | ||
Comment 7•9 years ago
|
||
OK, I'll update the patch. I was hoping we can get rid of the redundant code here though :(
Assignee | ||
Comment 8•9 years ago
|
||
Patch updated. https://treeherder.mozilla.org/ui/#/jobs?repo=gaia-try&revision=c21afc56e8ee
Assignee | ||
Updated•9 years ago
|
Blocks: fxos-langpacks
Assignee | ||
Comment 9•9 years ago
|
||
Oops, it looks like I broke all l10n tests ^^.
Assignee | ||
Comment 10•9 years ago
|
||
Aaaand it's fixed now. It looks like the treeherder is having a hiccup though; I don't have the URL to a new build yet.
Assignee | ||
Comment 11•9 years ago
|
||
Zibi, this is now ready for your review. https://treeherder.mozilla.org/ui/#/jobs?repo=gaia-try&revision=f856cc98486e
Reporter | ||
Comment 12•9 years ago
|
||
Comment on attachment 8545548 [details] [review] Allow loadJSON to be async sweet, thanks!
Attachment #8545548 -
Flags: review?(gandalf) → review+
Assignee | ||
Comment 13•9 years ago
|
||
https://github.com/mozilla-b2g/gaia/commit/1acb64c3dd32e285c5775119c4a5a1ff4dbbd5a3 https://github.com/l20n/l20n.js/commit/f0785817a49c7ba1fc9a59d6484e89b42b94ec24
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•