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

TypeScript i18next.t函数代码示例

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

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



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

示例1: error

 (noun = "Command") => () => error(t(`${noun} failed`));
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:1,代码来源:actions.ts


示例2:

const updateContent = () => {
    const value: string = i18next.t('key');
};
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:3,代码来源:i18next-tests.ts


示例3: t

 (getConfigValue: GetWebAppConfigValue): LabsFeature[] => ([
   {
     name: t("Internationalize Web App"),
     description: t("Turn off to set Web App to English."),
     storageKey: BooleanSetting.disable_i18n,
     value: false,
     displayInvert: true,
     callback: () => window.location.reload()
   },
   {
     name: t("Confirm Sequence step deletion"),
     description: t(Content.CONFIRM_STEP_DELETION),
     storageKey: BooleanSetting.confirm_step_deletion,
     value: false
   },
   {
     name: t("Hide Webcam widget"),
     description: t(Content.HIDE_WEBCAM_WIDGET),
     storageKey: BooleanSetting.hide_webcam_widget,
     value: false
   },
   {
     name: t("Dynamic map size"),
     description: t(Content.DYNAMIC_MAP_SIZE),
     storageKey: BooleanSetting.dynamic_map,
     value: false
   },
   {
     name: t("Double default map dimensions"),
     description: t(Content.DOUBLE_MAP_DIMENSIONS),
     storageKey: BooleanSetting.map_xl,
     value: false
   },
   {
     name: t("Display plant animations"),
     description: t(Content.PLANT_ANIMATIONS),
     storageKey: BooleanSetting.disable_animations,
     value: false,
     displayInvert: true
   },
   {
     name: t("Read speak logs in browser"),
     description: t(Content.BROWSER_SPEAK_LOGS),
     storageKey: BooleanSetting.enable_browser_speak,
     value: false
   },
   {
     name: t("Discard Unsaved Changes"),
     description: t(Content.DISCARD_UNSAVED_CHANGES),
     storageKey: BooleanSetting.discard_unsaved,
     value: false,
     confirmationMessage: t(Content.DISCARD_UNSAVED_CHANGES_CONFIRM)
   },
   {
     name: t("Display virtual FarmBot trail"),
     description: t(Content.VIRTUAL_TRAIL),
     storageKey: BooleanSetting.display_trail,
     value: false,
     callback: () => sessionStorage.setItem(VirtualTrail.records, "[]")
   },
 ].map(fetchSettingValue(getConfigValue)));
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:61,代码来源:labs_features_list_data.ts


示例4: updateContent

    i18next.t('common:button.save'); // -> "save"
});

i18next.init({
    lng: 'de',

    // allow keys to be phrases having `:`, `.`
    nsSeparator: false,
    keySeparator: false,

    // do not load a fallback
    fallbackLng: false
});

const error404 = '404';
i18next.t([`error.${error404}`, 'error.unspecific']); // -> "The page was not found"

const error502 = '502';
i18next.t([`error.${error502}`, 'error.unspecific']); // -> "Something went wrong"

i18next.t('No one says a key can not be the fallback.');
// -> "Niemand sagt ein key kann nicht als Ersatz dienen."

i18next.t('This will be shown if the current loaded translations to not have this.');
// -> "This will be shown if the current loaded translations to not have this."

const languageChangedCallback = () => {
    updateContent();
};

i18next.on('languageChanged', languageChangedCallback);
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:i18next-tests.ts


示例5: Error

export async function handleErrors<T>(response: Response): Promise<ServerResponse<T>> {
  if (response instanceof TypeError) {
    throw new Error(
      navigator.onLine ? t('BungieService.NotConnectedOrBlocked') : t('BungieService.NotConnected')
    );
  }

  if (response instanceof Error) {
    throw response;
  }

  if (response.status === -1) {
    throw new Error(
      navigator.onLine ? t('BungieService.NotConnectedOrBlocked') : t('BungieService.NotConnected')
    );
  }
  // Token expired and other auth maladies
  if (response.status === 401 || response.status === 403) {
    goToLoginPage();
    throw new Error(t('BungieService.NotLoggedIn'));
  }
  /* 526 = cloudflare */
  if (response.status >= 503 && response.status <= 526) {
    throw new Error(t('BungieService.Difficulties'));
  }
  if (response.status < 200 || response.status >= 400) {
    throw new Error(
      t('BungieService.NetworkError', {
        status: response.status,
        statusText: response.statusText
      })
    );
  }

  const data: ServerResponse<any> = await response.json();

  const errorCode = data ? data.ErrorCode : -1;

  // See https://github.com/DestinyDevs/BungieNetPlatform/wiki/Enums#platformerrorcodes
  switch (errorCode) {
    case PlatformErrorCodes.Success:
      return data;

    case PlatformErrorCodes.DestinyVendorNotFound:
      throw error(t('BungieService.VendorNotFound'), errorCode);

    case PlatformErrorCodes.AuthorizationCodeInvalid:
    case PlatformErrorCodes.AccessNotPermittedByApplicationScope:
      goToLoginPage();
      throw error('DIM does not have permission to perform this action.', errorCode);

    case PlatformErrorCodes.SystemDisabled:
      throw error(t('BungieService.Maintenance'), errorCode);

    case PlatformErrorCodes.ThrottleLimitExceededMinutes:
    case PlatformErrorCodes.ThrottleLimitExceededMomentarily:
    case PlatformErrorCodes.ThrottleLimitExceededSeconds:
    case PlatformErrorCodes.DestinyThrottledByGameServer:
      throw error(t('BungieService.Throttled'), errorCode);

    case PlatformErrorCodes.AccessTokenHasExpired:
    case PlatformErrorCodes.WebAuthRequired:
    case PlatformErrorCodes.WebAuthModuleAsyncFailed: // means the access token has expired
      goToLoginPage();
      throw error(t('BungieService.NotLoggedIn'), errorCode);

    case PlatformErrorCodes.DestinyAccountNotFound:
    case PlatformErrorCodes.DestinyUnexpectedError:
      if (response.url.indexOf('/Account/') >= 0 && response.url.indexOf('/Character/') < 0) {
        const account = getActivePlatform();
        throw error(
          t('BungieService.NoAccount', {
            platform: account ? account.platformLabel : 'Unknown'
          }),
          errorCode
        );
      }
      break;

    case PlatformErrorCodes.DestinyLegacyPlatformInaccessible:
      throw error(t('BungieService.DestinyLegacyPlatform'), errorCode);

    case PlatformErrorCodes.ApiInvalidOrExpiredKey:
    case PlatformErrorCodes.ApiKeyMissingFromRequest:
    case PlatformErrorCodes.OriginHeaderDoesNotMatchKey:
      if ($DIM_FLAVOR === 'dev') {
        router.stateService.go('developer');
        throw error(t('BungieService.DevVersion'), errorCode);
      } else {
        throw error(t('BungieService.Difficulties'), errorCode);
      }
  }

  // Any other error
  if (data && data.Message) {
    const e = error(t('BungieService.UnknownError', { message: data.Message }), errorCode);
    e.status = data.ErrorStatus;
    throw e;
  } else {
    console.error('No response data:', response.status, response.statusText);
//.........这里部分代码省略.........
开发者ID:w1cked,项目名称:DIM,代码行数:101,代码来源:bungie-service-helper.ts


示例6: saveRegimenErr

function saveRegimenErr(err: any) {
  error(prettyPrintApiErrors(err),
    t("Unable to save regimen."));
}
开发者ID:roryaronson,项目名称:farmbot-web-frontend,代码行数:4,代码来源:actions.ts


示例7: t

 $rootScope.$apply(() =>
   toaster.pop({
     type: 'error',
     title: t('Help.NoStorage'),
     body: `<p>${t('Help.NoStorageMessage')}</p>`
   })
开发者ID:bhollis,项目名称:DIM,代码行数:6,代码来源:compatibility.ts


示例8:

        web.getUserById(_spPageContextInfo.userId).get().then((user) => {

            this.welcomeMessage(sprintf.sprintf(i18n.t("welcomeMessage"), user.Title.split(" ")[0]));

        }).catch((errorMesssage) => {
开发者ID:AKrasheninnikov,项目名称:PnP,代码行数:5,代码来源:WelcomeOverlayViewModel.ts


示例9: error

 }, (e: Error) => {
     error(t(`User could not be updated: ${e.message}`));
 });
开发者ID:roryaronson,项目名称:farmbot-web-frontend,代码行数:3,代码来源:actions.ts


示例10: t

import { t } from "i18next";
import { DropDownItem } from "../../ui/index";
import { SPECIAL_VALUES } from "./remote_env/constants";

/** Mapping of SPECIAL_VALUE numeric codes into corresponding drop down items. */
export const SPECIAL_VALUE_DDI: { [index: number]: DropDownItem } = {
  [SPECIAL_VALUES.X]: {
    label: "X",
    value: SPECIAL_VALUES.X
  },
  [SPECIAL_VALUES.Y]: {
    label: "Y",
    value: SPECIAL_VALUES.Y
  },
  [SPECIAL_VALUES.TOP_LEFT]: {
    label: t("Top Left"),
    value: SPECIAL_VALUES.TOP_LEFT
  },
  [SPECIAL_VALUES.TOP_RIGHT]: {
    label: t("Top Right"),
    value: SPECIAL_VALUES.TOP_RIGHT
  },
  [SPECIAL_VALUES.BOTTOM_LEFT]: {
    label: t("Bottom Left"),
    value: SPECIAL_VALUES.BOTTOM_LEFT
  },
  [SPECIAL_VALUES.BOTTOM_RIGHT]: {
    label: t("Bottom Right"),
    value: SPECIAL_VALUES.BOTTOM_RIGHT
  },
};
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:31,代码来源:constants.ts


示例11: success

 .then((resp) => {
     success(t("User successfully updated."));
     dispatch(updateUserSuccess(resp.data));
 }, (e: Error) => {
开发者ID:roryaronson,项目名称:farmbot-web-frontend,代码行数:4,代码来源:actions.ts


示例12: factoryReset

export function factoryReset() {
  if (!confirm(t(Content.FACTORY_RESET_ALERT))) {
    return;
  }
  getDevice().resetOS();
}
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:6,代码来源:actions.ts


示例13: t

export const commandOK = (noun = "Command") => () => {
  const msg = t(noun) + t(" request sent to device.");
  success(msg, t("Request sent"));
};
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:4,代码来源:actions.ts


示例14: t

      return;
    }
    t('key'); // -> same as i18next.t
  },
);

// with only callback
i18next.init((err, t) => {
  if (err) {
    console.log('something went wrong loading', err);
    return;
  }
  t('key'); // -> same as i18next.t
});

const v: string = i18next.t('my.key');

// fix language to german
const de = i18next.getFixedT('de');
const z: string = de('myKey');

// or fix the namespace to anotherNamespace
const anotherNamespace = i18next.getFixedT(null, 'anotherNamespace');
const x: string = anotherNamespace('anotherNamespaceKey'); // no need to prefix ns i18n.t('anotherNamespace:anotherNamespaceKey');

i18next.changeLanguage('en', (err, t) => {
  if (err) {
    console.log('something went wrong loading', err);
    return;
  }
  t('key'); // -> same as i18next.t
开发者ID:i18next,项目名称:i18next,代码行数:31,代码来源:init.test.ts


示例15: doMoveDroppedItem

async function doMoveDroppedItem(
  target: DimStore,
  item: DimItem,
  equip: boolean,
  shiftPressed: boolean,
  hovering: boolean
) {
  if (item.notransfer && item.owner !== target.id) {
    throw new Error(t('Help.CannotMove'));
  }

  if (item.owner === target.id && !item.location.inPostmaster) {
    if ((item.equipped && equip) || (!item.equipped && !equip)) {
      return;
    }
  }

  let moveAmount = item.amount || 1;

  try {
    if (
      item.maxStackSize > 1 &&
      item.amount > 1 &&
      // TODO: how to do this...
      (shiftPressed || hovering)
    ) {
      ngDialog.closeAll();
      const dialogResult = ngDialog.open({
        // TODO: break this out into a separate service/directive?
        template: dialogTemplate,
        controllerAs: 'vm',
        controller($scope) {
          'ngInject';
          const vm = this;
          vm.item = $scope.ngDialogData;
          vm.moveAmount = vm.item.amount;
          vm.maximum = vm.item
            .getStoresService()
            .getStore(vm.item.owner)!
            .amountOfItem(item);
          vm.stacksWorth = Math.min(
            Math.max(item.maxStackSize - target.amountOfItem(item), 0),
            vm.maximum
          );
          vm.stacksWorthClick = () => {
            vm.moveAmount = vm.stacksWorth;
            vm.finish();
          };
          vm.finish = () => {
            $scope.closeThisDialog(vm.moveAmount);
          };
        },
        plain: true,
        data: item,
        appendTo: 'body',
        overlay: true,
        className: 'move-amount-popup',
        appendClassName: 'modal-dialog'
      });

      const data = await dialogResult.closePromise;
      if (typeof data.value === 'string') {
        const error: DimError = new Error('move-canceled');
        error.code = 'move-canceled';
        throw error;
      }
      moveAmount = data.value;
    }

    if ($featureFlags.debugMoves) {
      console.log(
        'User initiated move:',
        moveAmount,
        item.name,
        item.type,
        'to',
        target.name,
        'from',
        item.getStoresService().getStore(item.owner)!.name
      );
    }

    item = await dimItemService.moveTo(item, target, equip, moveAmount);

    const reload = item.equipped || equip;
    if (reload) {
      await item.getStoresService().updateCharacters();
    }

    item.updateManualMoveTimestamp();
  } catch (e) {
    if (e.message !== 'move-canceled') {
      toaster.pop('error', item.name, e.message);
      console.error('error moving', e, item);
      // Some errors aren't worth reporting
      if (
        e.code !== 'wrong-level' &&
        e.code !== 'no-space' &&
        e.code !== PlatformErrorCodes.DestinyCannotPerformActionAtThisLocation
      ) {
//.........这里部分代码省略.........
开发者ID:bhollis,项目名称:DIM,代码行数:101,代码来源:move-dropped-item.ts


示例16: success

let commandOK = (noun = "Command") => () => {
  let msg = noun + " request sent to device.";
  success(msg, t("Request sent"));
};
开发者ID:creimers,项目名称:Farmbot-Web-API,代码行数:4,代码来源:actions.ts


示例17: constructor

    constructor() {

        super();

        this.taxonomyModule = new TaxonomyModule();
        this.utilityModule = new UtilityModule();
        this.errorMessage = ko.observable("");
        this.wait = ko.observable(true);

        this.localStorageKey = i18n.t("siteMapLocalStorageKey");

        // The current language is determined at the entry point of the application
        // Instead of making a second call to get the current langauge, we get the corresponding resource value according to the current context (like we already do for LCID)
        let currentLanguage = i18n.t("LanguageLabel");
        let configListName = "Configuration";

        // Yamm3! MegaMenu
        $(document).on("click", ".yamm .dropdown-menu", (e) => {
            e.stopPropagation();
        });

        let filterQuery: string = "IntranetContentLanguage eq '" + currentLanguage + "'";

        // Read the configuration value from the configuration list and for the current langauge. We use a list item instead of a term set property to improve performances (SOD loading is slow compared to a simple REST call).
        pnp.sp.site.rootWeb.lists.getByTitle(configListName).items.filter(filterQuery).top(1).get().then((item) => {

            if (item.length > 0) {

                // Get the boolean value
                let noCache: boolean = item[0].ForceCacheRefresh;

                // Get the term set id
                let termSetId = item[0].SiteMapTermSetId;

                if (noCache) {

                        // Clear the local storage value
                        pnp.storage.local.delete(this.localStorageKey);

                        // Get navigation nodes
                        this.getNavigationNodes(termSetId);

                } else {

                    let navigationTree = this.utilityModule.isCacheValueValid(this.localStorageKey);

                    // Check if the local storage value is still valid (i.e not null)
                    if (navigationTree) {

                        this.initialize(navigationTree);
                        this.wait(false);

                        // Publish the data to all subscribers (contextual menu and breadcrumb) 
                        PubSub.publish("navigationNodes", { nodes: navigationTree } );

                    } else {

                        this.getNavigationNodes(termSetId);
                    }
                }

            } else {

                pnp.log.write("There is no configuration item for the site map for the language '" + currentLanguage + "'", pnp.LogLevel.Error);
            }

        }).catch(errorMesssage => {

            this.errorMessage(errorMesssage);

            pnp.log.write(errorMesssage, pnp.LogLevel.Error);
        });
    }
开发者ID:kaminagi107,项目名称:PnP,代码行数:73,代码来源:topnav.viewmodel.ts


示例18: async

    const doLoadout = async () => {
      if (allowUndo && !store.isVault) {
        reduxStore.dispatch(
          actions.savePreviousLoadout({
            storeId: store.id,
            loadoutId: loadout.id,
            previousLoadout: store.loadoutFromCurrentlyEquipped(
              t('Loadouts.Before', { name: loadout.name })
            )
          })
        );
      }

      let items: DimItem[] = copy(_.flatten(Object.values(loadout.items)));

      const loadoutItemIds = items.map((i) => {
        return {
          id: i.id,
          hash: i.hash
        };
      });

      // Only select stuff that needs to change state
      let totalItems = items.length;
      items = items.filter((pseudoItem) => {
        const item = getLoadoutItem(pseudoItem, store);
        // provide a more accurate count of total items
        if (!item) {
          totalItems--;
          return true;
        }

        const notAlreadyThere =
          item.owner !== store.id ||
          item.location.inPostmaster ||
          // Needs to be equipped. Stuff not marked "equip" doesn't
          // necessarily mean to de-equip it.
          (pseudoItem.equipped && !item.equipped) ||
          pseudoItem.amount > 1;

        return notAlreadyThere;
      });

      // only try to equip subclasses that are equippable, since we allow multiple in a loadout
      items = items.filter((item) => {
        const ok = item.type !== 'Class' || !item.equipped || item.canBeEquippedBy(store);
        if (!ok) {
          totalItems--;
        }
        return ok;
      });

      // vault can't equip
      if (store.isVault) {
        items.forEach((i) => {
          i.equipped = false;
        });
      }

      // We'll equip these all in one go!
      let itemsToEquip = items.filter((i) => i.equipped);
      if (itemsToEquip.length > 1) {
        // we'll use the equipItems function
        itemsToEquip.forEach((i) => {
          i.equipped = false;
        });
      }

      // Stuff that's equipped on another character. We can bulk-dequip these
      const itemsToDequip = items.filter((pseudoItem) => {
        const item = storeService.getItemAcrossStores(pseudoItem);
        return item && item.owner !== store.id && item.equipped;
      });

      const scope = {
        failed: 0,
        total: totalItems,
        successfulItems: [] as DimItem[]
      };

      if (itemsToDequip.length > 1) {
        const realItemsToDequip = _.compact(
          itemsToDequip.map((i) => storeService.getItemAcrossStores(i))
        );
        const dequips = _.map(
          _.groupBy(realItemsToDequip, (i) => i.owner),
          (dequipItems, owner) => {
            const equipItems = _.compact(
              dequipItems.map((i) => dimItemService.getSimilarItem(i, loadoutItemIds))
            );
            return dimItemService.equipItems(storeService.getStore(owner)!, equipItems);
          }
        );
        await Promise.all(dequips);
      }

      await applyLoadoutItems(store, items, loadoutItemIds, scope);

      let equippedItems: DimItem[];
      if (itemsToEquip.length > 1) {
//.........这里部分代码省略.........
开发者ID:w1cked,项目名称:DIM,代码行数:101,代码来源:loadout.service.ts


示例19: deleteRegimenErr

function deleteRegimenErr(payload: Error) {
  error(t("Unable to delete regimen."));
}
开发者ID:roryaronson,项目名称:farmbot-web-frontend,代码行数:3,代码来源:actions.ts


示例20: t

 failedItems.forEach((item) => {
   scope.failed++;
   toaster.pop('error', loadout.name, t('Loadouts.CouldNotEquip', { itemname: item.name }));
 });
开发者ID:w1cked,项目名称:DIM,代码行数:4,代码来源:loadout.service.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript i18next.use函数代码示例发布时间:2022-05-25
下一篇:
TypeScript i18next.removeResourceBundle函数代码示例发布时间: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