npm package diff
Package: @forge/bridge
Versions: 4.0.0 - 4.0.1-next.0
File: package/out/i18n/index.js
Index: package/out/i18n/index.js
===================================================================
--- package/out/i18n/index.js
+++ package/out/i18n/index.js
@@ -1,50 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTranslationFunction = exports.getTranslations = exports.resetTranslationsCache = void 0;
-const tslib_1 = require("tslib");
const i18n_1 = require("@forge/i18n");
const view_1 = require("../view");
const frontendResourcesAccessor = {
- getI18nInfoConfig: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const resp = yield fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${i18n_1.I18N_INFO_FILE_NAME}`);
+ getI18nInfoConfig: async () => {
+ const resp = await fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${i18n_1.I18N_INFO_FILE_NAME}`);
if (!resp.ok) {
throw new Error('Failed to get i18n info config: ' + resp.statusText);
}
- const info = (yield resp.json());
+ const info = (await resp.json());
return info.config;
- }),
- getTranslationResource: (locale) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const resp = yield fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${locale}.json`);
+ },
+ getTranslationResource: async (locale) => {
+ const resp = await fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${locale}.json`);
if (!resp.ok) {
throw new Error(`Failed to get translation resource for locale: ${locale}`);
}
return resp.json();
- })
+ }
};
const translationsGetter = new i18n_1.TranslationsGetter(frontendResourcesAccessor);
const resetTranslationsCache = () => {
translationsGetter.reset();
};
exports.resetTranslationsCache = resetTranslationsCache;
-const getTranslations = (locale = null, options = {
+const getTranslations = async (locale = null, options = {
fallback: true
-}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+}) => {
let targetLocale = locale;
if (!targetLocale) {
- const context = yield view_1.view.getContext();
+ const context = await view_1.view.getContext();
targetLocale = context.locale;
}
- return yield translationsGetter.getTranslations(targetLocale, options);
-});
+ return await translationsGetter.getTranslations(targetLocale, options);
+};
exports.getTranslations = getTranslations;
-const createTranslationFunction = (locale = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+const createTranslationFunction = async (locale = null) => {
let targetLocale = locale;
if (!targetLocale) {
- const context = yield view_1.view.getContext();
+ const context = await view_1.view.getContext();
targetLocale = context.locale;
}
const translator = new i18n_1.Translator(targetLocale, translationsGetter);
- yield translator.init();
+ await translator.init();
return (i18nKey, defaultValue) => { var _a, _b; return (_b = (_a = translator.translate(i18nKey)) !== null && _a !== void 0 ? _a : defaultValue) !== null && _b !== void 0 ? _b : i18nKey; };
-});
+};
exports.createTranslationFunction = createTranslationFunction;