2018-01-05 22:30:15 +01:00
|
|
|
import { PlatformUtilsService } from './abstractions/platformUtils.service';
|
2017-12-06 20:05:49 +01:00
|
|
|
|
2018-01-05 22:30:15 +01:00
|
|
|
export default function i18nService(platformUtilsService: PlatformUtilsService) {
|
2017-12-06 19:51:49 +01:00
|
|
|
const edgeMessages: any = {};
|
|
|
|
|
2018-01-05 22:30:15 +01:00
|
|
|
if (platformUtilsService.isEdge()) {
|
2017-12-06 20:05:49 +01:00
|
|
|
fetch('../_locales/en/messages.json').then((file) => {
|
|
|
|
return file.json();
|
|
|
|
}).then((locales) => {
|
|
|
|
for (const prop in locales) {
|
|
|
|
if (locales.hasOwnProperty(prop)) {
|
|
|
|
edgeMessages[prop] = chrome.i18n.getMessage(prop);
|
2017-12-06 19:51:49 +01:00
|
|
|
}
|
2017-12-06 20:05:49 +01:00
|
|
|
}
|
|
|
|
});
|
2017-12-06 19:51:49 +01:00
|
|
|
|
|
|
|
return edgeMessages;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Proxy({}, {
|
2017-12-06 20:23:34 +01:00
|
|
|
get: (target, name) => {
|
2017-12-06 19:51:49 +01:00
|
|
|
return chrome.i18n.getMessage(name);
|
|
|
|
},
|
2017-12-06 20:23:34 +01:00
|
|
|
set: (target, name, value) => {
|
2017-12-06 19:51:49 +01:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|