From b6f1ee835a77374d759189fbd0d09a7d614d81cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20H=C3=B6lting?= <87192362+moritz-hoelting@users.noreply.github.com> Date: Thu, 27 Jun 2024 10:59:13 +0200 Subject: [PATCH] add ErrorDisplay localisation --- astro.config.mjs | 9 ++++++++- src/components/Playground.tsx | 13 ++++++++++--- src/components/playground.tsx | 4 ---- src/components/playground/ErrorDisplay.tsx | 7 +++++-- src/pages/de/playground.astro | 6 ++++++ src/pages/playground.astro | 16 ++++++++++++---- src/utils/playground.ts | 7 +++++++ 7 files changed, 48 insertions(+), 14 deletions(-) delete mode 100644 src/components/playground.tsx diff --git a/astro.config.mjs b/astro.config.mjs index 1ef7897..199c75c 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -59,6 +59,7 @@ export default defineConfig({ }), starlightLinksValidator({ errorOnFallbackPages: false, + errorOnRelativeLinks: false, }), ], expressiveCode: { @@ -95,7 +96,13 @@ export default defineConfig({ de: "Zukunftspläne", }, }, - playgroundSidebarEntry + { + ...playgroundSidebarEntry, + badge: { + text: "WIP", + variant: "caution", + }, + }, ], }, { diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index a1e1023..bea6fa8 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -176,7 +176,7 @@ export default function Playground({ lang }: { lang: PlaygroundLang }) { marginTop: "0.5cm", }} > - +
{ @@ -386,6 +389,7 @@ function jsonReplacer(_key: any, value: any): any { function deleteFile(monaco: Monaco, updater: Updater, name: string) { const uri = monaco.Uri.parse(name); + console.log(uri); const model = monaco.editor.getModel(uri); if (model) { model.dispose(); @@ -403,6 +407,7 @@ function deleteFile(monaco: Monaco, updater: Updater, name: string) { } current = current.dirs[part]; } + console.log("file", current); if (current.files) { delete current.files[last]; } @@ -423,6 +428,7 @@ function deleteDir(monaco: Monaco, updater: Updater, path: string) { } current = current.dirs[part]; } + console.log(current); if (current.dirs) { for (const [name, _] of Object.entries(current.dirs ?? {})) { @@ -465,3 +471,4 @@ function renameFile( loadFile(monaco, updater, file, newName); } } + diff --git a/src/components/playground.tsx b/src/components/playground.tsx deleted file mode 100644 index 6d55efd..0000000 --- a/src/components/playground.tsx +++ /dev/null @@ -1,4 +0,0 @@ - let prevModel = monaco.editor.getModel(uri); - if (prevModel) { - prevModel.setValue(file.content); - } else { diff --git a/src/components/playground/ErrorDisplay.tsx b/src/components/playground/ErrorDisplay.tsx index a80e207..225610a 100644 --- a/src/components/playground/ErrorDisplay.tsx +++ b/src/components/playground/ErrorDisplay.tsx @@ -3,17 +3,20 @@ import Dialog from "@mui/material/Dialog"; import DialogActions from "@mui/material/DialogActions"; import DialogContent from "@mui/material/DialogContent"; import DialogTitle from "@mui/material/DialogTitle"; +import type { PlaygroundErrorDisplayLang } from "@utils/playground"; export default function ErrorDisplay({ + lang, error, setError, }: { + lang: PlaygroundErrorDisplayLang; error: string | null; setError: (error: string | null) => void; }) { return ( setError(null)}> - Error during compilation! + {lang.title}
- +
); diff --git a/src/pages/de/playground.astro b/src/pages/de/playground.astro index 47daa84..91b0374 100644 --- a/src/pages/de/playground.astro +++ b/src/pages/de/playground.astro @@ -30,6 +30,12 @@ const lang: PlaygroundLang = { cancel: "Abbrechen", } }, + errorDisplay: { + title: "Fehler beim kompilieren!", + buttons: { + close: "Schließen", + }, + } }; --- diff --git a/src/pages/playground.astro b/src/pages/playground.astro index fc8b8f7..7cb2db9 100644 --- a/src/pages/playground.astro +++ b/src/pages/playground.astro @@ -19,16 +19,24 @@ const lang: PlaygroundLang = { add: "Add file", addPrompt: { label: "File path", - message: "Enter the path you want the new file to be created at." + message: + "Enter the path you want the new file to be created at.", }, delete: "Delete", rename: "Rename", renamePrompt: { label: "New file path", - message: "Enter the path you want the file to be renamed/moved to." + message: + "Enter the path you want the file to be renamed/moved to.", }, cancel: "Cancel", - } + }, + }, + errorDisplay: { + title: "Error during compilation!", + buttons: { + close: "Close", + }, }, }; --- @@ -41,4 +49,4 @@ const lang: PlaygroundLang = { .pagination-links { display: none; } - \ No newline at end of file + diff --git a/src/utils/playground.ts b/src/utils/playground.ts index 72cf775..26a07dc 100644 --- a/src/utils/playground.ts +++ b/src/utils/playground.ts @@ -1,6 +1,7 @@ export type PlaygroundLang = { header: PlaygroundHeaderLang; explorer: PlaygroundExplorerLang; + errorDisplay: PlaygroundErrorDisplayLang; }; export type PlaygroundHeaderLang = { @@ -29,6 +30,12 @@ export type PlaygroundExplorerLang = { cancel: string; } }; +export type PlaygroundErrorDisplayLang = { + title: string; + buttons: { + close: string; + } +} export type File = { language?: string;