fix: using the global cron locale

This commit is contained in:
chenos 2024-06-19 17:52:34 +08:00
parent 173dfbfe21
commit 8586992219

View File

@ -7,16 +7,11 @@
* For more information, please refer to: https://www.nocobase.com/agreement. * For more information, please refer to: https://www.nocobase.com/agreement.
*/ */
import { css, useAPIClient } from '@nocobase/client'; import { css } from '@nocobase/client';
import { InputNumber, Select } from 'antd'; import { InputNumber, Select } from 'antd';
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { Cron } from 'react-js-cron'; import { Cron } from 'react-js-cron';
import { useWorkflowTranslation } from '../../locale'; import { useWorkflowTranslation } from '../../locale';
import CronZhCN from './locale/Cron.zh-CN';
const languages = {
'zh-CN': CronZhCN,
};
const RepeatOptions = [ const RepeatOptions = [
{ value: 'none', text: 'No repeat' }, { value: 'none', text: 'No repeat' },
@ -65,7 +60,6 @@ function CommonRepeatField({ value, onChange }) {
export function RepeatField({ value = null, onChange }) { export function RepeatField({ value = null, onChange }) {
const { t } = useWorkflowTranslation(); const { t } = useWorkflowTranslation();
const api = useAPIClient();
const typeValue = getRepeatTypeValue(value); const typeValue = getRepeatTypeValue(value);
const onTypeChange = useCallback( const onTypeChange = useCallback(
(v) => { (v) => {
@ -82,8 +76,6 @@ export function RepeatField({ value = null, onChange }) {
[onChange], [onChange],
); );
const locale = languages[localStorage.getItem(api.auth.locale) || 'en-US'];
return ( return (
<fieldset <fieldset
className={css` className={css`
@ -130,7 +122,7 @@ export function RepeatField({ value = null, onChange }) {
value={value.trim().split(/\s+/).slice(1).join(' ')} value={value.trim().split(/\s+/).slice(1).join(' ')}
setValue={(v) => onChange(`0 ${v}`)} setValue={(v) => onChange(`0 ${v}`)}
clearButton={false} clearButton={false}
locale={locale} locale={window['cronLocale']}
/> />
) : null} ) : null}
</fieldset> </fieldset>