Skip to content

Commit

Permalink
fix: fixing translations and typescript renderer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrannychaseroperation committed May 4, 2024
1 parent 22633ba commit 0a597ac
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 49 deletions.
40 changes: 29 additions & 11 deletions src/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
"checking_files": "{{title}} ({{percentage}} - Analizando archivos…)",
"paused": "{{title}} (Pausado)",
"downloading": "{{title}} ({{percentage}} - Descargando…)",
"filter": "Filtrar biblioteca",
"filter": "Buscar en la biblioteca",
"follow_us": "Síguenos",
"home": "Inicio",
"follow_us": "Síguenos"
"discord": "Únete a nuestro Discord",
"x": "Síguenos en X",
"github": "Contribuye en GitHub"
},
"header": {
"search": "Buscar",
Expand Down Expand Up @@ -45,7 +48,7 @@
"remove": "Eliminar",
"remove_from_list": "Quitar",
"space_left_on_disk": "{{space}} restantes en el disco",
"eta": "Finalizando {{eta}}",
"eta": "Finalizando en {{eta}}",
"downloading_metadata": "Descargando metadatos…",
"checking_files": "Analizando archivos…",
"filter": "Filtrar repacks",
Expand All @@ -55,14 +58,12 @@
"no_minimum_requirements": "Sin requisitos mínimos para {{title}}",
"no_recommended_requirements": "{{title}} no tiene requisitos recomendados",
"paused_progress": "{{progress}} (Pausado)",
"release_date": "Fecha de lanzamiento {{date}}",
"publisher": "Publicado por {{publisher}}",
"release_date": "Fecha de lanzamiento: {{date}}",
"publisher": "Publicado por: {{publisher}}",
"copy_link_to_clipboard": "Copiar enlace",
"copied_link_to_clipboard": "Enlace copiado",
"hours": "horas",
"minutes": "minutos",
"amount_hours": "{{amount}} horas",
"amount_minutes": "{{amount}} minutos",
"accuracy": "{{accuracy}}% precisión",
"add_to_library": "Agregar a la biblioteca",
"remove_from_library": "Eliminar de la biblioteca",
Expand All @@ -75,7 +76,21 @@
"close": "Cerrar",
"deleting": "Eliminando instalador…",
"playing_now": "Jugando ahora",
"last_time_played": "Jugado por última vez {{period}}"
"last_time_played": "Jugado por última vez {{period}}",
"got_it": "Entendido",
"change": "Cambiar",
"repacks_modal_description": "Selecciona el repack que quieres descargar",
"downloads_path": "Ruta de descarga",
"select_folder_hint": "Para cambiar la carpeta predeterminada, accede a",
"settings": "Ajustes",
"download_now": "Descargar ahora",
"installation_instructions": "Instrucciones de instalación",
"installation_instructions_description": "Se requieren de pasos adicionales para instalar este juego",
"online_fix_instruction": "Los juegos de OnlineFix requieren una contraseña para ser extraídos. Cuando se requiera, usa la siguiente contraseña:",
"dodi_installation_instruction": "Cuando abras el instalador de DODI, presiona la tecla hacia arriba del teclado <0 /> para iniciar el proceso de instalación:",
"dont_show_it_again": "No mostrar de nuevo",
"copy_to_clipboard": "Copiar",
"copied_to_clipboard": "Copiado"
},
"activation": {
"title": "Activar Hydra",
Expand All @@ -88,7 +103,7 @@
"downloads": {
"resume": "Resumir",
"pause": "Pausa",
"eta": "Finalizando {{eta}}",
"eta": "Finalizando en {{eta}}",
"paused": "En Pausa",
"verifying": "Verificando…",
"completed_at": "Completado el {{date}}",
Expand All @@ -103,8 +118,8 @@
"starting_download": "Iniciando descarga…",
"remove_from_list": "Eliminar",
"delete": "Eliminar instalador",
"delete_modal_description": "Esto eliminará todos los archivos de instalación de su computadora.",
"delete_modal_title": "¿Está seguro?",
"delete_modal_description": "Esto eliminará todos los archivos de instalación de tu computadora.",
"delete_modal_title": "¿Estás seguro?",
"deleting": "Eliminando instalador…",
"install": "Instalar"
},
Expand Down Expand Up @@ -136,6 +151,9 @@
"description": "Los ejecutables de Wine o Lutris no se encontraron en su sistema",
"instructions": "Comprueba como instalar de forma correcta uno de los dos en tu distro de Linux para ejecutar el juego con normalidad"
},
"modal": {
"close": "Botón de cierre"
},
"catalogue": {
"next_page": "Siguiente página",
"previous_page": "Pagina anterior"
Expand Down
2 changes: 1 addition & 1 deletion src/main/events/library/add-game-to-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const addGameToLibrary = async (
objectID: string,
title: string,
gameShop: GameShop,
executablePath: string
executablePath: string | null
) => {
const game = await gameRepository.findOne({
where: {
Expand Down
6 changes: 5 additions & 1 deletion src/main/events/misc/show-open-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { registerEvent } from "../register-event";
const showOpenDialog = async (
_event: Electron.IpcMainInvokeEvent,
options: Electron.OpenDialogOptions
) => dialog.showOpenDialog(WindowManager.mainWindow, options);
) => {
if (WindowManager.mainWindow) {
dialog.showOpenDialog(WindowManager.mainWindow, options);
}
};

registerEvent(showOpenDialog, {
name: "showOpenDialog",
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ app.on("second-instance", (_event, commandLine) => {
WindowManager.createMainWindow();
}

const [, path] = commandLine.pop().split("://");
const [, path] = commandLine.pop()?.split("://") ?? [];
if (path) WindowManager.redirect(path);
});

Expand Down
3 changes: 2 additions & 1 deletion src/main/services/steam-250.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const getSteam250List = async () => {
).flat();

const gamesMap: Map<string, Steam250Game> = gamesList.reduce((map, item) => {
map.set(item.objectID, item);
if (item) map.set(item.objectID, item);

return map;
}, new Map());

Expand Down
12 changes: 6 additions & 6 deletions src/main/services/window-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrowserWindow, Menu, Notification, Tray, app } from "electron";
import { BrowserWindow, Menu, Tray, app } from "electron";
import { is } from "@electron-toolkit/utils";
import { t } from "i18next";
import path from "node:path";
Expand Down Expand Up @@ -50,15 +50,15 @@ export class WindowManager {
this.loadURL();
this.mainWindow.removeMenu();

const userPreferences = await userPreferencesRepository.findOne({
where: { id: 1 },
});

this.mainWindow.on("ready-to-show", () => {
if (!app.isPackaged) WindowManager.mainWindow?.webContents.openDevTools();
});

this.mainWindow.on("close", () => {
this.mainWindow.on("close", async () => {
const userPreferences = await userPreferencesRepository.findOne({
where: { id: 1 },
});

if (userPreferences?.preferQuitInsteadOfHiding) {
app.quit();
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/declaration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ declare global {
objectID: string,
title: string,
shop: GameShop,
executablePath: string
executablePath: string | null
) => Promise<void>;
getLibrary: () => Promise<Game[]>;
getRepackersFriendlyNames: () => Promise<Record<string, string>>;
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ export const getSteamLanguage = (language: string) => {
if (language.startsWith("ru")) return "russian";
if (language.startsWith("it")) return "italian";
if (language.startsWith("hu")) return "hungarian";
if (language.startsWith("pl")) return "polish";

return "english";
};
13 changes: 10 additions & 3 deletions src/renderer/src/pages/downloads/downloads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function Downloads() {
</>
);
}

if (game?.status === "cancelled") return <p>{t("cancelled")}</p>;
if (game?.status === "downloading_metadata")
return <p>{t("starting_download")}</p>;
Expand All @@ -115,6 +116,8 @@ export function Downloads() {
</>
);
}

return null;
};

const openDeleteModal = (gameId: number) => {
Expand Down Expand Up @@ -210,6 +213,12 @@ export function Downloads() {
);
};

const handleDeleteGame = () => {
if (gameToBeDeleted.current) {
deleteGame(gameToBeDeleted.current).then(updateLibrary);
}
};

return (
<section className={styles.downloadsContainer}>
<BinaryNotFoundModal
Expand All @@ -219,9 +228,7 @@ export function Downloads() {
<DeleteModal
visible={showDeleteModal}
onClose={() => setShowDeleteModal(false)}
deleteGame={() =>
deleteGame(gameToBeDeleted.current).then(updateLibrary)
}
deleteGame={handleDeleteGame}
/>

<TextField placeholder={t("filter")} onChange={handleFilter} />
Expand Down
43 changes: 25 additions & 18 deletions src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function HeroPanelActions({
try {
if (game) {
await removeGameFromLibrary(game.id);
} else {
} else if (gameDetails) {
const gameExecutablePath = await selectGameExecutable();

await window.electron.addGameToLibrary(
Expand All @@ -87,30 +87,37 @@ export function HeroPanelActions({
};

const openGameInstaller = () => {
window.electron.openGameInstaller(game.id).then((isBinaryInPath) => {
if (!isBinaryInPath) openBinaryNotFoundModal();
updateLibrary();
});
if (game) {
window.electron.openGameInstaller(game.id).then((isBinaryInPath) => {
if (!isBinaryInPath) openBinaryNotFoundModal();
updateLibrary();
});
}
};

const openGame = async () => {
if (game.executablePath) {
window.electron.openGame(game.id, game.executablePath);
return;
}
if (game) {
if (game.executablePath) {
window.electron.openGame(game.id, game.executablePath);
return;
}

if (game?.executablePath) {
window.electron.openGame(game.id, game.executablePath);
return;
}
if (game?.executablePath) {
window.electron.openGame(game.id, game.executablePath);
return;
}

const gameExecutablePath = await selectGameExecutable();
window.electron.openGame(game.id, gameExecutablePath);
const gameExecutablePath = await selectGameExecutable();
if (gameExecutablePath)
window.electron.openGame(game.id, gameExecutablePath);
}
};

const closeGame = () => window.electron.closeGame(game.id);
const closeGame = () => {
if (game) window.electron.closeGame(game.id);
};

const deleting = isGameDeleting(game?.id);
const deleting = game ? isGameDeleting(game?.id) : false;

const toggleGameOnLibraryButton = (
<Button
Expand All @@ -124,7 +131,7 @@ export function HeroPanelActions({
</Button>
);

if (isGameDownloading) {
if (game && isGameDownloading) {
return (
<>
<Button
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/src/pages/game-details/hero/hero-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ export function HeroPanel({
return <p>{t("deleting")}</p>;
}

if (isGameDownloading) {
if (isGameDownloading && gameDownloading?.status) {
return (
<>
<p className={styles.downloadDetailsRow}>
{progress}
{eta && <small>{t("eta", { eta })}</small>}
</p>

{gameDownloading?.status !== "downloading" ? (
{gameDownloading.status !== "downloading" ? (
<>
<p>{t(gameDownloading?.status)}</p>
<p>{t(gameDownloading.status)}</p>
{eta && <small>{t("eta", { eta })}</small>}
</>
) : (
<p className={styles.downloadDetailsRow}>
{formatBytes(gameDownloading?.bytesDownloaded)} /{" "}
{formatBytes(gameDownloading.bytesDownloaded)} /{" "}
{finalDownloadSize}
<small>
{numPeers} peers / {numSeeds} seeds
Expand Down Expand Up @@ -148,7 +148,7 @@ export function HeroPanel({
<>
<p>
{t("play_time", {
amount: formatPlayTime(game.playTimeInMilliseconds),
amount: formatPlayTime(),
})}
</p>

Expand Down
4 changes: 3 additions & 1 deletion src/renderer/src/pages/game-details/repacks-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function RepacksModal({
<p style={{ color: "#DADBE1" }}>{repack.title}</p>
<p style={{ fontSize: "12px" }}>
{repack.fileSize} - {repackersFriendlyNames[repack.repacker]} -{" "}
{format(repack.uploadDate, "dd/MM/yyyy")}
{repack.uploadDate
? format(repack.uploadDate, "dd/MM/yyyy")
: ""}
</p>
</Button>
))}
Expand Down

0 comments on commit 0a597ac

Please sign in to comment.