当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript translate._函数代码示例

本文整理汇总了TypeScript中translate._函数的典型用法代码示例。如果您正苦于以下问题:TypeScript _函数的具体用法?TypeScript _怎么用?TypeScript _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: old_getTimeControlText

} /* }}} */
function old_getTimeControlText(time_control_system, time_per_move) { /* This is old but STILL NEEDED (for archived games) {{{ */
    let time_control_text = "";
    let time = old_computeTimeControl(time_control_system, time_per_move);
    switch (time_control_system) {
        case "simple":
            time_control_text = interpolate(_("%s per move"), [durationString(time.per_move)]);
            break;
        case "fischer":
            time_control_text = interpolate(_("%s starting time<br/>plus %s per move<br/> up to a maximum of %s"), [
                                    durationString(time.initial),
                                    durationString(time.per_move),
                                    durationString(time.max)]);
            break;
        case "canadian":
            time_control_text = interpolate(_("%s thinking time<br/>%s per %s moves after that"),
                                    [durationString(time.initial), durationString(Math.min(86400 * 21, time.per_move * time.moves)), time.moves]);
            break;
        case "absolute":
            time_control_text = interpolate(_("%s total play time per player"), [durationString(time.initial)]);
            break;
        case "none":
            $("#time_per_move").attr("disabled", "disabled");
            time_control_text = _("No time limits.");
            break;

    }
    return time_control_text;
} /* }}} */
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:29,代码来源:util.ts

示例2: 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

示例3: errorAlerter

export function errorAlerter(...args) {{{
    let err = getPrintableError(args[0]);
    if (!err) {
        return;
    }
    swal({
        title: _(err.substring(0, 128)),
        type: "error"
    });
    console.error(err);
}}}
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:11,代码来源:misc.ts

示例4: longRankString

export function longRankString(r) {
    if (typeof(r) === "object") {
        if (r.pro) {
            return interpolate(_("%s Pro"), [((r.ranking - 36))]);
        }
        r = r.ranking;
    }
    if (r > 900) {
        return interpolate(_("%s Pro"), [(((r - 1000) - 36))]);
    }

    if (r < -900) {
        return "?";
    }

    if (r < 30) {
        return interpolate(_("%s Kyu"), [(30 - r)]);
    }
    return interpolate(_("%s Dan"), [((r - 30) + 1)]);
}
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:20,代码来源:rank_utils.ts

示例5: alertModerator

export function alertModerator(obj) {{{
    swal({
        text: (obj.user ? _("Report user:") + " " : "") +
            _("Please provide a brief description of the problem"),
        input: "text",
        showCancelButton: true,
    }).then((description) => {
        if (description.length < 5) {
            alertModerator(obj);
            return;
        }
        obj.note = description;
        post("moderation/incident", obj)
        .then(() => {
            swal({text: _("Thanks for the report!")});
        })
        .catch(errorAlerter)
        ;
    })
    .catch(ignore);
}}}
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:21,代码来源:misc.ts

示例6: getGameResultText

export function getGameResultText(game) { /* {{{ */
    /* SGFs will encode the full result in the outcome */
    if (/[+]/.test(game.outcome)) {
        return game.outcome;
    }

    let winner = "";
    let result = "";
    if (game.white_lost && game.black_lost) {
        winner = _("Tie");
    } else if (game.white_lost) {
        winner = _("B");
    } else if (game.black_lost) {
        winner = _("W");
    } else {
        winner = _("Tie");
    }

    game.outcome = game.outcome.replace(" points", "");
    result += winner + "+"  + getOutcomeTranslation(game.outcome);

    if (game.ranked) {
        result += ", ";
        result += _("ranked");
    }
    if (game.annulled) {
        result += ", ";
        result += _("annulled");
    }
    return result;
} /* }}} */
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:31,代码来源:misc.ts

示例7: fullDurationString

export function fullDurationString(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;

    function plurality(num, single, plural) {
        num = Math.round(num);
        if (num > 0) {
            if (num === 1) {
                return num + " " + single;
            }
            return num + " " + plural;
        }
        return "";
    }

    return "" +
        (weeks ? " " + plurality(weeks, _("Week"), _("Weeks")) : "") +
        (days ? " " + plurality(days, _("Day"), _("Days")) : "") +
        (hours ? " " + plurality(hours, _("Hour"), _("Hours")) : "") +
        (minutes ? " " + plurality(minutes, _("Minute"), _("Minutes")) : "") +
        (seconds ? " " + plurality(seconds, _("Second"), _("Seconds")) : "");
} /* }}} */
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:24,代码来源:util.ts

示例8: timeControlDescription

export function timeControlDescription(time_control, old_time_per_move?) { /* {{{ */
    if (old_time_per_move) {
        return old_getTimeControlText(time_control, old_time_per_move);
    }

    let ret = "";

    switch (time_control && (time_control.system || time_control.time_control)) {
        case "simple":
            ret = interpolate(_("Simple: %s per move."), [durationString(time_control.per_move).toLowerCase()]);
            break;
        case "fischer":
            ret = interpolate(_("Fischer: Clock starts with %s and increments by %s per move up to a maximum of %s."), [
                                    durationString(time_control.initial_time).toLowerCase(),
                                    durationString(time_control.time_increment).toLowerCase(),
                                    durationString(time_control.max_time).toLowerCase()
                                ]);
            break;
        case "byoyomi":
            ret = interpolate(_("Japanese Byo-Yomi: Clock starts with %s main time, followed by %s %s periods."), [
                                    durationString(time_control.main_time).toLowerCase(),
                                    time_control.periods,
                                    durationString(time_control.period_time).toLowerCase()
                                ]);

            break;
        case "canadian":
            ret = interpolate(_("Canadian Byo-Yomi: Clock starts with %s main time, followed by %s per %s stones."), [
                                    durationString(time_control.main_time).toLowerCase(),
                                    durationString(time_control.period_time).toLowerCase(),
                                    time_control.stones_per_period
                                ]);
            break;
        case "absolute":
            ret = interpolate(_("Absolute: %s total play time per player."), [durationString(time_control.total_time).toLowerCase()]);
            break;
        case "none":
            ret = _("No time limits.");
            break;
        default:
            ret = "[No time control description for " + (time_control && (time_control.system || time_control.time_control)) + "]";
            break;
    }

    if (time_control && time_control.pause_on_weekends) {
        ret += " " + _("Pauses on weekends");
    }

    return ret;
}  /* }}} */
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:50,代码来源:util.ts

示例9: rulesText

export function rulesText(rules) { /* {{{ */
    if (!rules) {
        return "[unknown]";
    }

    switch (rules.toLowerCase()) {
        case "aga": return _("AGA");
        case "japanese": return _("Japanese");
        case "korean": return _("Korean");
        case "chinese": return _("Chinese");
        case "ing": return _("Ing");
        case "nz": return _("New Zealand");
    }
    return "[unknown]";
} /* }}} */
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:15,代码来源:misc.ts

示例10: timeControlSystemText

export function timeControlSystemText(system) { /* {{{ */
    if (!system) {
        return "[unknown]";
    }

    switch (system.toLowerCase()) {
        case "fischer": return _("Fischer");
        case "simple": return _("Simple");
        case "byoyomi": return _("Byo-Yomi");
        case "canadian": return _("Canadian");
        case "absolute": return _("Absolute");
        case "none": return _("None");
    }
    return "[unknown]";
} /* }}} */
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:15,代码来源:misc.ts


注:本文中的translate._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。