adding translations 1/2
UI Translations Coming in 2/2: Output translations
This commit is contained in:
+15
-1
@@ -157,4 +157,18 @@ body {
|
||||
|
||||
.popup-overlay {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-custom {
|
||||
width: 20%;
|
||||
background-color: black;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dropdown-custom:hover {
|
||||
background-color: #444;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
export default function text(lang: string, input: string): string {
|
||||
// German translation
|
||||
if (lang === "ger") {
|
||||
switch (input) {
|
||||
case "header_title":
|
||||
return "OR-Tool";
|
||||
case "header_subtitle":
|
||||
return "von Spaceholder Programming";
|
||||
case "boxObjTitle":
|
||||
return "Ziel";
|
||||
case "boxObjDesc":
|
||||
return "Gib hier dein Ziel ein. Es ist nur ein Ziel erlaubt. Verwende eine Zeile dafür (kein \"Return\"!). Erlaubte Symbole sind 0-9, a-z, A-Z und <>=.\nBeispiel:\nx + y\n-786433 x1 + 655361 x2";
|
||||
case "boxSubjTitle":
|
||||
return "Nebenbedingungen";
|
||||
case "boxSubjDesc":
|
||||
return "Gib hier dein Nebenbedingungen ein. Eines pro Zeile (trenne mit der 'Return'-Taste). Erlaubte Symbole sind 0-9, a-z, A-Z und <>=.\nBeispiel:\n+1 x + 2 y <= 15\n524321 x14 + 524305 x15 <= 4194303.5";
|
||||
case "boxBoundsTitle":
|
||||
return "Grenzen";
|
||||
case "boxBoundsDesc":
|
||||
return "Gib hier deine Grenzen ein. Eine pro Zeile (trenne mit der 'Return'-Taste). Erlaubte Symbole sind 0-9, a-z, A-Z und <>=.\nBeispiel:\nx >= 0\nx > 0\n0 <= x1 <= 1";
|
||||
case "boxVarsTitle":
|
||||
return "Variablen";
|
||||
case "boxVarsDesc":
|
||||
return "Liste alle deine Variablen auf. Eine pro Zeile (trenne mit der 'Return'-Taste). Erlaubte Symbole sind a-z, A-Z.\nBeispiel:\nx\ny";
|
||||
case "boxExportLP":
|
||||
return "Exportieren als LP";
|
||||
case "boxOut":
|
||||
return "Geben Sie ein Problem und eine Aktionstaste ein, um die Ausgabe anzuzeigen...";
|
||||
case "buttonCalc":
|
||||
return "Berechnen";
|
||||
default:
|
||||
return "Fehler: Übersetzung nicht gefunden";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// English translation
|
||||
if (lang === "eng") {
|
||||
switch (input) {
|
||||
case "header_title":
|
||||
return "OR-Tool";
|
||||
case "header_subtitle":
|
||||
return "by Spaceholder Programming";
|
||||
case "boxObjTitle":
|
||||
return "Objective";
|
||||
case "boxObjDesc":
|
||||
return "Insert your objective here. One objective is allowed. Use one line for it (no \"return\"!) Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\nx + y\n-786433 x1 + 655361 x2";
|
||||
case "boxSubjTitle":
|
||||
return "Subject";
|
||||
case "boxSubjDesc":
|
||||
return "Insert your subject here. One per line (divide by 'return' button). Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\n+1 x + 2 y <= 15\n524321 x14 + 524305 x15 <= 4194303.5";
|
||||
case "boxBoundsTitle":
|
||||
return "Bounds";
|
||||
case "boxBoundsDesc":
|
||||
return "Insert your bounds here. One per line (divide by 'return' button). Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\nx >= 0\nx > 0\n0 <= x1 <= 1";
|
||||
case "boxVarsTitle":
|
||||
return "Variables";
|
||||
case "boxVarsDesc":
|
||||
return "List all your variables. One per line (divide by 'return' button). Allowed symbols are a-z, A-Z.\nExample:\nx\ny";
|
||||
case "boxExportLP":
|
||||
return "Export as LP";
|
||||
case "boxOut":
|
||||
return "Input a problem and an action button to display output...";
|
||||
case "buttonCalc":
|
||||
return "Calculate";
|
||||
default:
|
||||
return "Error: Translation Not Found";
|
||||
}
|
||||
}
|
||||
|
||||
return "Error: Translation Module - Language Not Known.";
|
||||
}
|
||||
+3
-3
@@ -45,7 +45,7 @@ export default function RootLayout({
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Go to our docs
|
||||
Docs
|
||||
</a>
|
||||
<a
|
||||
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
||||
@@ -60,7 +60,7 @@ export default function RootLayout({
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
See the source code
|
||||
Source Code
|
||||
</a>
|
||||
<a
|
||||
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
||||
@@ -75,7 +75,7 @@ export default function RootLayout({
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Powered by GLPK
|
||||
GLPK
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
+42
-25
@@ -1,58 +1,75 @@
|
||||
'use client'
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Box, Button, Output } from "./modules";
|
||||
import { calculate_click, downloadLP, import_click } from "./scripts"
|
||||
import text from "./lang"
|
||||
|
||||
export default function Home() {
|
||||
const [language, setLanguage] = useState('eng');
|
||||
const tr_hTitle = text(language, 'header_title');
|
||||
const tr_hSubtitle = text(language, 'header_subtitle');
|
||||
const tr_boxObjTitle = text(language, 'boxObjTitle');
|
||||
const tr_boxObjDesc = text(language, "boxObjDesc");
|
||||
const tr_boxSubjTitle = text(language, 'boxSubjTitle');
|
||||
const tr_boxSubjDesc = text(language, "boxSubjDesc");
|
||||
const tr_boxBoundsTitle = text(language, 'boxBoundsTitle');
|
||||
const tr_boxBoundsDesc = text(language, "boxBoundsDesc");
|
||||
const tr_boxVarsTitle = text(language, 'boxVarsTitle');
|
||||
const tr_boxVarsDesc = text(language, "boxVarsDesc");
|
||||
const tr_boxOut = text(language, "boxOut");
|
||||
const tr_boxExportLP = text(language, "boxExportLP");
|
||||
const tr_calc = text(language, "buttonCalc");
|
||||
|
||||
const handleLanguageChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
setLanguage(event.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<header className="header">
|
||||
<div className="title">
|
||||
<main className="header_box">
|
||||
Operations Research Tool
|
||||
{tr_hTitle}
|
||||
<br></br>
|
||||
<span className="header_copyright">
|
||||
<i>by Spaceholder Programming</i>
|
||||
</span>
|
||||
<i>{tr_hSubtitle}</i>
|
||||
</span><br></br>
|
||||
<select id="language_current" value={language} onChange={handleLanguageChange} className="dropdown-custom">
|
||||
<option value="ger">Deutsch</option>
|
||||
<option value="eng">English</option>
|
||||
</select>
|
||||
</main>
|
||||
</div>
|
||||
</header>
|
||||
<Box
|
||||
title={"Objective"}
|
||||
placeholder={"Insert your objective here. One objective is allowed. Use one line for it (no \"return\"!) Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\nx + y\n-786433 x1 + 655361 x2"}
|
||||
id="objective"/>
|
||||
title={tr_boxObjTitle}
|
||||
placeholder={tr_boxObjDesc}
|
||||
id="objective" />
|
||||
<Box
|
||||
title={"Subject"}
|
||||
placeholder={"Insert your subject here. One per line (divide by 'return' button). Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\n+1 x + 2 y <= 15\n524321 x14 + 524305 x15 <= 4194303.5"}
|
||||
id="subject"/>
|
||||
title={tr_boxSubjTitle}
|
||||
placeholder={tr_boxSubjDesc}
|
||||
id="subject" />
|
||||
<Box
|
||||
title={"Bounds"}
|
||||
placeholder={"Insert your bounds here. One per line (divide by 'return' button). Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\nx >= 0\nx > 0\n0 <= x1 <= 1"}
|
||||
id="bounds"/>
|
||||
title={tr_boxBoundsTitle}
|
||||
placeholder={tr_boxBoundsDesc}
|
||||
id="bounds" />
|
||||
<Box
|
||||
title={"Variables"}
|
||||
placeholder={"List all your variables. One per line (divide by 'return' button). Allowed symbols are a-z, A-Z.\nExample:\nx\ny"}
|
||||
title={tr_boxVarsTitle}
|
||||
placeholder={tr_boxVarsDesc}
|
||||
id="vars" />
|
||||
<Button
|
||||
title={"Calculate"}
|
||||
title={tr_calc}
|
||||
className={"button_green"}
|
||||
onClickFunc={calculate_click} />
|
||||
{/* <Popup_Button
|
||||
title={"Import"}
|
||||
className={"button"} /> */}
|
||||
<Button
|
||||
title={"Export as LP"}
|
||||
title={tr_boxExportLP}
|
||||
className={"button"}
|
||||
onClickFunc={downloadLP} />
|
||||
<br></br>
|
||||
<Output
|
||||
id="out"
|
||||
text={"Input a problem and an action button to display output..."}/>
|
||||
{/* <Popup_Button
|
||||
title="Popup"
|
||||
className="button"
|
||||
/> */}
|
||||
|
||||
text={tr_boxOut} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
+11
-2
@@ -5,13 +5,22 @@ import * as LPAPI from "../api/optimizeLP.js"
|
||||
import * as GLPKAPI from "../solver/glpk.min.js"
|
||||
import { start } from "repl";
|
||||
|
||||
import text from "./lang"
|
||||
|
||||
// custom log so we can append the output dynamically
|
||||
function customLog(message: string) {
|
||||
console.log(message); // Continue to print message inside of box
|
||||
function customLog(input: string) {
|
||||
|
||||
|
||||
// get language
|
||||
const lang = (document.getElementById('language_current') as HTMLSelectElement)?.value;
|
||||
|
||||
// Get Output Box
|
||||
const outputElement = document.getElementById('out');
|
||||
|
||||
// load text
|
||||
const message: string = text(lang, input);
|
||||
console.log(message); // Continue to print message inside of box
|
||||
|
||||
// Append message if element exists
|
||||
if (outputElement) {
|
||||
outputElement.innerHTML += message + "<br>"; // Append message
|
||||
|
||||
Reference in New Issue
Block a user