tachybase_todo/packages/plugins/@nocobase/plugin-client/src/server/cronstrue.ts

114 lines
2.1 KiB
TypeScript
Raw Normal View History

const methods = [
'atX0SecondsPastTheMinuteGt20',
'atX0MinutesPastTheHourGt20',
'commaMonthX0ThroughMonthX1',
'commaYearX0ThroughYearX1',
'use24HourTimeFormatByDefault',
'anErrorOccuredWhenGeneratingTheExpressionD',
'everyMinute',
'everyHour',
'atSpace',
'everyMinuteBetweenX0AndX1',
'at',
'spaceAnd',
'everySecond',
'everyX0Seconds',
'secondsX0ThroughX1PastTheMinute',
'atX0SecondsPastTheMinute',
'everyX0Minutes',
'minutesX0ThroughX1PastTheHour',
'atX0MinutesPastTheHour',
'everyX0Hours',
'betweenX0AndX1',
'atX0',
'commaEveryDay',
'commaEveryX0DaysOfTheWeek',
'commaX0ThroughX1',
'commaAndX0ThroughX1',
'first',
'second',
'third',
'fourth',
'fifth',
'commaOnThe',
'spaceX0OfTheMonth',
'lastDay',
'commaOnTheLastX0OfTheMonth',
'commaOnlyOnX0',
'commaAndOnX0',
'commaEveryX0Months',
'commaOnlyInX0',
'commaOnTheLastDayOfTheMonth',
'commaOnTheLastWeekdayOfTheMonth',
'commaDaysBeforeTheLastDayOfTheMonth',
'firstWeekday',
'weekdayNearestDayX0',
'commaOnTheX0OfTheMonth',
'commaEveryX0Days',
'commaBetweenDayX0AndX1OfTheMonth',
'commaOnDayX0OfTheMonth',
'commaEveryHour',
'commaEveryX0Years',
'commaStartingX0',
'daysOfTheWeek',
'monthsOfTheYear',
];
const langs = {
af: 'af',
ar: 'ar',
be: 'be',
ca: 'ca',
cs: 'cs',
da: 'da',
de: 'de',
'en-US': 'en',
es: 'es',
fa: 'fa',
fi: 'fi',
fr: 'fr',
he: 'he',
hu: 'hu',
id: 'id',
it: 'it',
'ja-JP': 'ja',
ko: 'ko',
nb: 'nb',
nl: 'nl',
pl: 'pl',
pt_BR: 'pt_BR',
pt_PT: 'pt_PT',
ro: 'ro',
'ru-RU': 'ru',
sk: 'sk',
sl: 'sl',
sv: 'sv',
sw: 'sw',
'th-TH': 'th',
'tr-TR': 'tr',
uk: 'uk',
'zh-CN': 'zh_CN',
'zh-TW': 'zh_TW',
};
export const getCronstrueLocale = (lang) => {
const lng = langs[lang] || 'en';
const Locale = require(`cronstrue/locales/${lng}`);
let locale;
if (Locale?.default) {
locale = Locale.default.locales[lng];
} else {
const L = Locale[lng];
locale = new L();
}
const items = {};
for (const method of methods) {
try {
items[method] = locale[method]();
refactor!: plugins build and plugins load (#2253) * refactor: plugin build and plugin template * refactor: plugins' deps * refactor: plugins bugs * feat: add plugin static middleware * fix: bugs * refactor: frontend plugin add from remote * refactor: delete useless app/client/plugins * fix: requirejs move to local * fix: tests case * refactor: add src/client and src/server dir check * fix: lodash tree shaking * refactor: add BUILD_TIP * refactor: add file size tip * fix: bugs * fix: bug * fix: change china-division * fix: change plugins response * fix: recover dynamicImport * fix: change server src entry * fix: test error * fix: plugins sourcemap => false * fix: production file error * refactor: change build tools to vite and tsup * fix: yarn.lock * fix: bugs * fix: server build bugs * fix: delete .fatherrc.ts * fix: bug * fix: bug * fix: bugs * fix: bugs * fix: bugs * refactor: add plugin d.ts * refactor: delete fatherrc * refactor: delete father scripts * refactor: build bug * fix: bug * fix: deps adjust * fix: add build tips * fix: bug * refactor: ignore plugins when build client * docs: update doc * refactor: docs and build * fix: bug * refactor: build deps * fix: add USER_REMOTE_PLUGIN env * feat: add plugin static cache * feat: add build deps cache * fix: bugs * test: add test * fix: add plugin depden on plugin tip * fix: adjust shouldDevDependencies * fix: deps * fix: ajust deps * fix: mobile style error * fix: map error * fix: test * fix: bug * feat: lodash and dayjs import from themself * feat: @emotion/css 、ahooks and lodash to global * fix: theme-editor plugin error * fix: review * feat: move all plugins' dependencies to devDependencies * feat: change build * feat: add devPlugins * fix: bug * fix: bugs * fix: bugs * fix: bugs * feat: build bugs * fix: bugs * fix: bugs * fix: review * fix: bug * fix: change deps build * fix: bugs * fix: bug * fix: bug * fix: bugs * fix: bug * fix: bug * fix: multi language * fix: dist * fix: cronstrue * fix: getPackageClientStaticUrl * fix: antd dayjs locale * fix: plugin' d.ts import from dist * fix: multi language * fix: build types error * fix: requireModule * fix: plugin lifecycle * fix: client resource * fix: improve code * fix: locale * feat: custom build * fix: require locale * fix: improve code * fix: improve code * fix: skip preset * fix: collection undefined * feat: yarn build * fix: remove enabled * fix: update dockerfile * fix: formily version * docs: update v12 changelog * fix: devDependencies * feat: @nocobase/app * feat: generateAppDir * fix: improve code * fix: 0.11.1-alpha.5 * fix: missing @nocobase/client * fix: error * fix: add .npmignore * feat: upgrade antd version * fix: dependencies * fix: peerDependencies * fix: remove china-division dep * fix: toposort deps * fix: update dockerfile * fix: plugin template * fix: app client outputPath * feat: update docs * fix: nginx server root * fix: storage/.app-dev * fix: getChinaDivisionData * feat: plugin info * feat: update docs * fix: docs menu --------- Co-authored-by: chenos <chenlinxh@gmail.com>
2023-08-02 00:07:52 +08:00
} catch (error) {
// empty
}
}
return items;
};