add ErrorDisplay localisation
This commit is contained in:
parent
8e50f01b5a
commit
b6f1ee835a
|
@ -59,6 +59,7 @@ export default defineConfig({
|
||||||
}),
|
}),
|
||||||
starlightLinksValidator({
|
starlightLinksValidator({
|
||||||
errorOnFallbackPages: false,
|
errorOnFallbackPages: false,
|
||||||
|
errorOnRelativeLinks: false,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
expressiveCode: {
|
expressiveCode: {
|
||||||
|
@ -95,7 +96,13 @@ export default defineConfig({
|
||||||
de: "Zukunftspläne",
|
de: "Zukunftspläne",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
playgroundSidebarEntry
|
{
|
||||||
|
...playgroundSidebarEntry,
|
||||||
|
badge: {
|
||||||
|
text: "WIP",
|
||||||
|
variant: "caution",
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -176,7 +176,7 @@ export default function Playground({ lang }: { lang: PlaygroundLang }) {
|
||||||
marginTop: "0.5cm",
|
marginTop: "0.5cm",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ErrorDisplay error={errorMsg} setError={setErrorMsg} />
|
<ErrorDisplay lang={lang.errorDisplay} error={errorMsg} setError={setErrorMsg} />
|
||||||
<Header
|
<Header
|
||||||
lang={lang.header}
|
lang={lang.header}
|
||||||
onSave={onSave}
|
onSave={onSave}
|
||||||
|
@ -277,7 +277,7 @@ function getFile(root: Directory, path: string): File | null {
|
||||||
let last = split.pop()!;
|
let last = split.pop()!;
|
||||||
|
|
||||||
for (const dirName of split) {
|
for (const dirName of split) {
|
||||||
if (dir.dirs) {
|
if (dir && dir.dirs) {
|
||||||
dir = dir.dirs[dirName];
|
dir = dir.dirs[dirName];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -335,7 +335,10 @@ function loadFile(
|
||||||
lang = "json";
|
lang = "json";
|
||||||
}
|
}
|
||||||
const uri = monaco.Uri.parse(name);
|
const uri = monaco.Uri.parse(name);
|
||||||
if (!monaco.editor.getModel(uri)) {
|
let prevModel = monaco.editor.getModel(uri);
|
||||||
|
if (prevModel) {
|
||||||
|
prevModel.setValue(file.content);
|
||||||
|
} else {
|
||||||
monaco.editor.createModel(file.content, lang, uri);
|
monaco.editor.createModel(file.content, lang, uri);
|
||||||
}
|
}
|
||||||
updater((dir) => {
|
updater((dir) => {
|
||||||
|
@ -386,6 +389,7 @@ function jsonReplacer(_key: any, value: any): any {
|
||||||
|
|
||||||
function deleteFile(monaco: Monaco, updater: Updater<Directory>, name: string) {
|
function deleteFile(monaco: Monaco, updater: Updater<Directory>, name: string) {
|
||||||
const uri = monaco.Uri.parse(name);
|
const uri = monaco.Uri.parse(name);
|
||||||
|
console.log(uri);
|
||||||
const model = monaco.editor.getModel(uri);
|
const model = monaco.editor.getModel(uri);
|
||||||
if (model) {
|
if (model) {
|
||||||
model.dispose();
|
model.dispose();
|
||||||
|
@ -403,6 +407,7 @@ function deleteFile(monaco: Monaco, updater: Updater<Directory>, name: string) {
|
||||||
}
|
}
|
||||||
current = current.dirs[part];
|
current = current.dirs[part];
|
||||||
}
|
}
|
||||||
|
console.log("file", current);
|
||||||
if (current.files) {
|
if (current.files) {
|
||||||
delete current.files[last];
|
delete current.files[last];
|
||||||
}
|
}
|
||||||
|
@ -423,6 +428,7 @@ function deleteDir(monaco: Monaco, updater: Updater<Directory>, path: string) {
|
||||||
}
|
}
|
||||||
current = current.dirs[part];
|
current = current.dirs[part];
|
||||||
}
|
}
|
||||||
|
console.log(current);
|
||||||
|
|
||||||
if (current.dirs) {
|
if (current.dirs) {
|
||||||
for (const [name, _] of Object.entries(current.dirs ?? {})) {
|
for (const [name, _] of Object.entries(current.dirs ?? {})) {
|
||||||
|
@ -465,3 +471,4 @@ function renameFile(
|
||||||
loadFile(monaco, updater, file, newName);
|
loadFile(monaco, updater, file, newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
let prevModel = monaco.editor.getModel(uri);
|
|
||||||
if (prevModel) {
|
|
||||||
prevModel.setValue(file.content);
|
|
||||||
} else {
|
|
|
@ -3,17 +3,20 @@ import Dialog from "@mui/material/Dialog";
|
||||||
import DialogActions from "@mui/material/DialogActions";
|
import DialogActions from "@mui/material/DialogActions";
|
||||||
import DialogContent from "@mui/material/DialogContent";
|
import DialogContent from "@mui/material/DialogContent";
|
||||||
import DialogTitle from "@mui/material/DialogTitle";
|
import DialogTitle from "@mui/material/DialogTitle";
|
||||||
|
import type { PlaygroundErrorDisplayLang } from "@utils/playground";
|
||||||
|
|
||||||
export default function ErrorDisplay({
|
export default function ErrorDisplay({
|
||||||
|
lang,
|
||||||
error,
|
error,
|
||||||
setError,
|
setError,
|
||||||
}: {
|
}: {
|
||||||
|
lang: PlaygroundErrorDisplayLang;
|
||||||
error: string | null;
|
error: string | null;
|
||||||
setError: (error: string | null) => void;
|
setError: (error: string | null) => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Dialog open={error !== null} onClose={() => setError(null)}>
|
<Dialog open={error !== null} onClose={() => setError(null)}>
|
||||||
<DialogTitle>Error during compilation!</DialogTitle>
|
<DialogTitle>{lang.title}</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -33,7 +36,7 @@ export default function ErrorDisplay({
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={() => setError(null)}>Close</Button>
|
<Button onClick={() => setError(null)}>{lang.buttons.close}</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|
|
@ -30,6 +30,12 @@ const lang: PlaygroundLang = {
|
||||||
cancel: "Abbrechen",
|
cancel: "Abbrechen",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
errorDisplay: {
|
||||||
|
title: "Fehler beim kompilieren!",
|
||||||
|
buttons: {
|
||||||
|
close: "Schließen",
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,24 @@ const lang: PlaygroundLang = {
|
||||||
add: "Add file",
|
add: "Add file",
|
||||||
addPrompt: {
|
addPrompt: {
|
||||||
label: "File path",
|
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",
|
delete: "Delete",
|
||||||
rename: "Rename",
|
rename: "Rename",
|
||||||
renamePrompt: {
|
renamePrompt: {
|
||||||
label: "New file path",
|
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",
|
cancel: "Cancel",
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
errorDisplay: {
|
||||||
|
title: "Error during compilation!",
|
||||||
|
buttons: {
|
||||||
|
close: "Close",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
@ -41,4 +49,4 @@ const lang: PlaygroundLang = {
|
||||||
.pagination-links {
|
.pagination-links {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
export type PlaygroundLang = {
|
export type PlaygroundLang = {
|
||||||
header: PlaygroundHeaderLang;
|
header: PlaygroundHeaderLang;
|
||||||
explorer: PlaygroundExplorerLang;
|
explorer: PlaygroundExplorerLang;
|
||||||
|
errorDisplay: PlaygroundErrorDisplayLang;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PlaygroundHeaderLang = {
|
export type PlaygroundHeaderLang = {
|
||||||
|
@ -29,6 +30,12 @@ export type PlaygroundExplorerLang = {
|
||||||
cancel: string;
|
cancel: string;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
export type PlaygroundErrorDisplayLang = {
|
||||||
|
title: string;
|
||||||
|
buttons: {
|
||||||
|
close: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type File = {
|
export type File = {
|
||||||
language?: string;
|
language?: string;
|
||||||
|
|
Loading…
Reference in New Issue