本文整理汇总了TypeScript中translate.pgettext函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pgettext函数的具体用法?TypeScript pgettext怎么用?TypeScript pgettext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pgettext函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: shortShortTimeControl
export function shortShortTimeControl(time_control) { /* {{{ */
if (typeof(time_control) !== "object") {
return "~" + shortDurationString(time_control);
}
switch (time_control.system || time_control.time_control) {
case "simple":
return interpolate(pgettext("Simple time: <time>/move", "%s/move"), [shortDurationString(time_control.per_move).toLowerCase()]);
case "fischer":
return interpolate(pgettext("Fischer time", "%s+%s up to %s"), [
shortDurationString(time_control.initial_time).toLowerCase(),
shortDurationString(time_control.time_increment).toLowerCase(),
shortDurationString(time_control.max_time).toLowerCase()
]);
case "byoyomi":
return interpolate(pgettext("Japanese Byo-Yomi", "%s+%sx%s"), [
shortDurationString(time_control.main_time).toLowerCase(),
time_control.periods,
shortDurationString(time_control.period_time).toLowerCase().trim()
]);
case "canadian":
return interpolate(pgettext("Canadian Byo-Yomi", "%s+%s/%s"), [
shortDurationString(time_control.main_time).toLowerCase(),
shortDurationString(time_control.period_time).toLowerCase(),
time_control.stones_per_period
]);
case "absolute":
return shortDurationString(time_control.total_time).toLowerCase();
case "none":
return _("None");
default:
return "[error: " + (time_control.system || time_control.time_control) + "]";
}
} /* }}} */
示例2: shortDurationString
export function shortDurationString(seconds) { /* {{{ */
let weeks = Math.floor(seconds / (86400 * 7)); seconds -= weeks * 86400 * 7;
let days = Math.floor(seconds / 86400); seconds -= days * 86400;
let hours = Math.floor(seconds / 3600); seconds -= hours * 3600;
let minutes = Math.floor(seconds / 60); seconds -= minutes * 60;
return "" +
(weeks ? " " + interpolate(pgettext("Short time (weeks)", "%swk"), [weeks]) : "") +
(days ? " " + interpolate(pgettext("Short time (days)", "%sd"), [days]) : "") +
(hours ? " " + interpolate(pgettext("Short time (hours)", "%sh"), [hours]) : "") +
(minutes ? " " + interpolate(pgettext("Short time (minutes)", "%sm"), [minutes]) : "") +
(seconds ? " " + interpolate(pgettext("Short time (seconds)", "%ss"), [seconds]) : "");
} /* }}} */
示例3: getOutcomeTranslation
export function getOutcomeTranslation(outcome:string) { /* {{{ */
/* Note: for the case statements, don't simply do `pgettext("Game outcome", outcome)`,
* the system to parse out strings to translate needs the text. */
switch (outcome) {
case 'resign':
case 'r':
case 'Resignation':
return pgettext("Game outcome", 'Resignation');
case 'Stone Removal Timeout':
return pgettext("Game outcome", 'Stone Removal Timeout');
case 'Timeout':
return pgettext("Game outcome", 'Timeout');
case 'Cancellation':
return pgettext("Game outcome", 'Cancellation');
case 'Disqualification':
return pgettext("Game outcome", 'Disqualification');
case 'Moderator Decision':
return pgettext("Game outcome", 'Moderator Decision');
case 'Abandonment':
return pgettext("Game outcome", 'Abandonment');
}
if (/[0-9.]+/.test(outcome)) {
let num = outcome.match(/([0-9.]+)/)[1];
return interpolate(pgettext("Game outcome", "{{number}} points"), {"number": num});
}
return outcome;
} /* }}} */
示例4: rankString
export function rankString(r) {
if (typeof(r) === "object") {
let ranking = "ranking" in r ? r.ranking : r.rank;
if (r.pro || r.professional) {
return interpolate(pgettext("Pro", "%sp"), [((ranking - 36))]);
}
r = ranking;
}
if (r > 900) {
return interpolate(pgettext("Pro", "%sp"), [(((r - 1000) - 36))]);
}
if (r < -900) {
return "?";
}
if (r < 30) {
return interpolate(pgettext("Kyu", "%sk"), [(30 - r)]);
}
return interpolate(pgettext("Dan", "%sd"), [((r - 30) + 1)]);
}
示例5: timeControlSystemText
export function timeControlSystemText(system) { /* {{{ */
switch (system) {
case "simple" : return pgettext("time control system", "simple");
case "fischer" : return pgettext("time control system", "fischer");
case "byoyomi" : return pgettext("time control system", "byo-yomi");
case "canadian" : return pgettext("time control system", "canadian byo-yomi");
case "absolute" : return pgettext("time control system", "absolute");
case "none" : return pgettext("time control system", "none");
default : return "[error]";
}
} /* }}} */