I18n components (#27)

* New translation keys in en-US locale

* New translation keys in de-DE locale

* New translation keys in fr-FR locale

* New translation keys in it-IT locale

* New translation keys in pl-PL locale

* New translation keys in pt-PT locale

* New translation keys in tr-TR locale

* Move into function

* Replace string matching to boolean check

* Add FIXIT in UsersTable

* Use localization for size units

* Missed and restored translation keys

* fixup! New translation keys in tr-TR locale

* Add translation keys in components
This commit is contained in:
vlalx 2025-05-25 17:41:38 +03:00 committed by GitHub
parent af3694da34
commit ea24759bb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 1419 additions and 329 deletions

View file

@ -24,6 +24,7 @@ import Enable2FaForm from "./Enable2FaForm";
import SupporterStatus from "./SupporterStatus";
import { UserType } from "@server/types/UserTypes";
import LocaleSwitcher from '@app/components/LocaleSwitcher';
import { useTranslations } from "next-intl";
export default function ProfileIcon() {
@ -40,6 +41,8 @@ export default function ProfileIcon() {
const [openEnable2fa, setOpenEnable2fa] = useState(false);
const [openDisable2fa, setOpenDisable2fa] = useState(false);
const t = useTranslations();
function getInitials() {
return (user.email || user.name || user.username)
.substring(0, 1)
@ -54,10 +57,10 @@ export default function ProfileIcon() {
function logout() {
api.post("/auth/logout")
.catch((e) => {
console.error("Error logging out", e);
console.error(t('logoutError'), e);
toast({
title: "Error logging out",
description: formatAxiosError(e, "Error logging out")
title: t('logoutError'),
description: formatAxiosError(e, t('logoutError'))
});
})
.then(() => {
@ -94,7 +97,7 @@ export default function ProfileIcon() {
<DropdownMenuLabel className="font-normal">
<div className="flex flex-col space-y-1">
<p className="text-sm font-medium leading-none">
Signed in as
{t('signingAs')}
</p>
<p className="text-xs leading-none text-muted-foreground">
{user.email || user.name || user.username}
@ -102,11 +105,11 @@ export default function ProfileIcon() {
</div>
{user.serverAdmin ? (
<p className="text-xs leading-none text-muted-foreground mt-2">
Server Admin
{t('serverAdmin')}
</p>
) : (
<p className="text-xs leading-none text-muted-foreground mt-2">
{user.idpName || "Internal"}
{user.idpName || t('idpNameInternal')}
</p>
)}
</DropdownMenuLabel>
@ -117,14 +120,14 @@ export default function ProfileIcon() {
<DropdownMenuItem
onClick={() => setOpenEnable2fa(true)}
>
<span>Enable Two-factor</span>
<span>{t('otpEnable')}</span>
</DropdownMenuItem>
)}
{user.twoFactorEnabled && (
<DropdownMenuItem
onClick={() => setOpenDisable2fa(true)}
>
<span>Disable Two-factor</span>
<span>{t('otpDisable')}</span>
</DropdownMenuItem>
)}
<DropdownMenuSeparator />
@ -166,7 +169,7 @@ export default function ProfileIcon() {
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => logout()}>
{/* <LogOut className="mr-2 h-4 w-4" /> */}
<span>Log Out</span>
<span>{t('logout')}</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>