-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
219 lines (195 loc) · 8.03 KB
/
index.html
File metadata and controls
219 lines (195 loc) · 8.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html lang="te">
<head>
<meta charset="UTF-8" />
<title>TL-Lang: Telugu Inspired Programming</title>
<script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<a href="https://bhashabytes.github.io/" class="site-logo" aria-label="BhashaBytes Home">
<img src="logo.png" alt="BhashaBytes Logo" />
</a>
<h1>TL-Lang: Telugu-Inspired Programming</h1>
<div class="intro-card">
<p>
Welcome to <strong>TL-Lang</strong> – a programming language designed especially for Telugu speakers!
TL-Lang makes coding more intuitive by using Telugu words and their transliterations as keywords,
instead of English-based Python syntax. It’s beginner-friendly and runs fully on Python via a translation layer.
</p>
<p>
Write code below, run it instantly, and explore TL-Lang’s features with live examples. Learning programming
has never been this friendly!
</p>
</div>
<div class="container">
<textarea id="teluguCode" rows="10" placeholder="Type your Telugu code here...">చూపించు("Hello TL-Lang!")</textarea>
<br>
<button onclick="runCode()">Run Code</button>
<pre id="output">Output will appear here...</pre>
</div>
<h2>Documentation & Examples</h2>
<div class="docs">
<h3>Print (చూపించు / chuppinchu)</h3>
<pre>చూపించు("Hello World")</pre>
<h3>Functions (నివారణ్చు / nivarinchu)</h3>
<pre>నివారణ్చు జోడించు(a, b):
తిరిగి ఇవ్వు a + b
చూపించు("ఫలితం =", జోడించు(5, 3))</pre>
<h3>Input (తీసుకో / tisuko)</h3>
<pre>a = int(తీసుకో("num1:"))
b = int(తీసుకో("num2:"))
చూపించు("మొత్తం =", a + b)</pre>
<h3>Conditionals</h3>
<pre>i = 5
ఒకవేళ i > 3:
చూపించు("i పెద్దది")
ఒకవెలలేదా i == 3:
చూపించు("i సమానమైంది")
లేదా:
చూపించు("i చిన్నది")</pre>
<h3>Loops</h3>
<pre>కొసం x in [1,2,3]:
చూపించు("x =", x)
i = 0
అయితే i < 3:
చూపించు("i =", i)
i += 1</pre>
<h3>Loop Control</h3>
<pre>కొసం x in [1,2,3]:
ఒకవేళ x == 2:
చూపించు("రెండు దొరికింది")
అగ్గు
లేదా:
చూపించు(x)</pre>
<h3>Booleans & None</h3>
<pre>ఒకవేళ నిజం:
చూపించు("true")
ఒకవెలలేదా అబద్ధం:
చూపించు("false")
చూపించు("విలువ లేదు =", ఏదీ లేదు)</pre>
<h3>Exceptions</h3>
<pre>ప్రయత్నించు:
1 / 0
తప్ప ZeroDivisionError:
చూపించు("శూన్యంతో భాగించడం సాధ్యం కాదు")
చివరగా:
చూపించు("ఇది ఎప్పుడూ జరుగుతుంది")</pre>
<h3>Imports</h3>
<pre>దిగుమతి math గా m
చూపించు(m.sqrt(4))</pre>
<p>Modify examples above and run your own TL-Lang code above!</p>
</div>
<h2>TL-Lang Keywords</h2>
<div class="reference-box">
<table>
<thead>
<tr>
<th>Python</th>
<th>Telugu Script</th>
<th>Transliteration</th>
</tr>
</thead>
<tbody>
<tr><td>print</td><td>చూపించు</td><td>chuppinchu</td></tr>
<tr><td>input</td><td>తీసుకో</td><td>tisuko</td></tr>
<tr><td>if</td><td>ఒకవేళ</td><td>okavela</td></tr>
<tr><td>elif</td><td>ఒకవెలలేదా</td><td>okavelaledha</td></tr>
<tr><td>else</td><td>లేదా</td><td>ledha</td></tr>
<tr><td>for</td><td>కొసం</td><td>kosam</td></tr>
<tr><td>or</td><td>లేకపోతే</td><td>lekapothe</td></tr>
<tr><td>while</td><td>అయితే</td><td>ayithe</td></tr>
<tr><td>def</td><td>నివారణ్చు</td><td>nivarinchu</td></tr>
<tr><td>class</td><td>వర్గం</td><td>vargam</td></tr>
<tr><td>return</td><td>తిరిగి ఇవ్వు</td><td>tirigiivvu</td></tr>
<tr><td>break</td><td>అగ్గు</td><td>aggu</td></tr>
<tr><td>continue</td><td>కొనసాగించు</td><td>konasaginchu</td></tr>
<tr><td>import</td><td>దిగుమతి</td><td>digumati</td></tr>
<tr><td>from</td><td>నుండి</td><td>nundi</td></tr>
<tr><td>as</td><td>గా</td><td>ga</td></tr>
<tr><td>with</td><td>తో</td><td>tho</td></tr>
<tr><td>try</td><td>ప్రయత్నించు</td><td>prayatninchu</td></tr>
<tr><td>except</td><td>తప్ప</td><td>tappa</td></tr>
<tr><td>finally</td><td>చివరగా</td><td>chivariga</td></tr>
<tr><td>True</td><td>నిజం</td><td>nijam</td></tr>
<tr><td>False</td><td>అబద్ధం</td><td>abaddham</td></tr>
<tr><td>None</td><td>ఏదీ లేదు</td><td>ediledu</td></tr>
</tbody>
</table>
</div>
<script>
let pyodideReady = false;
let pyodide;
async function loadPyodideAndPackages() {
pyodide = await loadPyodide();
// redirect print → <pre>
pyodide.runPython(`
import sys
from js import document, prompt
class OutputCatcher:
def write(self, s):
if s.strip():
document.getElementById("output").textContent += s + "\\n"
def flush(self): pass
sys.stdout = OutputCatcher()
sys.stderr = OutputCatcher()
# redefine input
def input(msg=""):
resp = prompt(str(msg))
return "" if resp is None else str(resp)
`);
pyodideReady = true;
}
loadPyodideAndPackages();
const mapping = {
"చూపించు": "print", "chuppinchu": "print",
"తీసుకో": "input", "tisuko": "input",
"ఒకవేళ": "if", "okavela": "if",
"ఒకవెలలేదా": "elif", "okavelaledha": "elif",
"లేదా": "else", "ledha": "else",
"కొసం": "for", "kosam": "for",
"అయితే": "while", "ayithe": "while",
"నివారణ్చు": "def", "nivarinchu": "def",
"వర్గం": "class", "vargam": "class",
"తిరిగి ఇవ్వు": "return", "tirigiivvu": "return",
"అగ్గు": "break", "aggu": "break",
"కొనసాగించు": "continue", "konasaginchu": "continue",
"దిగుమతి": "import", "digumati": "import",
"నుండి": "from", "nundi": "from",
"గా": "as", "ga": "as",
"తో": "with", "tho": "with",
"ప్రయత్నించు": "try", "prayatninchu": "try",
"తప్పు": "except", "tappa": "except",
"చివరగా": "finally", "chivariga": "finally",
"నిజం": "True", "nijam": "True",
"అబద్ధం": "False", "abaddham": "False",
"ఏదీ లేదు": "None", "ediledu": "None",
"లేకపోతే": "or", "lekapothe": "or"
};
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function translate(code) {
for (let tel in mapping) {
const re = new RegExp(`(?<!\\w)${escapeRegExp(tel)}(?!\\w)`, 'gu');
code = code.replace(re, mapping[tel]);
}
return code;
}
async function runCode() {
if (!pyodideReady) {
alert("Pyodide is still loading...");
return;
}
document.getElementById("output").textContent = "";
const rawCode = document.getElementById("teluguCode").value;
const pyCode = translate(rawCode);
try {
await pyodide.runPythonAsync(pyCode);
} catch (err) {
document.getElementById("output").textContent += "Error: " + err + "\n";
}
}
</script>
</body>
</html>