mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-13 02:49:37 +00:00
d1c51f4af8
1. new translation docs 2. lazy-load TimeAgo locales (used for "x min ago" messages). This 1. reduces size and 2. provides all languages without adding them manually. 3. Remove DayJS locales, they're unused.
18 lines
528 B
TypeScript
18 lines
528 B
TypeScript
import TimeAgo from 'javascript-time-ago';
|
|
import en from 'javascript-time-ago/locale/en.json';
|
|
|
|
import { getUserLanguage } from '~/utils/locale';
|
|
|
|
TimeAgo.addDefaultLocale(en);
|
|
|
|
const addedLocales = ['en'];
|
|
|
|
export default () => new TimeAgo(getUserLanguage());
|
|
export async function loadTimeAgoLocale(locale: string) {
|
|
if (!addedLocales.includes(locale)) {
|
|
const { default: timeAgoLocale } = await import(`~/assets/timeAgoLocales/${locale}.js`);
|
|
TimeAgo.addLocale(timeAgoLocale);
|
|
addedLocales.push(locale);
|
|
}
|
|
}
|