我们将构建多语言网络应用程序,我们考虑使用 Yarp's Timeago jQuery plugin.
但我们希望在我们的应用程序中支持阿拉伯语。您可能知道阿拉伯语有不同的方式来处理单数,复数和“双重”
e.g。
那么有没有办法在不影响英语的情况下支持阿拉伯语?
答案 0 :(得分: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));