语言环境
你可以使用 locale 获取或设置持续时间的区域设置。语言环境会影响持续时间的字符串方法,例如 humanize()。有关国际化的更多信息,请参阅 国际化 部分。
¥You can get or set the locale of a duration using locale. The locale will affect the duration's string methods, like humanize(). See the i18n section for more information on internationalization generally.
This requires the
RelativeTime
plugin to work
require("dayjs/locale/es");
// import es from 'dayjs/plugin/es' // ES 2015
dayjs.duration(1, "minutes").locale("en").humanize(); // a minute
dayjs.duration(1, "minutes").locale("es").humanize(); // un minuto
// dayjs.duration(1, "minutes").locale(es).humanize(); // ES 2015
