3

我们将构建多语言 Web 应用程序,并考虑使用Yarp 的 Timeago jQuery 插件。

但我们希望在我们的应用程序中支持阿拉伯语。正如您可能知道的那样,阿拉伯语有不同的方式来处理单数、复数和“双”

例如

  • 1 分钟 => دقيقة单数
  • 2 分钟 => دقيقتين
  • 3-10 分钟 => 3 دقائق复数
  • 超过 10 分钟 => 11 دقيقة单数

那么有没有办法在不影响英语的情况下支持阿拉伯语呢?

4

1 回答 1

1

我最终得到了库的更新版本,这里是新的 js 代码:

strings: {
    prefixAgo: null,
    prefixFromNow: null,
    suffixAgo: "ago",
    suffixFromNow: "from now",
    seconds: "less than a minute",
    minute: "about a minute",
    twominute: "%d minutes",
    lessthanorequaltwominutes: "%d minutes",
    lessthanorequaltenminutes: "%d minutes",
    minutes: "%d minutes",
    hour: "about an hour",
    twohour: "about %d hours",
    lessthanorequaltwohours: "about %d hours",
    lessthanorequaltenhours: "about %d hours",
    hours: "about %d hours",
    day: "a day",
    twoday: "%d days",
    lessthanorequaltwodays: "%d days",
    lessthanorequaltendays: "%d days",
    days: "%d days",
    month: "about a month",
    twomonth: "%d months",
    lessthanorequaltwomonths: "%d months",
    lessthanorequaltenmonths: "%d months",
    months: "%d months",
    year: "about a year",
    twoyear: "%d years",
    lessthanorequaltwoyears: "%d years",
    lessthanorequaltenyears: "%d years",
    years: "%d years",
    wordSeparator: " ",
    numbers: []
}

还有一个地方需要更新到:

var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
    seconds < 90 && substitute($l.minute, 1) ||
    seconds > 90 && seconds < 120 && substitute($l.lessthanorequaltwominutes, 1) ||
    minutes >= 2 && minutes < 3 && substitute($l.twominute, 2) ||
    minutes < 11 && substitute($l.lessthanorequaltenminutes, Math.round(minutes)) ||
    minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
    minutes < 90 && substitute($l.hour, 1) ||
    minutes < 121 && minutes > 90 && substitute($l.lessthanorequaltwohours, 2) ||
    hours >= 2 && hours < 3 && substitute($l.twohour, 2) ||
    hours < 11 && substitute($l.lessthanorequaltenhours, Math.round(hours)) ||
    hours < 24 && substitute($l.hours, Math.round(hours)) ||
    hours < 42 && substitute($l.day, 1) ||
    hours < 48 && hours > 42 && substitute($l.lessthanorequaltwodays, 2) ||
    days >= 2 && days < 3 && substitute($l.twoday, 2) ||
    days < 11 && substitute($l.lessthanorequaltendays, Math.round(days)) ||
    days < 30 && substitute($l.days, Math.round(days)) ||
    days < 45 && substitute($l.month, 1) ||
    days > 59 && days < 63 && substitute($l.twomonth, 2) ||
    days < 75 && days > 45 && substitute($l.lessthanorequaltwomonths, 2) ||
    days < 310 && substitute($l.lessthanorequaltenmonths, Math.round(days / 30)) ||
    days < 365 && substitute($l.months, Math.round(days / 30)) ||
    days > 365 && days < 485 && substitute($l.year, 1) ||
    days > 485 && years < 2 && substitute($l.lessthanorequaltwoyears, 2) ||
    years >= 2 && years < 3 && substitute($l.twoyear, 2) ||
    years < 11 && substitute($l.lessthanorequaltenyears, Math.round(years)) ||
    years < 1.5 && substitute($l.year, 1) ||
    substitute($l.years, Math.round(years));
于 2013-04-05T18:46:21.067 回答