From d062dbf4ac23c76caa964a781fbf1c57e6dfabd4 Mon Sep 17 00:00:00 2001 From: Tim Mickel Date: Fri, 22 Jan 2016 15:42:56 -0500 Subject: [PATCH] Make Localization.includeLocales async --- src/utils/Localization.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/utils/Localization.js b/src/utils/Localization.js index 418b5b9..f999522 100644 --- a/src/utils/Localization.js +++ b/src/utils/Localization.js @@ -1,5 +1,6 @@ import Cookie from './Cookie'; import Intl from 'intl'; +import IO from '../iPad/IO'; window.Intl = Intl; require('intl/locale-data/jsonp/en.js'); @@ -52,7 +53,7 @@ export default class Localization { // Include locale support files and load the messages // Call this when the app is initialized - static includeLocales () { + static includeLocales (whenDone) { var localizationCookie = Cookie.get('localization'); if (localizationCookie === null) { @@ -62,11 +63,11 @@ export default class Localization { } var topLevel = currentLocale.split('-')[0]; - // Get messages synchronously - var xhr = new XMLHttpRequest(); - xhr.open('GET', root + 'localizations/' + topLevel + '.json', false); - xhr.send(null); - localizationMessages = JSON.parse(xhr.responseText); + // Get messages + IO.requestFromServer(root + 'localizations/' + topLevel + '.json', (result) => { + localizationMessages = JSON.parse(result); + whenDone(); + }); } // Translate a particular message given the message key and info