Skip to content

Added a feature to add languages dynamically in linebyline output #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 86 additions & 48 deletions Compiler/constants.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,118 @@
let ActiveLanguage = localStorage.getItem('ActiveLangugae');
let ActiveLanguage = localStorage.getItem("ActiveLangugae");
//

if (ActiveLanguage == null) {
ActiveLanguage = 'Hindi';
ActiveLanguage = "Hindi";
}

//

var ActiveLangugaeKeywords = '';
var ActiveLangugaeKeywords = "";

var KalaamKeywords = {
Hindi: {
Print: 'दिखाए', //Still have to change this manually where REGEX are implemented
Input: 'इनपुट',
If: 'अगर',
For: 'दुहराओ',
While: 'जबतक',
Length: 'संख्या',
Push: 'पुश',
Function: 'रचना',
Langugae: 'Hindi',
inputText: 'को क्या किंमत देना चाहते हो ?',
Print: "दिखाए", //Still have to change this manually where REGEX are implemented
Input: "इनपुट",
If: "अगर",
For: "दुहराओ",
While: "जबतक",
Length: "संख्या",
Push: "पुश",
Function: "रचना",
Langugae: "Hindi",
inputText: "को क्या किंमत देना चाहते हो ?",
},
Marathi: {
Print: "दाखवा", //Still have to change this manually where REGEX are implemented
Input: "इनपुट",
If: "जर",
For: "दुहराओ",
While: "जोपर्यंत",
Length: "संख्या",
Push: "पुश",
Function: "रचना",
Langugae: "Marathi",
inputText: "ला कोणती किंमत द्यायची आहे??",
},
Bengali: {
Print: "দেখাও", //Still have to change this manually where REGEX are implemented
Input: "নিবেশ",
If: "যদি",
For: "সন্ধানে",
While: "যখন",
Length: "দৈর্ঘ্য" || "length",
Push: "যোগ",
Function: "পর্ব",
Langugae: "Bengali",
inputText: "আপনি কি মান দিতে চান?",
},
Telugu: {
Print: "చూపించు", //Still have to change this manually where REGEX are implemented
Input: "ఇన్పుట్",
If: "ఉంటే",
For: "పునరావృతం",
While: "ఉండగా",
Length: "లెక్కించండి" || "length",
Push: "పుష్",
Function: "నిర్మాణము",
Langugae: "Bengali",
inputText: "మీరు ఏ ధర చెల్లించాలనుకుంటున్నారు",
},
};

const KalamOutputMessages = {
Hindi: {
message: [
" Computer ने आपकी दी गयी वैल्यू, " + '"',
'"' + " को दिखाया है |",
],
description:
"किसी VALUE को OUTPUT SCREEN पे दिखाने के लिए दिखाए() का उपयोग होता है।",
},
Marathi: {
Print: 'दाखवा', //Still have to change this manually where REGEX are implemented
Input: 'इनपुट',
If: 'जर',
For: 'दुहराओ',
While: 'जोपर्यंत',
Length: 'संख्या',
Push: 'पुश',
Function: 'रचना',
Langugae: 'Marathi',
inputText: 'ला कोणती किंमत द्यायची आहे??',
message: [
" संगणकाने तुम्हाला मूल्य दिले आहे, " + '"',
'"' + " दाखवले आहेत |",
],
description: "आउटपुट स्क्रीनवर मूल्य दर्शविण्यासाठी दाखवा() वापरला जातो।",
},
Bengali: {
Print: 'দেখাও', //Still have to change this manually where REGEX are implemented
Input: 'নিবেশ',
If: 'যদি',
For: 'সন্ধানে',
While: 'যখন',
Length: 'দৈর্ঘ্য' || 'length',
Push: 'যোগ',
Function: 'পর্ব',
Langugae: 'Bengali',
inputText: 'আপনি কি মান দিতে চান?',
message: [
" Computer আপনার দেওয়া value, " + '"',
'"' + " কে দেখিয়েছে |",
],
description:
"OUTPUT SCREEN এ একটি মান দেখানোর জন্য দেখাও() ব্যবহার করা হয়।",
},
Telugu: {
Print: 'చూపించు', //Still have to change this manually where REGEX are implemented
Input: 'ఇన్పుట్',
If: 'ఉంటే',
For: 'పునరావృతం',
While: 'ఉండగా',
Length: 'లెక్కించండి' || 'length',
Push: 'పుష్',
Function: 'నిర్మాణము',
Langugae: 'Bengali',
inputText: 'మీరు ఏ ధర చెల్లించాలనుకుంటున్నారు',
message: [
" Computer ने आपकी दी गयी वैल्यू, " + '"',
'"' + " को दिखाया है |",
],
description:
"किसी VALUE को OUTPUT SCREEN पे दिखाने के लिए दिखाए() का उपयोग होता है।",
},
};

if (ActiveLanguage == 'Hindi') {
if (ActiveLanguage == "Hindi") {
ActiveLangugaeKeywords = KalaamKeywords.Hindi;
}

if (ActiveLanguage == 'Marathi') {
if (ActiveLanguage == "Marathi") {
ActiveLangugaeKeywords = KalaamKeywords.Marathi;
}

if (ActiveLanguage == 'Bengali') {
if (ActiveLanguage == "Bengali") {
ActiveLangugaeKeywords = KalaamKeywords.Bengali;
}
if (ActiveLanguage == 'Telugu') {
if (ActiveLanguage == "Telugu") {
ActiveLangugaeKeywords = KalaamKeywords.Telugu;
}
//

export { ActiveLangugaeKeywords, KalaamKeywords, ActiveLanguage };
export {
ActiveLangugaeKeywords,
KalaamKeywords,
ActiveLanguage,
KalamOutputMessages,
};
7 changes: 4 additions & 3 deletions Compiler/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//To check variable types: Number, String, Array etc.
import * as TypeCheck from '../TypeCheck/TypeChecking';

import { KalaamKeywords } from '../Compiler/constants';
import { KalaamKeywords,KalamOutputMessages,ActiveLanguage } from '../Compiler/constants';

//To check other operations like MultiString, Arithmetic Operation etc.
import * as AdvancedTypeCheck from '../TypeCheck/AdvancedTypeChecking';
Expand Down Expand Up @@ -336,12 +336,13 @@ function Compile(sourcecode, ActiveLangugaeKeywords) {
handleOutput(output + '\n', kalaam);
}

let message = ' Computer ने आपकी दी गयी वैल्यू, ' + '"' + RemoveBrackets(NextTokenValue) + '"' + ' को दिखाया है |';
let message = KalamOutputMessages[ActiveLanguage].message[0]+ RemoveBrackets(NextTokenValue) + KalamOutputMessages[ActiveLanguage].message[1];

//This is the experession whcih is getting evaluated.

let expression = token + NextTokenValue;
let description = 'किसी VALUE को OUTPUT SCREEN पे दिखाने के लिए दिखाए() का उपयोग होता है।';
// let description = 'किसी VALUE को OUTPUT SCREEN पे दिखाने के लिए दिखाए() का उपयोग होता है।';
let description = KalamOutputMessages[ActiveLanguage].description;

expression = GetcleanedExpression(expression);

Expand Down