• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript t.t函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中common/format/t.t函数的典型用法代码示例。如果您正苦于以下问题:TypeScript t函数的具体用法?TypeScript t怎么用?TypeScript t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: makeInstallErrorModal

export function makeInstallErrorModal(params: InstallErrorParams) {
  let buttons: IModalButtonSpec[] = [];
  let detail: ILocalizedString;
  let shouldRetry = true;
  let forceDetails = false;

  const { store, e, log, retryAction, stopAction, game } = params;
  const { i18n } = store.getState();

  const re = asRequestError(e);

  if (re) {
    switch (re.rpcError.code) {
      case messages.Code.UnsupportedPackaging: {
        const learnMore = t(i18n, ["docs.how_to_help"]);
        detail = `[${learnMore}](https://itch.io/docs/itch/integrating/quickstart.html)`;
        shouldRetry = false;
        forceDetails = true;
        break;
      }
    }
  }

  if (shouldRetry) {
    buttons = [
      ...buttons,
      {
        label: ["game.install.try_again"],
        icon: "repeat",
        action: retryAction(),
      },
    ];
  }

  buttons = [
    ...buttons,

    {
      label: ["grid.item.discard_download"],
      icon: "delete",
      action: stopAction(),
    },
    "cancel",
  ];

  return modalWidgets.showError.make({
    window: "root",
    title: ["prompt.install_error.title"],
    message: t(i18n, formatError(e)),
    detail,
    widgetParams: { rawError: e, log, forceDetails, game },
    buttons,
  });
}
开发者ID:HorrerGames,项目名称:itch,代码行数:54,代码来源:make-install-error-modal.ts


示例2: t

  nativeWindow.on("close", (e: any) => {
    const rs = store.getState();
    if (wind === "root") {
      const prefs =
        rs.preferences || ({ closeToTray: true } as PreferencesState);

      let { closeToTray } = prefs;
      if (rs.system.macos) {
        closeToTray = true;
      }
      if (env.integrationTests) {
        // always let app close in testing
        closeToTray = false;
      }

      if (store.getState().system.quitting) {
        logger.debug("On window.close: quitting, letting it close");
        return;
      }
      if (closeToTray) {
        logger.debug("On window.close: close to tray enabled");
      } else {
        logger.debug("On window.close: close to tray disabled, quitting!");
        process.nextTick(() => {
          store.dispatch(actions.quit({}));
        });
        return;
      }

      // hide, never destroy
      e.preventDefault();
      nativeWindow.hide();

      if (!prefs.gotMinimizeNotification && !store.getState().system.macos) {
        store.dispatch(
          actions.updatePreferences({
            gotMinimizeNotification: true,
          })
        );

        const i18n = store.getState().i18n;
        store.dispatch(
          actions.notify({
            title: t(i18n, ["notification.see_you_soon.title"]),
            body: t(i18n, ["notification.see_you_soon.message"]),
          })
        );
      }
    } else {
      store.dispatch(actions.windClosed({ wind }));
    }
  });
开发者ID:itchio,项目名称:itch,代码行数:52,代码来源:winds.ts


示例3: async

 watcher.on(actions.statusMessage, async (store, action) => {
   const { message } = action.payload;
   const { i18n } = store.getState();
   logger.info(`Status: ${t(i18n, message)}`);
   await delay(AUTODISMISS_DELAY);
   store.dispatch(actions.dismissStatusMessage({}));
 });
开发者ID:HorrerGames,项目名称:itch,代码行数:7,代码来源:notifications.ts


示例4: convertTemplate

function convertTemplate(
  store: Store,
  template: MenuItem[]
): MenuItemConstructorOptions[] {
  const rs = store.getState();
  const { i18n } = rs;
  const result: MenuItemConstructorOptions[] = [];
  for (const item of template) {
    const opts: MenuItemConstructorOptions = {};
    if (item.localizedLabel) {
      opts.label = t(i18n, item.localizedLabel);
    }
    if (item.action) {
      opts.click = () => {
        store.dispatch(item.action);
      };
    }
    if (item.type) {
      opts.type = item.type;
    }
    if (item.submenu) {
      opts.submenu = convertTemplate(store, item.submenu);
    }
    if (item.accelerator) {
      opts.accelerator = item.accelerator;
    }
    result.push(opts);
  }
  return result;
}
开发者ID:itchio,项目名称:itch,代码行数:30,代码来源:context-menu.ts


示例5: async

  watcher.on(actions.addInstallLocation, async (store, action) => {
    const { window } = action.payload;
    const i18n = store.getState().i18n;
    const nativeWindow = getNativeWindow(store.getState(), window);
    if (!nativeWindow) {
      return;
    }

    const dialogOpts = {
      title: t(i18n, ["prompt.install_location_add.title"]),
      // crazy typescript workaround, avert your eyes
      properties: ["openDirectory", "createDirectory"] as (
        | "openDirectory"
        | "createDirectory")[],
    };

    const promise = new ItchPromise<string>((resolve, reject) => {
      const callback = (response: string[]) => {
        if (!response) {
          return resolve();
        }

        return resolve(response[0]);
      };
      dialog.showOpenDialog(nativeWindow, dialogOpts, callback);
    });

    const path = await promise;
    if (path) {
      await call(messages.InstallLocationsAdd, { path });
      store.dispatch(actions.installLocationsChanged({}));
    }
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:33,代码来源:install-locations.ts


示例6: t

  const visitNode = (input: MenuItem) => {
    const node = { ...input } as Electron.MenuItemConstructorOptions;
    if (node.type === "separator") {
      return node;
    }

    const { localizedLabel, role = null, enabled = true } = input;

    if (localizedLabel) {
      node.label = t(i18n, localizedLabel);
    }
    if (enabled && !node.click) {
      node.click = e => {
        const menuAction = convertMenuAction(
          wind,
          { localizedLabel, role },
          runtime
        );
        if (menuAction) {
          store.dispatch(menuAction);
        }
      };
    }

    if (node.submenu) {
      node.submenu = map(node.submenu as MenuItem[], visitNode);
    }

    return node;
  };
开发者ID:itchio,项目名称:itch,代码行数:30,代码来源:flesh-out-template.ts


示例7: async

  watcher.on(actions.relaunchRequest, async (store, action) => {
    const rs = store.getState();
    const pkg = rs.broth.packages[rs.system.appName];
    if (pkg.stage !== "need-restart") {
      return;
    }
    const version = pkg.availableVersion;
    const restart = t(rs.i18n, ["prompt.self_update_ready.action.restart"]);

    store.dispatch(
      actions.openModal(
        modals.naked.make({
          wind: "root",
          title: ["prompt.self_update.title", { version }],
          message: ["prompt.self_update_ready.message", { restart }],
          buttons: [
            {
              label: ["prompt.self_update_ready.action.restart"],
              action: actions.relaunch({}),
            },
            {
              label: ["prompt.self_update_ready.action.snooze"],
              action: actions.closeModal({ wind: "root" }),
            },
          ],
          widgetParams: null,
        })
      )
    );
  });
开发者ID:itchio,项目名称:itch,代码行数:30,代码来源:self-update.ts


示例8: t

  nativeWindow.on("close", (e: any) => {
    const prefs = store.getState().preferences || { closeToTray: true };

    let { closeToTray } = prefs;
    if (env.integrationTests) {
      // always let app close in testing
      closeToTray = false;
    }

    if (closeToTray) {
      logger.debug("Close to tray enabled");
    } else {
      logger.debug("Close to tray disabled, quitting!");
      process.nextTick(() => {
        store.dispatch(actions.quit({}));
      });
      return;
    }

    if (!nativeWindow.isVisible()) {
      logger.info("Main window hidden, letting it close");
      return;
    }

    if (!prefs.gotMinimizeNotification) {
      store.dispatch(
        actions.updatePreferences({
          gotMinimizeNotification: true,
        })
      );

      const i18n = store.getState().i18n;
      store.dispatch(
        actions.notify({
          title: t(i18n, ["notification.see_you_soon.title"]),
          body: t(i18n, ["notification.see_you_soon.message"]),
        })
      );
    }

    // hide, never destroy
    e.preventDefault();
    logger.info("Hiding main window");
    nativeWindow.hide();
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:45,代码来源:main-window.ts


示例9: t

 let processItem = (i: number) => {
   let item = history[i];
   let label = item.label ? t(i18n, item.label) : item.url;
   template.push({
     localizedLabel: truncate(label, { length: 50 }),
     checked: i === currentIndex,
     action: actions.tabGoToIndex({ wind, tab, index: i }),
   });
 };
开发者ID:itchio,项目名称:itch,代码行数:9,代码来源:navigation.ts


示例10: async

  watcher.on(actions.downloadEnded, async (store, action) => {
    const { download } = action.payload;
    if (download.error) {
      // don't show notifications for these
      return;
    }

    const prefs = store.getState().preferences || { readyNotification: true };
    const { readyNotification } = prefs;

    if (readyNotification) {
      let notificationMessage: string = null;
      let notificationOptions: any = {
        title: download.game.title,
      };

      switch (download.reason) {
        case "install":
          notificationMessage = "notification.download_installed";
          break;
        case "reinstall":
          notificationMessage = "notification.download_healed";
          break;
        case "update":
          notificationMessage = "notification.download_updated";
          break;
        case "version-switch":
          notificationMessage = "notification.download_reverted";
          notificationOptions.version = `?`;
          const { build } = download;
          if (build) {
            notificationOptions.version = `#${build.userVersion ||
              build.version}`;
          }
          break;
        default:
        // make the typescript compiler happy
      }

      if (notificationMessage) {
        const { i18n } = store.getState();
        const message = t(i18n, [notificationMessage, notificationOptions]);
        store.dispatch(
          actions.notify({
            body: message,
            onClick: actions.navigateToGame({
              window: "root",
              game: download.game,
            }),
          })
        );
      }
    }
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:54,代码来源:download-ended.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript frequency.Frequency类代码示例发布时间:2022-05-25
下一篇:
TypeScript show-in-explorer.showInExplorerString函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap