decord/source/modules/user_settings/LocaleStore.tsx

211 lines
5.7 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 1996
// Function ID: 1997
2026-07-29 08:29:29 +00:00
// Name: _getSystemLocale
2026-08-25 06:04:03 +00:00
// Dependencies: [5, 1997, 1340, 4008, 1236, 589, 709, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 1996 (_getSystemLocale)
2026-08-24 06:08:38 +00:00
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
2026-08-25 06:04:03 +00:00
import { setAppLocale } from "_setAppLocale" /* 1997 */;
2026-08-24 06:08:38 +00:00
import closure_5 from "handleConnectionClosedOrResumed" /* 1340 */;
import { systemLocale } from "getSystemLocale" /* 1236 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
function _getSystemLocale() {
const self = this;
const tmp = callback(function*() {
if (c3 === 2) {
c3 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp5 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-25 06:04:03 +00:00
return { value: "HermesInternal", done: "HermesInternal" };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c3 = 2;
if (0 === dependencyMap) {
if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_1 = tmp2;
2026-07-29 08:29:29 +00:00
let callback = tmp3;
callback = undefined;
2026-08-25 06:04:03 +00:00
const tmp25 = closure_1_1(4008);
2026-07-29 08:29:29 +00:00
let prop;
if (tmp25 != null) {
const app = tmp25.app;
if (app != null) {
prop = app.getPreferredSystemLanguages;
}
}
if (null != prop) {
2026-08-25 06:04:03 +00:00
const app2 = tmp23(4008).app;
2026-07-29 08:29:29 +00:00
const preferredSystemLanguages = app2.getPreferredSystemLanguages();
dependencyMap = 1;
c3 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
2026-07-29 08:29:29 +00:00
obj1[0] = preferredSystemLanguages.then((arg0) => arg0[0]);
return obj1;
}
2026-08-24 06:08:38 +00:00
tmp23 = closure_1_1;
2026-07-29 08:29:29 +00:00
}
} else if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
const obj2 = { value: null, done: true };
obj2[0] = arg1;
return obj2;
} else {
callback = arg1;
if (null != callback) {
if ("" !== callback) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = callback;
return obj;
}
}
}
c3 = 3;
const obj3 = { value: null, done: true };
obj3[0] = callback(1236).systemLocale;
return obj3;
} catch (tmp15) {
c3 = tmp;
throw tmp15;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
});
2026-08-24 06:08:38 +00:00
closure_6 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function handleUpdate() {
2026-08-24 06:08:38 +00:00
const localization = closure_5.settings.localization;
2026-07-20 16:05:17 +00:00
let value;
2026-07-29 08:29:29 +00:00
if (localization != null) {
if (localization.locale != null) {
2026-07-20 16:05:17 +00:00
value = iter.value;
}
}
let flag = null != value;
if (flag) {
flag = "" !== value;
}
if (flag) {
flag = value !== currentLocale;
}
if (flag) {
2026-07-23 10:11:24 +00:00
currentLocale = value;
2026-07-20 16:05:17 +00:00
setAppLocale(value);
flag = true;
}
return flag;
}
2026-07-23 10:11:24 +00:00
let currentLocale = require("getSystemLocale").intl.currentLocale;
(function getSystemLocale() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _getSystemLocale.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-23 10:11:24 +00:00
})().then((arg0) => {
2026-08-24 06:08:38 +00:00
closure_8 = arg0;
2026-07-20 16:05:17 +00:00
});
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class LocaleStore extends Store {
}
const prototype = LocaleStore.prototype;
prototype["initialize"] = function initialize() {
2026-08-24 06:08:38 +00:00
this.waitFor(closure_5);
const localization = closure_5.settings.localization;
2026-07-29 08:29:29 +00:00
let value;
if (localization != null) {
if (localization.locale != null) {
value = iter.value;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
let tmp3 = null != value;
if (tmp3) {
tmp3 = "" !== value;
}
if (tmp3) {
tmp3 = value !== currentLocale;
}
if (tmp3) {
currentLocale = value;
setAppLocale(value);
}
setAppLocale(currentLocale);
};
Object.defineProperty(prototype, "locale", {
get: function locale() {
return currentLocale;
},
set: undefined
});
Object.defineProperty(prototype, "systemLocale", {
get: function systemLocale() {
return systemLocale;
},
set: undefined
});
LocaleStore.displayName = "LocaleStore";
2026-08-24 06:08:38 +00:00
const localeStore = new LocaleStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
OVERLAY_INITIALIZE: handleUpdate,
CACHE_LOADED: handleUpdate,
CONNECTION_OPEN: handleUpdate,
USER_SETTINGS_PROTO_UPDATE: handleUpdate,
USER_SETTINGS_LOCALE_OVERRIDE: function handleLocaleOverride(locale) {
locale = locale.locale;
setAppLocale(locale);
}
});
2026-07-23 10:11:24 +00:00
let obj = {
2026-07-20 16:05:17 +00:00
OVERLAY_INITIALIZE: handleUpdate,
CACHE_LOADED: handleUpdate,
CONNECTION_OPEN: handleUpdate,
USER_SETTINGS_PROTO_UPDATE: handleUpdate,
USER_SETTINGS_LOCALE_OVERRIDE: function handleLocaleOverride(locale) {
locale = locale.locale;
setAppLocale(locale);
}
};
2026-07-23 10:11:24 +00:00
const promise = (function getSystemLocale() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _getSystemLocale.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-23 10:11:24 +00:00
})();
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/user_settings/LocaleStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default localeStore;