Migrate to lingui
Switch to "lingui" for better DX. Tried to persist existing languages as much as possible. Removed "vite-plugin-node-polyfills" because it's incompatible with "lingui"
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import List from '@mui/material/List';
|
||||
import ListItem from '@mui/material/ListItem';
|
||||
import ListItemText from '@mui/material/ListItemText';
|
||||
import Switch from '@mui/material/Switch';
|
||||
import { useCallback } from 'react';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { NumberSetting } from '@/base/components/settings/NumberSetting.tsx';
|
||||
import { getPersistedServerSetting, usePersistedValue } from '@/base/hooks/usePersistedValue.tsx';
|
||||
@@ -27,7 +27,7 @@ export const WebUIUpdateIntervalSetting = ({
|
||||
disabled?: boolean;
|
||||
updateCheckInterval: ServerSettings['webUIUpdateCheckInterval'];
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useLingui();
|
||||
|
||||
const shouldAutoUpdate = !!updateCheckInterval;
|
||||
const [mutateSettings] = requestManager.useUpdateServerSettings();
|
||||
@@ -44,7 +44,7 @@ export const WebUIUpdateIntervalSetting = ({
|
||||
webUIUpdateCheckInterval === 0 ? currentUpdateCheckInterval : webUIUpdateCheckInterval,
|
||||
);
|
||||
mutateSettings({ variables: { input: { settings: { webUIUpdateCheckInterval } } } }).catch((e) =>
|
||||
makeToast(t('global.error.label.failed_to_save_changes'), 'error', getErrorMessage(e)),
|
||||
makeToast(t`Failed to save changes`, 'error', getErrorMessage(e)),
|
||||
);
|
||||
},
|
||||
[currentUpdateCheckInterval],
|
||||
@@ -58,7 +58,7 @@ export const WebUIUpdateIntervalSetting = ({
|
||||
return (
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText primary={t('settings.webui.auto_update.label.title')} />
|
||||
<ListItemText primary={t`Automatically download the latest version`} />
|
||||
<Switch
|
||||
disabled={disabled}
|
||||
edge="end"
|
||||
@@ -67,16 +67,14 @@ export const WebUIUpdateIntervalSetting = ({
|
||||
/>
|
||||
</ListItem>
|
||||
<NumberSetting
|
||||
settingTitle={t('settings.webui.auto_update.label.interval')}
|
||||
settingValue={t('library.settings.global_update.auto_update.interval.label.value', {
|
||||
hours: currentUpdateCheckInterval,
|
||||
})}
|
||||
settingTitle={t`Update interval`}
|
||||
settingValue={`${currentUpdateCheckInterval}${t`h`}`}
|
||||
value={currentUpdateCheckInterval}
|
||||
minValue={WEB_UI_UPDATE_INTERVAL.min}
|
||||
maxValue={WEB_UI_UPDATE_INTERVAL.max}
|
||||
defaultValue={WEB_UI_UPDATE_INTERVAL.default}
|
||||
showSlider
|
||||
valueUnit={t('global.time.hour_short')}
|
||||
valueUnit={t`h`}
|
||||
handleUpdate={updateSetting}
|
||||
disabled={disabled || !shouldAutoUpdate}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user