• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript translate.interpolate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了interpolate函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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


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


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


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


示例6: mktime

function mktime(t) {{{
    if (t < 60) {
        return interpolate(t === 1 ? _("1 second") : _("%s seconds"), [t]);
    }
    if (t < 3600) {
        let t1 = Math.floor(t / 60);
        let t2 = t % 60;

        return interpolate(t1 === 1 ? _("1 minute") : _("%s minutes"), [t1]) +
                (t2 ? " " + interpolate(_("%s seconds"), [t2]) : "");
    }
    if (t < 86400) {
        let t1 = Math.floor(t / 3600);
        let t2 = (t % 3600) / 60;

        return interpolate(t1 === 1 ? _("1 hour") : _("%s hours"), [t1]) +
                (t2 ?  (" " + interpolate(_("%s minutes"), [t2])) : "");
    }

    let t1 = Math.floor(t / 86400);
    let t2 = (t % 86400) / 3600;

    return interpolate(t1 === 1 ? _("1 day") : _("%s days"), [t1]) +
            (t2 ?  (" " + interpolate(_("%s hours"), [t2])) : "");
}}}
开发者ID:PowerOlive,项目名称:online-go.com,代码行数:25,代码来源:util.ts


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript translate.pgettext函数代码示例发布时间:2022-05-25
下一篇:
TypeScript translate._函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap