2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-03-30 16:11:04 +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:
HuaYangTian
2026-03-29 11:25:27 +08:00
committed by GitHub
parent 100555c9db
commit 7614973a04
6 changed files with 31 additions and 11 deletions

View File

@@ -35,7 +35,7 @@ export default function StarredToggleButton({
showNotification({
title: t`Subscription Updated`,
id: 'subscription-update',
message: `Subscription ${starred ? 'removed' : 'added'}`,
message: starred ? t`Subscription removed` : t`Subscription added`,
autoClose: 5000,
color: 'blue'
});
@@ -43,7 +43,7 @@ export default function StarredToggleButton({
})
.catch((error) => {
showNotification({
title: 'Error',
title: t`Error`,
message: error.message,
autoClose: 5000,
color: 'red'

View File

@@ -23,6 +23,7 @@ import {
import { ActionButton } from '@lib/components/ActionButton';
import type { HostList } from '@lib/types/Server';
import { useShallow } from 'zustand/react/shallow';
import { translateHostName } from '../../defaults/defaultHostList';
import { Wrapper } from '../../pages/Auth/Layout';
import { useLocalState } from '../../states/LocalState';
import { useServerApiState } from '../../states/ServerApiState';
@@ -43,7 +44,7 @@ export function InstanceOptions({
);
const hostListData = Object.keys(hostList).map((key) => ({
value: key,
label: hostList[key]?.name
label: translateHostName(hostList[key]?.name)
}));
function SaveOptions(newHostList: HostList): void {

View File

@@ -49,7 +49,7 @@ export function LanguageSelect({ width = 80 }: Readonly<{ width?: number }>) {
defaultValue={''}
onChange={setValue}
searchable
aria-label='Select language'
aria-label={t`Select language`}
/>
);
}

View File

@@ -1,4 +1,18 @@
import type { HostList } from '@lib/types/Server';
import { t } from '@lingui/core/macro';
export const defaultHostList: HostList = window.INVENTREE_SETTINGS.server_list;
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 ?? '';
}
}

View File

@@ -10,7 +10,10 @@ import { removeTraceId, setApiDefaults, setTraceId } from '../../App';
import { AuthFormOptions } from '../../components/forms/AuthFormOptions';
import { AuthenticationForm } from '../../components/forms/AuthenticationForm';
import { InstanceOptions } from '../../components/forms/InstanceOptions';
import { defaultHostKey } from '../../defaults/defaultHostList';
import {
defaultHostKey,
translateHostName
} from '../../defaults/defaultHostList';
import {
checkLoginState,
doBasicLogin,
@@ -29,7 +32,9 @@ export default function Login() {
);
const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);
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 navigate = useNavigate();
const location = useLocation();

View File

@@ -277,7 +277,7 @@ export default function Stock() {
choices: deleteOptions
},
delete_sub_locations: {
label: t`Locations Action`,
label: t`Location Actions`,
required: true,
description: t`Action for child locations in this location`,
field_type: 'choice',
@@ -381,15 +381,15 @@ export default function Stock() {
perm={user.hasChangeRole(UserRoles.stock_location)}
actions={[
{
name: 'Scan in stock items',
name: t`Scan in stock items`,
icon: <InvenTreeIcon icon='stock' />,
tooltip: 'Scan item into this location',
tooltip: t`Scan item into this location`,
onClick: scanInStockItem.open
},
{
name: 'Scan in container',
name: t`Scan in container`,
icon: <InvenTreeIcon icon='unallocated_stock' />,
tooltip: 'Scan container into this location',
tooltip: t`Scan container into this location`,
onClick: scanInStockLocation.open
}
]}