Skip to content

Commit

Permalink
More account page i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Jan 15, 2025
1 parent 04af806 commit c2a2dcd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
15 changes: 14 additions & 1 deletion locales/en-US/instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@
"allFailed": "Failed to import any accounts",
"someFailed": "Imported {{count}} accounts, failed to import {{failed}} accounts",
"noneFailed": "{{count}} accounts imported!",
"error": "Failed to import accounts"
"error": "Failed to import accounts",
"noAccounts": "No accounts to import"
},
"unknownError": "Unknown error",
"deviceCodeImportToast": {
"loading": "Importing account...",
"success": "Account imported!",
"error": "Failed to import account"
},
"import": {
"javaEdition": "Java Edition",
"bedrockEdition": "Bedrock Edition",
"offline": "Offline",
"microsoftCredentials": "Microsoft Credentials",
"microsoftDeviceCode": "Microsoft Device Code",
"microsoftRefreshToken": "Microsoft Refresh Token",
"theAltening": "The Altening"
}
}
}
4 changes: 2 additions & 2 deletions src/components/dialog/import-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function TextInput(
<div className="flex flex-col gap-4">
<Textarea
autoFocus
placeholder={t('dialog.import.textarea.placeholder')}
placeholder={t('dialog.import.main.textarea.placeholder')}
defaultValue={inputText}
onChange={(e) => setInputText(e.currentTarget.value)}
/>
Expand All @@ -300,7 +300,7 @@ function TextInput(
onClick={() => props.listener(inputText)}
>
<TextIcon className="h-4" />
<span>{t('dialog.import.textarea.submit')}</span>
<span>{t('dialog.import.main.textarea.submit')}</span>
</Button>
</div>
</>
Expand Down
38 changes: 21 additions & 17 deletions src/routes/dashboard/_layout/instance/$instance/accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
MinecraftAccountProto_AccountTypeProto,
} from '@/generated/soulfire/common.ts';
import { PlusIcon, TrashIcon } from 'lucide-react';
import { Checkbox } from '@/components/ui/checkbox.tsx';
import {
DropdownMenu,
DropdownMenuContent,
Expand Down Expand Up @@ -108,7 +107,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
if (accountTypeCredentialsSelected === null) return;

if (text.length === 0) {
toast.error('No accounts to import');
toast.error(t('account.listImportToast.noAccounts'));
return;
}

Expand Down Expand Up @@ -172,6 +171,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
instanceInfo.id,
profile,
setProfileMutation,
t,
transport,
],
);
Expand Down Expand Up @@ -211,7 +211,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
if (e instanceof Error) {
reject(e);
} else {
reject(new Error('Unknown error'));
reject(new Error(t('account.unknownError')));
}
}
});
Expand All @@ -222,16 +222,16 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
});
})(),
{
loading: 'Importing account...',
success: 'Account imported!',
loading: t('account.deviceCodeImportToast.loading'),
success: t('account.deviceCodeImportToast.success'),
error: (e) => {
console.error(e);
return 'Failed to import accounts';
return t('account.deviceCodeImportToast.error');
},
},
);
},
[instanceInfo.id, profile, setProfileMutation, transport],
[instanceInfo.id, profile, setProfileMutation, t, transport],
);

return (
Expand All @@ -243,14 +243,16 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>Java Edition</DropdownMenuLabel>
<DropdownMenuLabel>
{t('account.import.javaEdition')}
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() =>
setAccountTypeCredentialsSelected(AccountTypeCredentials.OFFLINE)
}
>
Offline
{t('account.import.offline')}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
Expand All @@ -259,7 +261,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
)
}
>
Microsoft Credentials
{t('account.import.microsoftCredentials')}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
Expand All @@ -268,7 +270,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
)
}
>
Microsoft Device Code
{t('account.import.microsoftDeviceCode')}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
Expand All @@ -277,7 +279,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
)
}
>
Microsoft Refresh Token
{t('account.import.microsoftRefreshToken')}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
Expand All @@ -286,17 +288,19 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
)
}
>
The Altening
{t('account.import.theAltening')}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuLabel>Bedrock Edition</DropdownMenuLabel>
<DropdownMenuLabel>
{t('account.import.bedrockEdition')}
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() =>
setAccountTypeCredentialsSelected(AccountTypeCredentials.OFFLINE)
}
>
Offline
{t('account.import.offline')}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
Expand All @@ -305,7 +309,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
)
}
>
Microsoft Credentials
{t('account.import.microsoftCredentials')}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
Expand All @@ -314,7 +318,7 @@ function ExtraHeader(props: { table: ReactTable<ProfileAccount> }) {
)
}
>
Microsoft Device Code
{t('account.import.microsoftDeviceCode')}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/dashboard/_layout/instance/$instance/proxies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function parseRawTypeToProto(rawType: string): ProxyProto_Type {
case 'socks5':
return ProxyProto_Type.SOCKS5;
default:
throw new Error('Invalid proxy type');
throw new Error('Invalid proxy type ' + rawType);
}
}

Expand Down Expand Up @@ -136,6 +136,7 @@ const columns: ColumnDef<ProfileProxy>[] = [
];

function ExtraHeader(props: { table: ReactTable<ProfileProxy> }) {
const { t } = useTranslation('instance');
const queryClient = useQueryClient();
const profile = useContext(ProfileContext);
const transport = useContext(TransportContext);
Expand Down

0 comments on commit c2a2dcd

Please sign in to comment.