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


TypeScript translate.pgettext函數代碼示例

本文整理匯總了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) + "]";
    }
}  /* }}} */
開發者ID:PowerOlive,項目名稱:online-go.com,代碼行數:34,代碼來源:util.ts

示例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]) : "");
} /* }}} */
開發者ID:PowerOlive,項目名稱:online-go.com,代碼行數:12,代碼來源:util.ts

示例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;
} /* }}} */
開發者ID:PowerOlive,項目名稱:online-go.com,代碼行數:30,代碼來源:misc.ts

示例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)]);
}
開發者ID:PowerOlive,項目名稱:online-go.com,代碼行數:20,代碼來源:rank_utils.ts

示例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]";
    }
} /* }}} */
開發者ID:PowerOlive,項目名稱:online-go.com,代碼行數:11,代碼來源:util.ts


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