From 08112f4a1214eae4480bea9e3a4d10b635eaa9dd Mon Sep 17 00:00:00 2001 From: Sourav12061999 Date: Mon, 8 Aug 2022 20:33:01 +0530 Subject: [PATCH 1/2] Added a feature to add languages dynamically in linebyline output --- Compiler/constants.js | 113 ++++++++++++++++++++++++------------------ Compiler/main.js | 7 +-- 2 files changed, 68 insertions(+), 52 deletions(-) diff --git a/Compiler/constants.js b/Compiler/constants.js index 0c2eec48..852e55db 100644 --- a/Compiler/constants.js +++ b/Compiler/constants.js @@ -1,80 +1,95 @@ -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: 'ला कोणती किंमत द्यायची आहे??', + 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: 'আপনি কি মান দিতে চান?', + 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: 'మీరు ఏ ధర చెల్లించాలనుకుంటున్నారు', + 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 पे दिखाने के लिए दिखाए() का उपयोग होता है।", }, }; -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, +}; diff --git a/Compiler/main.js b/Compiler/main.js index 14de7588..17255441 100644 --- a/Compiler/main.js +++ b/Compiler/main.js @@ -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'; @@ -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); From c0b3706331dd13579340522dd4d79a2625097803 Mon Sep 17 00:00:00 2001 From: Sourav12061999 Date: Tue, 9 Aug 2022 08:27:10 +0530 Subject: [PATCH 2/2] Added Hindi Marathi Bengla in KalamOutputMessages --- Compiler/constants.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Compiler/constants.js b/Compiler/constants.js index 852e55db..7290c4f3 100644 --- a/Compiler/constants.js +++ b/Compiler/constants.js @@ -69,6 +69,29 @@ const KalamOutputMessages = { description: "किसी VALUE को OUTPUT SCREEN पे दिखाने के लिए दिखाए() का उपयोग होता है।", }, + Marathi: { + message: [ + " संगणकाने तुम्हाला मूल्य दिले आहे, " + '"', + '"' + " दाखवले आहेत |", + ], + description: "आउटपुट स्क्रीनवर मूल्य दर्शविण्यासाठी दाखवा() वापरला जातो।", + }, + Bengali: { + message: [ + " Computer আপনার দেওয়া value, " + '"', + '"' + " কে দেখিয়েছে |", + ], + description: + "OUTPUT SCREEN এ একটি মান দেখানোর জন্য দেখাও() ব্যবহার করা হয়।", + }, + Telugu: { + message: [ + " Computer ने आपकी दी गयी वैल्यू, " + '"', + '"' + " को दिखाया है |", + ], + description: + "किसी VALUE को OUTPUT SCREEN पे दिखाने के लिए दिखाए() का उपयोग होता है।", + }, }; if (ActiveLanguage == "Hindi") {