the relative date in Chinese language has unnecessary spaces,
usually the date format should be “mm月dd日” , the current format is “mm月 dd 日” ,
I haven’t found any issue with the translation, and also I think the ember helper lead to this issue
import jQuery from "jquery";
import deprecated from "discourse-common/lib/deprecated";
import { helperContext, makeArray } from "discourse-common/lib/helpers";
import I18n from "discourse-i18n";
export function shortDate(date) {
return moment(date).format(I18n.t("dates.medium.date_year"));
}
export function shortDateNoYear(date) {
return moment(date).format(I18n.t("dates.tiny.date_month"));
}
// Suppress year if it's this year
export function smartShortDate(date, withYear = tinyDateYear) {
return date.getFullYear() === new Date().getFullYear()
? shortDateNoYear(date)
: withYear(date);
}
This file has been truncated. show original
I think function autoUpdatingRelativeAge adds the extra spaces.
I understand this is not an issue for English version discourse, but may cause some format issues for other languages.
I tried javascript to remove the spaces, but it won’t work with the lazy loading content.
I’m appreciated to any tips for modifying the ember helper in a plugin or any fix from the main branch.
Alteras
(Steven Chang)
2024 年8 月 27 日 23:17
2
这似乎是由于 locale 文件中的日期格式字符串导致的 Bug ,影响了简体中文。查看 git 历史记录,在 v3.3.0 中,格式如下:
percent: "%{count}%"
short:
thousands: "%{number}k"
millions: "%{number}M"
dates:
time: "HH:mm"
time_with_zone: "HH:mm (z)"
time_short_day: "ddd, HH:mm"
timeline_date: "YYYY 年 M 月"
long_no_year: "M 月 D 日 HH:mm"
long_no_year_no_time: "M 月 D 日"
full_no_year_no_time: "M 月 D 日"
long_with_year: "YYYY 年 M 月 D 日 HH:mm"
long_with_year_no_time: "YYYY 年 M 月 D 日"
full_with_year_no_time: "YYYY 年 M 月 D 日"
long_date_with_year: "YYYY 年 MMM 月 D 日 LT"
long_date_without_year: "M 月 D 日 LT"
long_date_with_year_without_time: "YYYY 年 MMM 月 D 日"
long_date_without_year_with_linebreak: "M 月 D 日<br/>LT"
long_date_with_year_with_linebreak: "YYYY 年 MMM 月 D 日<br/>LT"
wrap_ago: "%{date} 前"
它们最近似乎已更新为(在 3.4.0.beta1-dev 中已确认 live):
percent: "%{count}%"
short:
thousands: "%{number}k"
millions: "%{number}M"
dates:
time: "HH:mm"
time_with_zone: "HH:mm (z)"
time_short_day: "ddd, HH:mm"
timeline_date: "YYYY 年 MMM"
long_no_year: "MMM D 日 HH:mm"
long_no_year_no_time: "MMM D 日"
full_no_year_no_time: "MMMM Do 日"
long_with_year: "YYYY 年 MMM D 日 HH:mm"
long_with_year_no_time: "YYYY 年 MMM D 日"
full_with_year_no_time: "YYYY 年 MMMM Do 日"
long_date_with_year: "YYYY 年 MMM D 日 LT"
long_date_without_year: "MMM D 日 LT"
long_date_with_year_without_time: "YYYY 年 MMM D 日"
long_date_without_year_with_linebreak: "MMM D 日<br/>LT"
long_date_with_year_with_linebreak: "YYYY 年 MMM D 日<br/>LT"
wrap_ago: "%{date} 前"
在 codepen 中使用默认的 Momentjs 配置 zh-cn 测试格式字符串 \"MMM D 日\",会产生观察到的缺陷(即 \"8月 2 日\")。
作为即时修复,您可以通过修改 js.dates.tiny.date_month 和 js.dates.long_no_year_no_time 的翻译来更改格式,如下所示:
2 个赞