fetch edge messages
This commit is contained in:
parent
bd109f4ed9
commit
4fb2d879ec
|
@ -1,27 +1,18 @@
|
||||||
export default function i18nService(utilsService) {
|
export default function i18nService(utilsService) {
|
||||||
this.utilsService = utilsService;
|
if (utilsService.isEdge()) {
|
||||||
this.messages = {};
|
this.__edgeMessages = {};
|
||||||
|
const self = this;
|
||||||
var self = this;
|
fetch('../_locales/en/messages.json').then((file) => {
|
||||||
|
return file.json();
|
||||||
if (self.utilsService.isEdge()) {
|
}).then((locales) => {
|
||||||
var rawFile = new XMLHttpRequest();
|
for (const prop in locales) {
|
||||||
rawFile.open('GET', '../_locales/en/messages.json', false);
|
if (locales.hasOwnProperty(prop)) {
|
||||||
rawFile.onreadystatechange = function () {
|
self.__edgeMessages[prop] = chrome.i18n.getMessage(prop);
|
||||||
if (rawFile.readyState === 4) {
|
|
||||||
if (rawFile.status === 200 || rawFile.status === 0) {
|
|
||||||
var locales = JSON.parse(rawFile.responseText);
|
|
||||||
for (var property in locales) {
|
|
||||||
if (locales.hasOwnProperty(property)) {
|
|
||||||
self.messages[property] = chrome.i18n.getMessage(property);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
rawFile.send(null);
|
|
||||||
|
|
||||||
return self.messages;
|
return this.__edgeMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Proxy({}, {
|
return new Proxy({}, {
|
||||||
|
|
Loading…
Reference in New Issue