Add localization support (#333)

* Add updated i18n config and en locale
This commit is contained in:
Jeff 2023-10-30 19:22:45 -07:00 committed by GitHub
parent 11863fd4c1
commit 8430b1ec95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
90 changed files with 2679 additions and 908 deletions

View file

@ -54,6 +54,7 @@ import { DeletePlaylistResponse, RandomSongListArgs } from './types';
import { ndController } from '/@/renderer/api/navidrome/navidrome-controller';
import { ssController } from '/@/renderer/api/subsonic/subsonic-controller';
import { jfController } from '/@/renderer/api/jellyfin/jellyfin-controller';
import i18n from '/@/i18n/i18n';
export type ControllerEndpoint = Partial<{
addToPlaylist: (args: AddToPlaylistArgs) => Promise<AddToPlaylistResponse>;
@ -212,7 +213,12 @@ const apiController = (endpoint: keyof ControllerEndpoint, type?: ServerType) =>
const serverType = type || useAuthStore.getState().currentServer?.type;
if (!serverType) {
toast.error({ message: 'No server selected', title: 'Unable to route request' });
toast.error({
message: i18n.t('error.serverNotSelectedError', {
postProcess: 'sentenceCase',
}) as string,
title: i18n.t('error.apiRouteError', { postProcess: 'sentenceCase' }) as string,
});
throw new Error(`No server selected`);
}
@ -221,10 +227,16 @@ const apiController = (endpoint: keyof ControllerEndpoint, type?: ServerType) =>
if (typeof controllerFn !== 'function') {
toast.error({
message: `Endpoint ${endpoint} is not implemented for ${serverType}`,
title: 'Unable to route request',
title: i18n.t('error.apiRouteError', { postProcess: 'sentenceCase' }) as string,
});
throw new Error(`Endpoint ${endpoint} is not implemented for ${serverType}`);
throw new Error(
i18n.t('error.endpointNotImplementedError', {
endpoint,
postProcess: 'sentenceCase',
serverType,
}) as string,
);
}
return endpoints[serverType][endpoint];