本文整理汇总了TypeScript中i18next.TranslationFunction.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TranslationFunction.default方法的具体用法?TypeScript TranslationFunction.default怎么用?TypeScript TranslationFunction.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i18next.TranslationFunction
的用法示例。
在下文中一共展示了TranslationFunction.default方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: t
.map(p => (
(p == null || p === '')
? t('Name cannot be empty')
: (duplicates.includes(p))
? t('Name cannot be repeated')
: ''
))
示例2: 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
}
示例3: 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
})
示例4: 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 ''
}
}
示例5: 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)
}
示例6: 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
}
示例7: 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
}
示例8: t
.map(theme => ({
value: theme,
label: t(theme)
}))