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


TypeScript i18next.t函数代码示例

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


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


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