mirror of
https://github.com/inventree/InvenTree.git
synced 2026-04-04 02:21:18 +00:00
fix(frontend): complete zh-Hans UI localization (#11612)
* fix(frontend): complete zh-Hans localization * fix(frontend): address i18n review feedback
This commit is contained in:
@@ -35,7 +35,7 @@ export default function StarredToggleButton({
|
|||||||
showNotification({
|
showNotification({
|
||||||
title: t`Subscription Updated`,
|
title: t`Subscription Updated`,
|
||||||
id: 'subscription-update',
|
id: 'subscription-update',
|
||||||
message: `Subscription ${starred ? 'removed' : 'added'}`,
|
message: starred ? t`Subscription removed` : t`Subscription added`,
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
});
|
});
|
||||||
@@ -43,7 +43,7 @@ export default function StarredToggleButton({
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: 'Error',
|
title: t`Error`,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
color: 'red'
|
color: 'red'
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
import { ActionButton } from '@lib/components/ActionButton';
|
import { ActionButton } from '@lib/components/ActionButton';
|
||||||
import type { HostList } from '@lib/types/Server';
|
import type { HostList } from '@lib/types/Server';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
|
import { translateHostName } from '../../defaults/defaultHostList';
|
||||||
import { Wrapper } from '../../pages/Auth/Layout';
|
import { Wrapper } from '../../pages/Auth/Layout';
|
||||||
import { useLocalState } from '../../states/LocalState';
|
import { useLocalState } from '../../states/LocalState';
|
||||||
import { useServerApiState } from '../../states/ServerApiState';
|
import { useServerApiState } from '../../states/ServerApiState';
|
||||||
@@ -43,7 +44,7 @@ export function InstanceOptions({
|
|||||||
);
|
);
|
||||||
const hostListData = Object.keys(hostList).map((key) => ({
|
const hostListData = Object.keys(hostList).map((key) => ({
|
||||||
value: key,
|
value: key,
|
||||||
label: hostList[key]?.name
|
label: translateHostName(hostList[key]?.name)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function SaveOptions(newHostList: HostList): void {
|
function SaveOptions(newHostList: HostList): void {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export function LanguageSelect({ width = 80 }: Readonly<{ width?: number }>) {
|
|||||||
defaultValue={''}
|
defaultValue={''}
|
||||||
onChange={setValue}
|
onChange={setValue}
|
||||||
searchable
|
searchable
|
||||||
aria-label='Select language'
|
aria-label={t`Select language`}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
import type { HostList } from '@lib/types/Server';
|
import type { HostList } from '@lib/types/Server';
|
||||||
|
import { t } from '@lingui/core/macro';
|
||||||
|
|
||||||
export const defaultHostList: HostList = window.INVENTREE_SETTINGS.server_list;
|
export const defaultHostList: HostList = window.INVENTREE_SETTINGS.server_list;
|
||||||
export const defaultHostKey = window.INVENTREE_SETTINGS.default_server;
|
export const defaultHostKey = window.INVENTREE_SETTINGS.default_server;
|
||||||
|
|
||||||
|
export function translateHostName(name: string | undefined): string {
|
||||||
|
switch (name) {
|
||||||
|
case 'Localhost':
|
||||||
|
return t`Local Server`;
|
||||||
|
case 'InvenTree Demo':
|
||||||
|
return t`InvenTree Demo`;
|
||||||
|
case 'Current Server':
|
||||||
|
return t`Current Server`;
|
||||||
|
default:
|
||||||
|
return name ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import { removeTraceId, setApiDefaults, setTraceId } from '../../App';
|
|||||||
import { AuthFormOptions } from '../../components/forms/AuthFormOptions';
|
import { AuthFormOptions } from '../../components/forms/AuthFormOptions';
|
||||||
import { AuthenticationForm } from '../../components/forms/AuthenticationForm';
|
import { AuthenticationForm } from '../../components/forms/AuthenticationForm';
|
||||||
import { InstanceOptions } from '../../components/forms/InstanceOptions';
|
import { InstanceOptions } from '../../components/forms/InstanceOptions';
|
||||||
import { defaultHostKey } from '../../defaults/defaultHostList';
|
import {
|
||||||
|
defaultHostKey,
|
||||||
|
translateHostName
|
||||||
|
} from '../../defaults/defaultHostList';
|
||||||
import {
|
import {
|
||||||
checkLoginState,
|
checkLoginState,
|
||||||
doBasicLogin,
|
doBasicLogin,
|
||||||
@@ -29,7 +32,9 @@ export default function Login() {
|
|||||||
);
|
);
|
||||||
const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);
|
const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);
|
||||||
const hostname =
|
const hostname =
|
||||||
hostList[hostKey] === undefined ? t`No selection` : hostList[hostKey]?.name;
|
hostList[hostKey] === undefined
|
||||||
|
? t`No selection`
|
||||||
|
: translateHostName(hostList[hostKey]?.name);
|
||||||
const [hostEdit, setHostEdit] = useToggle([false, true] as const);
|
const [hostEdit, setHostEdit] = useToggle([false, true] as const);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ export default function Stock() {
|
|||||||
choices: deleteOptions
|
choices: deleteOptions
|
||||||
},
|
},
|
||||||
delete_sub_locations: {
|
delete_sub_locations: {
|
||||||
label: t`Locations Action`,
|
label: t`Location Actions`,
|
||||||
required: true,
|
required: true,
|
||||||
description: t`Action for child locations in this location`,
|
description: t`Action for child locations in this location`,
|
||||||
field_type: 'choice',
|
field_type: 'choice',
|
||||||
@@ -381,15 +381,15 @@ export default function Stock() {
|
|||||||
perm={user.hasChangeRole(UserRoles.stock_location)}
|
perm={user.hasChangeRole(UserRoles.stock_location)}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
name: 'Scan in stock items',
|
name: t`Scan in stock items`,
|
||||||
icon: <InvenTreeIcon icon='stock' />,
|
icon: <InvenTreeIcon icon='stock' />,
|
||||||
tooltip: 'Scan item into this location',
|
tooltip: t`Scan item into this location`,
|
||||||
onClick: scanInStockItem.open
|
onClick: scanInStockItem.open
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Scan in container',
|
name: t`Scan in container`,
|
||||||
icon: <InvenTreeIcon icon='unallocated_stock' />,
|
icon: <InvenTreeIcon icon='unallocated_stock' />,
|
||||||
tooltip: 'Scan container into this location',
|
tooltip: t`Scan container into this location`,
|
||||||
onClick: scanInStockLocation.open
|
onClick: scanInStockLocation.open
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
|
|||||||
Reference in New Issue
Block a user