當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript i18next.TranslationFunction類代碼示例

本文整理匯總了TypeScript中i18next.TranslationFunction的典型用法代碼示例。如果您正苦於以下問題:TypeScript TranslationFunction類的具體用法?TypeScript TranslationFunction怎麽用?TypeScript TranslationFunction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TranslationFunction類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: validateMisc

function validateMisc(playerNames: string[], t: TranslationFunction): string | null {
  if (playerNames.length < 2) {
    return t('At least 2 players is required for a game')
  } else if (playerNames.length > playerUpperLimit) {
    return t('Too many players. Upper limit is {{limit}} players.', {limit: playerUpperLimit})
  }
  return null
}
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:8,代碼來源:entry-validator.ts

示例2: t

 (stage: GameStage | null, currentRound: number | null, rounds: number | null, t: TranslationFunction): string => {
   if (stage == null) {
     return ''
   } else if (stage === GameStage.waitingBid || stage === GameStage.waitingWin) {
     return t('Round {{currentRound}} of {{rounds}}', {currentRound, rounds})
   } else if (stage === GameStage.ended) {
     return t('Game over')
   } else {
     return ''
   }
 }
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:11,代碼來源:game-title.ts

示例3: validateWin

function validateWin(opts: IStackInput, t: TranslationFunction): IPlayerMap<string> | null {
  if (!opts.win || /* Is empty? */isOk(opts.win)) {
    return null
  }
  const sum: number = sumBy(Object.entries(opts.win), ([, value]) => value)
  if (sum === opts.currentRound) {
    return null
  }
  const msg = sum > opts.currentRound
    ? t('Too many stacks')
    : t('Too less stacks')
  return mapValues(opts.win, () => msg)
}
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:13,代碼來源:stack-input-validator.ts

示例4: validateMisc

function validateMisc(names: IPlayerMap<string>, currentRound: number, expectedRounds: number, t: TranslationFunction): string | null {
  const size = Object.keys(names).length
  if (size < 2) {
    return t('At least 2 players is required for a game')
  }
  if (size > playerUpperLimit) {
    return t('Too many players. Upper limit is {{limit}} players.', {limit: playerUpperLimit})
  }
  if (expectedRounds < currentRound) {
    return t('Impossible to continue the game due to too many players')
  }
  return null
}
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:13,代碼來源:settings-validator.ts

示例5: validateBid

function validateBid(opts: IStackInput, t: TranslationFunction): IPlayerMap<string> | null {
  if (!opts.bid) {
    return null
  }
  const sum: number = sumBy(Object.entries(opts.bid), ([, value]) => value)
  return sum === opts.currentRound
    ? {[opts.lastPlayerID]: t('Cannot choose that')}
    : null
}
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:9,代碼來源:stack-input-validator.ts

示例6: t

 .map(p => (
   (p == null || p === '')
     ? t('Name cannot be empty')
     : (duplicates.includes(p))
       ? t('Name cannot be repeated')
       : ''
 ))
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:7,代碼來源:entry-validator.ts

示例7: t

 const res: IPlayerMap<string | null> = mapValues(names, (name: string) => {
   if (name === '') {
     return t('Name cannot be empty')
   }
   if (duplicates.includes(name)) {
     return t('Name cannot be repeated')
   }
   return null
 })
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:9,代碼來源:settings-validator.ts

示例8: t

 .map(theme => ({
   value: theme,
   label: t(theme)
 }))
開發者ID:Holi0317,項目名稱:bridge-calc,代碼行數:4,代碼來源:theme-sources.ts


注:本文中的i18next.TranslationFunction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。