本文整理匯總了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
}
示例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 ''
}
}
示例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)
}
示例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
}
示例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
}
示例6: t
.map(p => (
(p == null || p === '')
? t('Name cannot be empty')
: (duplicates.includes(p))
? t('Name cannot be repeated')
: ''
))
示例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
})
示例8: t
.map(theme => ({
value: theme,
label: t(theme)
}))