当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript app.getLocale方法代码示例

本文整理汇总了TypeScript中electron.app.getLocale方法的典型用法代码示例。如果您正苦于以下问题:TypeScript app.getLocale方法的具体用法?TypeScript app.getLocale怎么用?TypeScript app.getLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.app的用法示例。


在下文中一共展示了app.getLocale方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: callback

  fs.readFile(`${dataPath}/settings.json`, { encoding: "utf8" }, (err, settingsJSON) => {
    let languageCode = (settingsJSON != null) ? JSON.parse(settingsJSON).languageCode : null;

    if (languageCode == null) languageCode = electron.app.getLocale();
    if (i18n.languageIds.indexOf(languageCode) === -1 && languageCode.indexOf("-") !== -1) languageCode = languageCode.split("-")[0];
    if (i18n.languageIds.indexOf(languageCode) === -1) languageCode = "en";

    callback(languageCode);
  });
开发者ID:AgileJoshua,项目名称:superpowers-app,代码行数:9,代码来源:getLanguageCode.ts

示例2: setUserLocale

function setUserLocale(): void {
	const userLocale = bestFacebookLocaleFor(app.getLocale().replace('-', '_'));
	const cookie = {
		url: 'https://www.messenger.com/',
		name: 'locale',
		value: userLocale
	};
	session.defaultSession!.cookies.set(cookie, () => {});
}
开发者ID:kusamakura,项目名称:caprine,代码行数:9,代码来源:index.ts

示例3: getUserData

  getUserData((dataPathErr, dataPath, languageCode) => {
    if (languageCode == null) languageCode = electron.app.getLocale();
    if (i18n.languageIds.indexOf(languageCode) === -1 && languageCode.indexOf("-") !== -1) languageCode = languageCode.split("-")[0];
    if (i18n.languageIds.indexOf(languageCode) === -1) languageCode = "en";

    i18n.languageCode = languageCode;
    i18n.load([ "startup", "tray" ], () => {
      if (dataPathErr != null) {
        electron.dialog.showErrorBox(i18n.t("startup:failedToStart"), i18n.t(dataPathErr.key, dataPathErr.variables));
        electron.app.quit();
        process.exit(1);
        return;
      }

      userDataPath = dataPath;
      setupTrayOrDock();
      setupMainWindow();
    });
  });
开发者ID:mk-pmb,项目名称:superpowers-app,代码行数:19,代码来源:main.ts

示例4: it

 it('should not be empty', () => {
   expect(app.getLocale()).to.not.equal('')
 })
开发者ID:malept,项目名称:electron,代码行数:3,代码来源:api-app-spec.ts

示例5: async

  watcher.on(actions.preboot, async (store, action) => {
    let dispatchedBoot = false;

    let t1 = Date.now();
    try {
      const system: ISystemState = {
        appName: app.getName(),
        appVersion: app.getVersion().replace(/\-.*$/, ""),
        platform: os.itchPlatform(),
        arch: os.arch(),
        macos: os.platform() === "darwin",
        windows: os.platform() === "win32",
        linux: os.platform() === "linux",
        sniffedLanguage: app.getLocale(),
        homePath: app.getPath("home"),
        userDataPath: app.getPath("userData"),
        proxy: null,
        proxySource: null,
        quitting: false,
      };
      store.dispatch(actions.systemAssessed({ system }));

      try {
        await loadPreferences(store);
      } catch (e) {
        logger.error(
          `Could not load preferences: ${e.stack || e.message || e}`
        );
      }

      try {
        app.on(
          "certificate-error",
          (ev, webContents, url, error, certificate, callback) => {
            // do not trust
            callback(false);

            logger.error(
              `Certificate error: ${error} issued by ${
                certificate.issuerName
              } for ${certificate.subjectName}`
            );

            // TODO: that's super annoying as a modal.

            store.dispatch(
              actions.openModal(
                modalWidgets.naked.make({
                  window: "root",
                  title: `Certificate error: ${error}`,
                  message:
                    `There was an error with the certificate for ` +
                    `\`${certificate.subjectName}\` issued by \`${
                      certificate.issuerName
                    }\`.\n\n` +
                    `Please check your proxy configuration and try again.`,
                  detail: `If you ignore this error, the rest of the app might not work correctly.`,
                  buttons: [
                    {
                      label: "Ignore and continue",
                      className: "secondary",
                    },
                    {
                      label: ["menu.file.quit"],
                      action: actions.quit({}),
                    },
                  ],
                  widgetParams: null,
                })
              )
            );
          }
        );
        logger.debug(`Set up certificate error handler`);
      } catch (e) {
        logger.error(
          `Could not set up certificate error handler: ${e.stack ||
            e.message ||
            e}`
        );
      }

      try {
        const { session } = require("electron");
        const netSession = session.fromPartition(NET_PARTITION_NAME, {
          cache: false,
        });

        const envSettings: string =
          process.env.https_proxy ||
          process.env.HTTPS_PROXY ||
          process.env.http_proxy ||
          process.env.HTTP_PROXY;

        let proxySettings = {
          proxy: null as string,
          source: "os" as ProxySource,
        };

        if (envSettings) {
//.........这里部分代码省略.........
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:preboot.ts

示例6: getLocale

export function getLocale() {
    return settings.locale || app.getLocale();
}
开发者ID:eez-open,项目名称:studio,代码行数:3,代码来源:settings.ts

示例7: async

  watcher.on(actions.preboot, async (store, action) => {
    let t1 = Date.now();
    try {
      const system: SystemState = {
        appName: app.getName(),
        appVersion: app.getVersion().replace(/\-.*$/, ""),
        platform: itchPlatform(),
        arch: arch(),
        macos: process.platform === "darwin",
        windows: process.platform === "win32",
        linux: process.platform === "linux",
        sniffedLanguage: app.getLocale(),
        homePath: app.getPath("home"),
        userDataPath: app.getPath("userData"),
        proxy: null,
        proxySource: null,
        quitting: false,
      };
      store.dispatch(actions.systemAssessed({ system }));

      try {
        await loadPreferences(store);
      } catch (e) {
        logger.error(
          `Could not load preferences: ${e.stack || e.message || e}`
        );
      }

      try {
        const netSession = session.fromPartition(NET_PARTITION_NAME, {
          cache: false,
        });

        const envSettings: string =
          process.env.https_proxy ||
          process.env.HTTPS_PROXY ||
          process.env.http_proxy ||
          process.env.HTTP_PROXY;

        let proxySettings = {
          proxy: null as string,
          source: "os" as ProxySource,
        };

        if (envSettings) {
          logger.info(`Got proxy settings from environment: ${envSettings}`);
          proxySettings = {
            proxy: envSettings,
            source: "env",
          };
          testProxy = true;
          store.dispatch(actions.proxySettingsDetected(proxySettings));
        }
        await applyProxySettings(netSession, proxySettings);
      } catch (e) {
        logger.warn(
          `Could not detect proxy settings: ${e ? e.message : "unknown error"}`
        );
      }

      if (env.production && env.appName === "itch") {
        try {
          app.setAsDefaultProtocolClient("itchio");
          app.setAsDefaultProtocolClient("itch");
        } catch (e) {
          logger.error(
            `Could not set app as default protocol client: ${e.stack ||
              e.message ||
              e}`
          );
        }
      }
    } catch (e) {
      throw e;
    } finally {
      const t2 = Date.now();
      logger.info(`preboot ran in ${elapsed(t1, t2)}`);
    }

    store.dispatch(actions.prebootDone({}));

    let devtoolsPath = process.env.ITCH_REACT_DEVTOOLS_PATH;
    if (!devtoolsPath && env.development) {
      let reactDevtoolsId = "fmkadmapgofadopljbjfkapdkoienihi";
      let devtoolsFolder = path.join(
        app.getPath("home"),
        "AppData",
        "Local",
        "Google",
        "Chrome",
        "User Data",
        "Default",
        "Extensions",
        reactDevtoolsId
      );
      try {
        const files = fs.readdirSync(devtoolsFolder);
        let version = files[0];
        if (version) {
          devtoolsPath = path.join(devtoolsFolder, version);
//.........这里部分代码省略.........
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:preboot.ts

示例8: getLocale

 private getLocale(): string {
     return app.getLocale() || 'en';
 }
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:3,代码来源:Bridge.ts


注:本文中的electron.app.getLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。