forked from Arison99/Indabax-AI-Club-UTAMU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSunbirdAI Translate.html
243 lines (189 loc) · 13 KB
/
SunbirdAI Translate.html
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<script src="https://cdn.tailwindcss.com"></script>
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<title>Indabax AI Club UTAMU</title>
</head>
<body>
<!-- Navbar -->
<header class="bg-black text-white">
<div class="container mx-auto flex justify-between items-center p-4">
<img src="IndabaX_Images/Logo_1.jpg" class="logo w-12 h-12">
<nav class="hidden md:flex space-x-12 mr-32">
<a href="index.html" class="hover:text-gray-400">Home</a>
<a href="About.html" class="hover:text-gray-400">About</a>
<a href="members.html" class="hover:text-gray-400">Members</a>
<a href="club-activities.html" class="hover:text-gray-400">Club activities</a>
<a href="SunbirdAI Translate.html" class="hover:text-gray-400">SunbirdAI Translate</a>
<a href="Partners.html" class="hover:text-gray-400">Our partners</a>
</nav>
<div class="md:hidden">
<button id="menu-btn" class="text-white focus:outline-none">
<ion-icon name="menu" size="large"></ion-icon>
</button>
</div>
</div>
<div id="mobile-menu" class="hidden md:hidden bg-black text-white">
<a href="index.html" class="block px-4 py-2 hover:bg-gray-700">Home</a>
<a href="About.html" class="block px-4 py-2 hover:bg-gray-700">About</a>
<a href="members.html" class="block px-4 py-2 hover:bg-gray-700">Members</a>
<a href="club-activities.html" class="block px-4 py-2 hover:bg-gray-700">Club activities</a>
<a href="SunbirdAI Translate.html" class="block px-4 py-2 hover:bg-gray-700">SunbirdAI Translate</a>
<a href="Partners.html" class="block px-4 py-2 hover:bg-gray-700">Our partners</a>
</div>
</header>
<script>
const menuBtn = document.getElementById('menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
menuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
</script>
<!-- <style>
body {
background-image: url('IndabaX_Images/sunbirdAi.svg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 50% 30%;
}
</style> -->
</head>
<body>
<form class="flex-nowrap space-y-8" id="translationForm">
<h1 class="text-blue-600 text-center text-bold text-3xl font-mon0" >SunbirdAI Translation Tool</h1><br>
<img src="IndabaX_Images/sunbirdAi.svg" class="w-20 h-20 rounded-full mx-auto" alt="">
<div class="space-y-1">
<label class="text-blue-600 text-center flex justify-center italic text-sm subpixel-antialiased" for="textToTranslate">Text to translate:</label><br>
<div class="flex justify-center ">
<textarea class="flex justify-center bg-blue-300 px-4 py-6 text-center rounded-lg shadow-2xl" id="textToTranslate" rows="4" cols="50"></textarea><br>
</div>
</div>
<div class="flex flex-wrap justify-center space-x-4" >
<label class="text-blue-600 text-center text-bold text-lg " for="sourceLang">Source Language:
<input class="text-center rounded-lg shadow-lg italic w-64" type="text" id="sourceLang" placeholder="e.g., eng,lug,ach,teo,lgg,nyn"><br>
</label>
<label class="text-blue-600 text-center text-bold text-lg" for="targetLang">Target Language:
<input class="text-center rounded-lg shadow-lg italic w-64" type="text" id="targetLang" placeholder="e.g., eng,lug,ach,teo,lgg,nyn"><br>
</label>
</div>
<div class="flex justify-center">
<button class="flex text-sm px-2 py-3 bg-blue-600 text-white text-bold text-center bg-gradient-to-r from-teal-400 to-blue-500 hover:from-pink-500 hover:to-orange-500 rounded-full shadow-md cursor-pointer w-32 place-content-center " type="button" onclick="translateText()">
Translate
</button>
</div>
</form>
<div class="space-y-8"><br>
<h2 class="text-center text-blue-600 text-2xl ">Translation Result:</h2>
<div class="flex justify-center text-wrap text-center shadow-sm" id="translationResult"></div>
</div>
<!-- <div class="flex justify-center ">
<textarea class="flex justify-center items-center bg-blue-300 px-4 py-6 text-center rounded-lg shadow-2xl" id="translationResult" rows="10" cols="50"></textarea><br>
</div> -->
<script>
const translationUrl = 'https://api.sunbird.ai/tasks/nllb_translate';
const apiToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJBcmlzb245OSIsImFjY291bnRfdHlwZSI6IkZyZWUiLCJleHAiOjQ4ODA1OTkyMDN9.GLuCbrvFGfCTJmebK724_47jGx5jqUNHmAVIvmFfHbw'; // Replace with your actual API token
const requestHeaders = {
"Authorization": `Bearer ${apiToken}`,
"Content-Type": "application/json"
};
const getTranslation = async (text, sourceLang, targetLang) => {
console.log(`sourceLang ${sourceLang}`);
console.log(`targetLang ${targetLang}`);
const requestOptions = {
method: "POST",
headers: requestHeaders,
body: JSON.stringify({ source_language: sourceLang, target_language: targetLang, text })
};
try {
const response = await fetch(translationUrl, requestOptions);
if (!response.ok) {
throw new Error(`${response.status} ${response.statusText}`);
}
const responseJson = await response.json();
if (!responseJson || !responseJson.output) {
throw new Error("Invalid response structure");
}
const translatedText = responseJson.output.translated_text;
console.log(`translatedText ${translatedText}`);
return translatedText;
} catch (err) {
console.error(err);
return "Translation failed, try again.";
}
};
function translateText() {
const text = document.getElementById('textToTranslate').value;
const sourceLang = document.getElementById('sourceLang').value;
const targetLang = document.getElementById('targetLang').value;
const resultContainer = document.getElementById('translationResult');
getTranslation(text, sourceLang, targetLang).then(translatedText => {
resultContainer.innerText = translatedText;
}).catch(error => {
console.error('Error translating text:', error);
resultContainer.innerText = 'Translation failed. Please try again.';
});
}
</script>
<!--Footer-->
<section class="bg-gray-900 ">
<div class="">
<div class="">
</div>
<script>
var sidemenu= document.getElementById("sidemenu");
function openmenu(){
sidemenu.style.right="0";
}
function closemenu(){
sidemenu.style.right="-200px";
}
</script>
<hr class="mt-16 mb-10 border-gray-800" />
<p class="w-full mt-8 text-sm text-center text-gray-100 sm:mt-0 md:mt-0 lg:mt-0 sm:w-auto md:w-auto lg:w-auto xl:w-auto sm:order-2 md:order-2 lg:order-2 xl:order-2">© Copyright 2024, All Rights Reserved by Indabax AI Club UTAMU</p>
<div class="flex flex-wrap ">
<ul class="flex justify-end sm:space-x-3 md:space-x-3 lg:space-x-10 xl:space-x-10 sm:order-3 md:order-3 lg:order-3 xl:order-3">
<li>
<a href="https://x.com/UTAMU/_AI?t=FR7_QAM60tlkssdK0gaKxQs=09" title="Twitter" class="flex items-center justify-center text-white transition-all duration-200 bg-transparent border border-gray-700 rounded-full w-7 h-7 focus:bg-blue-600 hover:bg-blue-600 hover:border-blue-600 focus:border-blue-600">
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path
d="M19.633 7.997c.013.175.013.349.013.523 0 5.325-4.053 11.461-11.46 11.461-2.282 0-4.402-.661-6.186-1.809.324.037.636.05.973.05a8.07 8.07 0 0 0 5.001-1.721 4.036 4.036 0 0 1-3.767-2.793c.249.037.499.062.761.062.361 0 .724-.05 1.061-.137a4.027 4.027 0 0 1-3.23-3.953v-.05c.537.299 1.16.486 1.82.511a4.022 4.022 0 0 1-1.796-3.354c0-.748.199-1.434.548-2.032a11.457 11.457 0 0 0 8.306 4.215c-.062-.3-.1-.611-.1-.923a4.026 4.026 0 0 1 4.028-4.028c1.16 0 2.207.486 2.943 1.272a7.957 7.957 0 0 0 2.556-.973 4.02 4.02 0 0 1-1.771 2.22 8.073 8.073 0 0 0 2.319-.624 8.645 8.645 0 0 1-2.019 2.083z"
></path>
</svg>
</a>
</li>
<li>
<a href="https://chat.whatsapp.com/G340z9ppZjQGuRUfdjySqF" title="WhatsApp" class="flex items-center justify-center text-white transition-all duration-200 bg-transparent border border-gray-700 rounded-full w-7 h-7 focus:bg-blue-600 hover:bg-blue-600 hover:border-blue-600 focus:border-blue-600">
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor">
<path d="M16 .3C7.3.3.3 7.3.3 16c0 2.9.8 5.6 2.3 8L.1 31.8c-.2.6.4 1.2 1 .9l7.7-2.4c2.3 1.2 4.9 1.9 7.6 1.9 8.8 0 15.7-7 15.7-15.7S24.8.3 16 .3zm8.8 23.4c-.4 1-2.1 2-3.1 2.3-.8.3-1.9.5-6.5-1.4-5.4-2.1-8.9-7.5-9.2-7.9-.3-.4-2.2-2.9-2.2-5.5s1.4-3.9 2-4.4c.5-.5 1.1-.7 1.5-.7h1.1c.4 0 .8 0 1.2.9.5 1.4 1.8 4.7 2 5 .2.4.2.7 0 1.1-.2.4-.4.7-.7 1-.4.4-.7.7-.3 1.4 1.1 2 2.7 3.6 4.8 4.6.7.4 1.1.3 1.5-.2.4-.5.9-1.2 1.4-1.9.4-.7.7-.8 1.2-.6.5.2 3 1.4 3.5 1.7.4.2.7.3.9.5.1.2.1 1.1-.3 2.1z"/>
</svg>
</a>
</li>
<li>
<a href="https://github.com/IndabaxAIClubUTAMU" title="Github" class="flex items-center justify-center text-white transition-all duration-200 bg-transparent border border-gray-700 rounded-full w-7 h-7 focus:bg-blue-600 hover:bg-blue-600 hover:border-blue-600 focus:border-blue-600">
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12.026 2c-5.509 0-9.974 4.465-9.974 9.974 0 4.406 2.857 8.145 6.821 9.465.499.09.679-.217.679-.481 0-.237-.008-.865-.011-1.696-2.775.602-3.361-1.338-3.361-1.338-.452-1.152-1.107-1.459-1.107-1.459-.905-.619.069-.605.069-.605 1.002.07 1.527 1.028 1.527 1.028.89 1.524 2.336 1.084 2.902.829.091-.645.351-1.085.635-1.334-2.214-.251-4.542-1.107-4.542-4.93 0-1.087.389-1.979 1.024-2.675-.101-.253-.446-1.268.099-2.64 0 0 .837-.269 2.742 1.021a9.582 9.582 0 0 1 2.496-.336 9.554 9.554 0 0 1 2.496.336c1.906-1.291 2.742-1.021 2.742-1.021.545 1.372.203 2.387.099 2.64.64.696 1.024 1.587 1.024 2.675 0 3.833-2.33 4.675-4.552 4.922.355.308.675.916.675 1.846 0 1.334-.012 2.41-.012 2.737 0 .267.178.577.687.479C19.146 20.115 22 16.379 22 11.974 22 6.465 17.535 2 12.026 2z"
></path>
</svg>
</a>
</li>
<li>
<a href="https://t.me/+MaR2hpvvPCczMDJk" title="Telegram" class="flex items-center justify-center text-white transition-all duration-200 bg-transparent border border-gray-700 rounded-full w-7 h-7 focus:bg-blue-600 hover:bg-blue-600 hover:border-blue-600 focus:border-blue-600">
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M22.356 3.31a1.5 1.5 0 0 0-1.545-.18L2.18 10.468a1.5 1.5 0 0 0 .079 2.804l3.72 1.243 1.302 4.476c.274.948 1.616 1.082 2.143.202l2.75-4.488 4.344 3.826a1.5 1.5 0 0 0 2.448-.77l3.905-15.41a1.5 1.5 0 0 0-.758-1.042zM17.603 18.452l-6.178-5.442a.75.75 0 0 0-1.167.177l-3.131 5.11-1.003-3.45 8.48-5.227a.75.75 0 0 0-.753-1.293l-9.616 4.123-3.493-1.167L20.555 4.5l-2.952 13.952z"/>
</svg>
</a>
</li>
</ul>
</div>
</div>
</section>
</body>
</html>