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:
@@ -7,15 +7,15 @@
|
||||
*/
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { makeToast } from '@/base/utils/Toast.ts';
|
||||
import { AppRoutes } from '@/base/AppRoute.constants.ts';
|
||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||
|
||||
export const TrackerOAuthLogin = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useLingui();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
@@ -28,7 +28,7 @@ export const TrackerOAuthLogin = () => {
|
||||
try {
|
||||
await requestManager.loginToTrackerOauth(trackerId, window.location.href).response;
|
||||
} catch (e) {
|
||||
makeToast(t('tracking.action.login.label.failure', { name: trackerName }), 'error', getErrorMessage(e));
|
||||
makeToast(t`Could not log in to ${trackerName}`, 'error', getErrorMessage(e));
|
||||
}
|
||||
|
||||
navigate(AppRoutes.settings.childRoutes.tracking.path, { replace: true });
|
||||
@@ -37,5 +37,5 @@ export const TrackerOAuthLogin = () => {
|
||||
login();
|
||||
}, [trackerId]);
|
||||
|
||||
return t('tracking.action.login.label.progress', { name: trackerName });
|
||||
return t`Logging in to ${trackerName}…`;
|
||||
};
|
||||
|
||||
@@ -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 ListSubheader from '@mui/material/ListSubheader';
|
||||
import ListItem from '@mui/material/ListItem';
|
||||
import ListItemText from '@mui/material/ListItemText';
|
||||
import Switch from '@mui/material/Switch';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { EmptyViewAbsoluteCentered } from '@/base/components/feedback/EmptyViewAbsoluteCentered.tsx';
|
||||
import { LoadingPlaceholder } from '@/base/components/feedback/LoadingPlaceholder.tsx';
|
||||
@@ -29,9 +29,9 @@ import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||
import { useAppTitle } from '@/features/navigation-bar/hooks/useAppTitle.ts';
|
||||
|
||||
export const TrackingSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useLingui();
|
||||
|
||||
useAppTitle(t('tracking.title'));
|
||||
useAppTitle(t`Tracking`);
|
||||
|
||||
const {
|
||||
settings: { updateProgressAfterReading, updateProgressManualMarkRead },
|
||||
@@ -39,7 +39,7 @@ export const TrackingSettings = () => {
|
||||
request: { error: metadataServerSettingsError, refetch: refetchServerMetadataSettings },
|
||||
} = useMetadataServerSettings();
|
||||
const updateTrackingSettings = createUpdateMetadataServerSettings<keyof MetadataTrackingSettings>((e) =>
|
||||
makeToast(t('global.error.label.failed_to_save_changes'), 'error', getErrorMessage(e)),
|
||||
makeToast(t`Failed to save changes`, 'error', getErrorMessage(e)),
|
||||
);
|
||||
|
||||
const {
|
||||
@@ -58,7 +58,7 @@ export const TrackingSettings = () => {
|
||||
if (error) {
|
||||
return (
|
||||
<EmptyViewAbsoluteCentered
|
||||
message={t('global.error.label.failed_to_load_data')}
|
||||
message={t`Unable to load data`}
|
||||
messageExtra={getErrorMessage(error)}
|
||||
retry={() => {
|
||||
if (metadataServerSettingsError) {
|
||||
@@ -85,7 +85,7 @@ export const TrackingSettings = () => {
|
||||
<>
|
||||
<List sx={{ pt: 0 }}>
|
||||
<ListItem>
|
||||
<ListItemText primary={t('tracking.settings.label.update_progress_reading')} />
|
||||
<ListItemText primary={t`Update progress after reading`} />
|
||||
<Switch
|
||||
edge="end"
|
||||
checked={updateProgressAfterReading}
|
||||
@@ -94,8 +94,8 @@ export const TrackingSettings = () => {
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary={t('tracking.settings.label.update_progress_manual')}
|
||||
secondary={t('tracking.settings.label.update_progress_reading_description')}
|
||||
primary={t`Update progress after manually marking as read`}
|
||||
secondary={t`Does not work when marking multiple manga as read at once`}
|
||||
/>
|
||||
<Switch
|
||||
edge="end"
|
||||
@@ -107,7 +107,7 @@ export const TrackingSettings = () => {
|
||||
<List
|
||||
subheader={
|
||||
<ListSubheader component="div" id="tracking-trackers">
|
||||
{t('tracking.settings.title.trackers')}
|
||||
{t`Trackers`}
|
||||
</ListSubheader>
|
||||
}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user