An online language translator is a digital tool that converts text or speech from one language to another. These translators use advanced technologies like artificial intelligence (AI), neural machine translation (NMT), and natural language processing (NLP) to provide accurate and context-aware translations.
Top Online Language Translators in 2024
1. Google Translate
Features:
Supports 100+ languages
Text, voice, and image translation
Offline mode available
Website and app integration
Best for: Quick translations, travelers, and students
2. DeepL Translator
Features:
High accuracy with natural-sounding translations
Supports 30+ languages
Document translation (PDF, Word, etc.)
Better context understanding than many competitors
Best for: Business professionals and academic use
3. Microsoft Translator
Features:
Real-time conversation translation
Multi-device compatibility
Supports 70+ languages
Integration with Microsoft Office
Best for: Meetings and collaborative work
4. Reverso Context
Features:
Provides translations with real-life examples
Grammar and spell-check tools
Supports 14 languages
Language learning features
Best for: Language learners and writers
5. Bing Translator
Features:
Powered by Microsoft AI
Text and website translation
Supports 60+ languages
Simple and user-friendly interface
Best for: Casual users and quick translations
How to Choose the Best Online Translator?
When selecting an online translator, consider:
✔ Language Support – Does it cover the languages you need?
✔ Accuracy – Does it provide context-aware translations?
✔ Features – Voice, image, or document translation?
✔ Offline Access – Useful for travelers
✔ Integration – Can it be used in apps or websites?
Limitations of Online Translators
While online translators are helpful, they may struggle with:
Idioms and slang – Literal translations can be inaccurate.
Complex sentences – Nuanced meanings may be lost.
Privacy concerns – Avoid translating sensitive information.
Conclusion
Online language translators have revolutionized global communication, making it easier to understand and connect across languages. Whether you need a quick translation or a professional-grade tool, options like Google Translate, DeepL, and Microsoft Translator offer powerful solutions. Choose the one that best fits your needs and explore the world without language barriers!
Do you use an online translator? Share your favorite in the comments! 🌍✨
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Techpk - Ultimate AI Translation Tool</title>
<meta name="description" content="Free AI-powered translation tool by Techpk, supporting 100+ languages including Urdu. Instantly translate text with accurate results.">
<meta name="keywords" content="translation, translator, AI translator, language translation, multilingual, Techpk, Urdu translation">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
/* Base Styles - Black and Red Theme with Animations */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Inter', system-ui, sans-serif;
}
body {
background: #000000;
color: #FFFFFF;
line-height: 1.6;
overflow-x: hidden;
}
/* Header Styles with Animation */
.header {
background: linear-gradient(to right, #1A0000, #400000);
padding: 1.5rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2px solid #FF0000;
position: relative;
animation: fadeInDown 0.8s ease-out;
}
.header::after {
content: '';
position: absolute;
bottom: -5px;
left: 0;
width: 100%;
height: 3px;
background: linear-gradient(to right, transparent, #FF0000, transparent);
animation: pulse 2s infinite;
}
.logo-area {
display: flex;
align-items: center;
transition: transform 0.3s ease;
}
.logo-area:hover {
transform: scale(1.05);
}
.logo-circle {
width: 60px;
height: 60px;
background: linear-gradient(135deg, #FF0000, #800000);
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
margin-right: 1rem;
flex-shrink: 0;
box-shadow: 0 0 15px rgba(255, 0, 0, 0.7);
animation: pulse 2s infinite;
}
.logo-circle span {
font-size: 1.8rem;
font-weight: bold;
color: #FFFFFF;
}
.header .brand-name {
color: #FF0000;
font-size: 2rem;
font-weight: 700;
text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
letter-spacing: 1px;
}
.header .page-title {
color: #FFFFFF;
font-size: 1.8rem;
font-weight: 600;
text-align: right;
text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}
/* Main Translator Container with Glow Effect */
.translator-container {
max-width: 1000px;
margin: 3rem auto;
padding: 2.5rem;
background: linear-gradient(to bottom, #1A0000, #250000);
border-radius: 15px;
box-shadow: 0 10px 30px rgba(255, 0, 0, 0.3);
border: 2px solid #FF0000;
position: relative;
overflow: hidden;
animation: fadeInUp 0.8s ease-out;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.translator-container:hover {
transform: translateY(-5px);
box-shadow: 0 15px 35px rgba(255, 0, 0, 0.4);
}
.translator-container::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,0,0,0.1) 0%, transparent 70%);
animation: rotate 20s linear infinite;
z-index: -1;
}
.tool-title {
text-align: center;
color: #FF0000;
font-size: 2.5rem;
margin-bottom: 2rem;
font-weight: 700;
text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
letter-spacing: 1px;
position: relative;
display: inline-block;
width: 100%;
}
.tool-title::after {
content: '';
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 100px;
height: 3px;
background: linear-gradient(to right, transparent, #FF0000, transparent);
}
.language-selectors {
display: flex;
gap: 1.5rem;
margin-bottom: 2rem;
align-items: center;
}
select {
flex: 1;
padding: 1rem 1.2rem;
border: 2px solid #FF0000;
border-radius: 10px;
font-size: 1.1rem;
background-color: #000000;
color: #FFFFFF;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FF0000' width='20px' height='20px'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 1.2rem center;
transition: all 0.3s ease;
cursor: pointer;
}
select:focus {
outline: none;
border-color: #FF0000;
box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.5);
transform: translateY(-2px);
}
select:hover {
background-color: #110000;
}
button#swapLanguages {
background: linear-gradient(135deg, #FF0000, #800000);
color: #FFFFFF;
border: none;
cursor: pointer;
font-size: 1.5rem;
padding: 1rem;
border-radius: 10px;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
width: 60px;
height: 60px;
box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
}
button#swapLanguages:hover {
transform: translateY(-3px) scale(1.05);
box-shadow: 0 6px 20px rgba(255, 0, 0, 0.6);
background: linear-gradient(135deg, #FF3333, #990000);
}
button#swapLanguages:active {
transform: translateY(1px);
}
.text-areas {
display: grid;
grid-template-columns: 1fr;
gap: 2rem;
min-height: 300px;
}
.text-area-container {
position: relative;
}
.speak-btn {
position: absolute;
right: 15px;
bottom: 15px;
background: rgba(255, 0, 0, 0.7);
border: none;
border-radius: 50%;
width: 40px;
height: 40px;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
z-index: 2;
}
.speak-btn:hover {
background: rgba(255, 0, 0, 0.9);
transform: scale(1.1);
}
textarea {
width: 100%;
height: 100%;
padding: 1.2rem;
border: 2px solid #FF0000;
border-radius: 10px;
resize: none;
font-size: 1.1rem;
background-color: #000000;
color: #FFFFFF;
min-height: 200px;
transition: all 0.3s ease;
}
textarea:focus {
outline: none;
border-color: #FF0000;
box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.5);
transform: translateY(-3px);
}
textarea:hover {
background-color: #110000;
}
textarea::placeholder {
color: #888888;
opacity: 0.7;
}
/* Action Buttons */
.action-buttons {
display: flex;
justify-content: center;
gap: 1.5rem;
margin-top: 2rem;
}
.btn {
padding: 0.8rem 1.8rem;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
border: none;
display: flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background: linear-gradient(135deg, #FF0000, #800000);
color: white;
box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
}
.btn-primary:hover {
transform: translateY(-3px);
box-shadow: 0 6px 20px rgba(255, 0, 0, 0.5);
background: linear-gradient(135deg, #FF3333, #990000);
}
.btn-secondary {
background: linear-gradient(135deg, #333333, #111111);
color: white;
border: 1px solid #FF0000;
}
.btn-secondary:hover {
transform: translateY(-3px);
box-shadow: 0 6px 15px rgba(255, 0, 0, 0.3);
background: linear-gradient(135deg, #444444, #222222);
}
/* Content Section Styling */
.content-section {
max-width: 1000px;
margin: 3rem auto;
padding: 2.5rem;
background: linear-gradient(to bottom, #1A0000, #250000);
border-radius: 15px;
border: 2px solid #FF0000;
box-shadow: 0 10px 25px rgba(255, 0, 0, 0.2);
animation: fadeIn 1s ease-out;
}
.content-section h2 {
color: #FF0000;
margin-bottom: 1.5rem;
text-align: center;
font-size: 2rem;
text-shadow: 0 0 8px rgba(255,0,0,0.5);
position: relative;
padding-bottom: 10px;
}
.content-section h2::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 80px;
height: 3px;
background: linear-gradient(to right, transparent, #FF0000, transparent);
}
.editable-content {
width: 100%;
min-height: 200px;
margin-top: 1.5rem;
animation: fadeIn 1.2s ease-out;
}
/* Features Section */
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
margin-top: 3rem;
}
.feature-card {
background: linear-gradient(to bottom, #1A0000, #200000);
border-radius: 12px;
padding: 1.5rem;
border: 1px solid #FF0000;
box-shadow: 0 5px 15px rgba(255, 0, 0, 0.2);
transition: all 0.3s ease;
}
.feature-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(255, 0, 0, 0.3);
border-color: #FF3333;
}
.feature-icon {
font-size: 2.5rem;
color: #FF0000;
margin-bottom: 1rem;
text-align: center;
}
.feature-title {
color: #FF0000;
font-size: 1.3rem;
margin-bottom: 1rem;
text-align: center;
font-weight: 600;
}
.feature-desc {
color: #DDDDDD;
text-align: center;
line-height: 1.7;
}
/* Footer Styles with Animation */
.footer {
background: linear-gradient(to right, #1A0000, #400000);
padding: 3rem 1rem;
margin-top: 5rem;
text-align: center;
color: #FFFFFF;
border-top: 2px solid #FF0000;
position: relative;
animation: fadeIn 1s ease-out;
}
.footer::before {
content: '';
position: absolute;
top: -5px;
left: 0;
width: 100%;
height: 3px;
background: linear-gradient(to right, transparent, #FF0000, transparent);
}
.footer-links {
display: flex;
justify-content: center;
gap: 2.5rem;
margin-bottom: 2rem;
list-style: none;
flex-wrap: wrap;
}
.footer-links a {
color: #FFFFFF;
text-decoration: none;
transition: all 0.3s ease;
font-size: 1.1rem;
position: relative;
padding: 0.5rem 0;
}
.footer-links a::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 2px;
background: #FF0000;
transition: width 0.3s ease;
}
.footer-links a:hover {
color: #FF0000;
transform: translateY(-2px);
}
.footer-links a:hover::after {
width: 100%;
}
.footer p {
font-size: 1rem;
opacity: 0.8;
margin-top: 1.5rem;
}
.social-links {
display: flex;
justify-content: center;
gap: 1.5rem;
margin-top: 1.5rem;
}
.social-links a {
color: #FFFFFF;
font-size: 1.5rem;
transition: all 0.3s ease;
}
.social-links a:hover {
color: #FF0000;
transform: translateY(-3px) scale(1.2);
}
/* Animations */
@keyframes pulse {
0% { opacity: 0.7; }
50% { opacity: 1; }
100% { opacity: 0.7; }
}
@keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes glow {
0% { box-shadow: 0 0 5px rgba(255, 0, 0, 0.5); }
50% { box-shadow: 0 0 20px rgba(255, 0, 0, 0.8); }
100% { box-shadow: 0 0 5px rgba(255, 0, 0, 0.5); }
}
/* Language Flags */
.language-flag {
width: 24px;
height: 16px;
margin-right: 8px;
vertical-align: middle;
border-radius: 2px;
}
/* RTL Support for Urdu */
.rtl-text {
direction: rtl;
text-align: right;
font-family: 'Noto Sans Arabic', 'Inter', sans-serif;
font-size: 1.2rem;
line-height: 2;
}
/* Responsive Design */
@media (min-width: 768px) {
.text-areas {
grid-template-columns: 1fr 1fr;
}
}
@media (max-width: 767px) {
.header {
flex-direction: column;
gap: 1.5rem;
padding: 1.5rem;
text-align: center;
}
.header .page-title {
text-align: center;
font-size: 1.5rem;
}
.translator-container, .content-section {
margin: 1.5rem;
padding: 1.8rem;
}
.tool-title {
font-size: 2rem;
}
.language-selectors {
flex-direction: column;
}
select, button#swapLanguages {
width: 100%;
}
button#swapLanguages {
height: auto;
padding: 1rem;
width: 100%;
margin: 0.5rem 0;
}
.action-buttons {
flex-direction: column;
gap: 1rem;
}
.btn {
width: 100%;
justify-content: center;
}
}
@media (max-width: 480px) {
.header .brand-name {
font-size: 1.8rem;
}
.logo-circle {
width: 50px;
height: 50px;
}
.logo-circle span {
font-size: 1.5rem;
}
.tool-title {
font-size: 1.8rem;
}
.content-section h2 {
font-size: 1.6rem;
}
.footer-links {
flex-direction: column;
gap: 1rem;
}
}
</style>
</head>
<body>
<!-- Animated Background Elements -->
<div class="bg-elements">
<div class="bg-red-dot" style="position: fixed; top: 20%; left: 10%; width: 10px; height: 10px; background: #FF0000; border-radius: 50%; filter: blur(1px); opacity: 0.7; animation: float 8s infinite ease-in-out;"></div>
<div class="bg-red-dot" style="position: fixed; top: 70%; left: 85%; width: 15px; height: 15px; background: #FF0000; border-radius: 50%; filter: blur(1.5px); opacity: 0.5; animation: float 10s infinite ease-in-out 2s;"></div>
<div class="bg-red-dot" style="position: fixed; top: 40%; left: 65%; width: 8px; height: 8px; background: #FF0000; border-radius: 50%; filter: blur(1px); opacity: 0.6; animation: float 12s infinite ease-in-out 4s;"></div>
</div>
<!-- Header Section -->
<header class="header">
<div class="logo-area">
<div class="logo-Square">
<span>TP</span>
</div>
<h1 class="brand-name animate__animated animate__fadeIn">Techpk</h1>
</div>
<h2 class="page-title animate__animated animate__fadeIn">Ultimate AI Translation Tool</h2>
</header>
<!-- Main Content -->
<main>
<div class="translator-container">
<center> techpk </center>
<h3 class="tool-title animate__animated animate__fadeIn">Translate Text Instantly</h3>
<!-- Language Selection -->
<div class="language-selectors">
<select id="sourceLang">
<option value="auto">Detect Language</option>
</select>
<button id="swapLanguages" title="Swap Languages" class="animate__animated animate__pulse animate__infinite animate__slower">↔</button>
<select id="targetLang">
</select>
</div>
<!-- Text Areas with Speak Buttons -->
<div class="text-areas">
<div class="text-area-container">
<textarea id="sourceText" placeholder="Enter text to translate..." class="animate__animated animate__fadeInLeft"></textarea>
<button class="speak-btn" title="Listen to source text">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path d="M3.5 6.5A.5.5 0 0 1 4 7v1a4 4 0 0 0 8 0V7a.5.5 0 0 1 1 0v1a5 5 0 0 1-4.5 4.975V15h3a.5.5 0 0 1 0 1h-7a.5.5 0 0 1 0-1h3v-2.025A5 5 0 0 1 3 8V7a.5.5 0 0 1 .5-.5z"/>
<path d="M10 8a2 2 0 1 1-4 0V3a2 2 0 1 1 4 0v5zM8 0a3 3 0 0 0-3 3v5a3 3 0 0 0 6 0V3a3 3 0 0 0-3-3z"/>
</svg>
</button>
</div>
<div class="text-area-container">
<textarea id="translatedText" placeholder="Translation will appear here..." readonly class="animate__animated animate__fadeInRight"></textarea>
<button class="speak-btn" title="Listen to translation">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path d="M3.5 6.5A.5.5 0 0 1 4 7v1a4 4 0 0 0 8 0V7a.5.5 0 0 1 1 0v1a5 5 0 0 1-4.5 4.975V15h3a.5.5 0 0 1 0 1h-7a.5.5 0 0 1 0-1h3v-2.025A5 5 0 0 1 3 8V7a.5.5 0 0 1 .5-.5z"/>
<path d="M10 8a2 2 0 1 1-4 0V3a2 2 0 1 1 4 0v5zM8 0a3 3 0 0 0-3 3v5a3 3 0 0 0 6 0V3a3 3 0 0 0-3-3z"/>
</svg>
</button>
</div>
</div>
<!-- Action Buttons -->
<div class="action-buttons">
<button id="downloadBtn" class="btn btn-primary animate__animated animate__fadeInUp">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" style="margin-right: 5px;">
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>
<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/>
</svg>
Download Translation
</button>
<button id="clearBtn" class="btn btn-secondary animate__animated animate__fadeInUp animate__delay-1s">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" style="margin-right: 5px;">
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
</svg>
Clear All
</button>
</div>
</div>
<!-- Features Section -->
<div class="content-section">
<center>techpk</center>
<h2 class="animate__animated animate__fadeIn">Why Choose Our Translator?</h2>
<div class="features">
<div class="feature-card animate__animated animate__fadeInUp">
<div class="feature-icon">🌍</div>
<h3 class="feature-title">100+ Languages</h3>
<p class="feature-desc">Supports translation between over 100 languages including Urdu, Arabic, English, Spanish, French and many more with high accuracy.</p>
</div>
<div class="feature-card animate__animated animate__fadeInUp animate__delay-1s">
<div class="feature-icon">🔊</div>
<h3 class="feature-title">Text-to-Speech</h3>
<p class="feature-desc">Listen to both source and translated text with our built-in speech synthesis feature.</p>
</div>
<div class="feature-card animate__animated animate__fadeInUp animate__delay-2s">
<div class="feature-icon">⚡</div>
<h3 class="feature-title">Instant Translation</h3>
<p class="feature-desc">Translates automatically as you type, no need to press any button.</p>
</div>
</div>
</div>
<!-- About Section -->
<div class="content-section animate__animated animate__fadeIn"><center> techpk </center>
<h2>About This Tool</h2>
<textarea class="editable-content" placeholder="Add your content here...">
Our AI-powered translation tool, part of the Techpk suite, supports over 100 languages including Urdu with high accuracy.
Key Features:
- Instant text translation with real-time results
- Automatic language detection
- Full Urdu language support with RTL formatting
- Text-to-speech for both source and translated text
- Download translations as text files
- Sleek, modern, mobile-friendly interface
- Free to use for all your translation needs
Simply enter your text, select your desired languages, and get instant, reliable translations. Perfect for personal, educational, and professional use!
Techpk is committed to providing free, high-quality tools to break language barriers worldwide. Our translation engine is constantly improving to deliver the most accurate results possible.
</textarea>
</div>
</main>
<!-- Footer Section -->
<footer class="footer">
<ul class="footer-links">
<li><a href="adsterra">Privacy Policy</a></li>
<li><a href="adsterra">Terms of Service</a></li>
<li><a href="adsterra">Contact Us</a></li>
<li><a href="adsterra">About Techpk</a></li>
<li><a href="adsterra">Help Center</a></li>
</ul>
<div class="social-links">
<a href="adsterra" title="Facebook"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8.049c0-4.446-3.582-8.05-8-8.05C3.58 0-.002 3.603-.002 8.05c0 4.017 2.926 7.347 6.75 7.951v-5.625h-2.03V8.05H6.75V6.275c0-2.017 1.195-3.131 3.022-3.131.876 0 1.791.157 1.791.157v1.98h-1.009c-.993 0-1.303.621-1.303 1.258v1.51h2.218l-.354 2.326H9.25V16c3.824-.604 6.75-3.934 6.75-7.951z"/></svg></a>
<a href="adsterra" title="Twitter"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M5.026 15c6.038 0 9.341-5.003 9.341-9.334 0-.14 0-.282-.006-.422A6.685 6.685 0 0 0 16 3.542a6.658 6.658 0 0 1-1.889.518 3.301 3.301 0 0 0 1.447-1.817 6.533 6.533 0 0 1-2.087.793A3.286 3.286 0 0 0 7.875 6.03a9.325 9.325 0 0 1-6.767-3.429 3.289 3.289 0 0 0 1.018 4.382A3.323 3.323 0 0 1 .64 6.575v.045a3.288 3.288 0 0 0 2.632 3.218 3.203 3.203 0 0 1-.865.115 3.23 3.23 0 0 1-.614-.057 3.283 3.283 0 0 0 3.067 2.277A6.588 6.588 0 0 1 .78 13.58a6.32 6.32 0 0 1-.78-.045A9.344 9.344 0 0 0 5.026 15z"/></svg></a>
<a href="adsterra" title="Instagram"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M8 0C5.829 0 5.556.01 4.703.048 3.85.088 3.269.222 2.76.42a3.917 3.917 0 0 0-1.417.923A3.927 3.927 0 0 0 .42 2.76C.222 3.268.087 3.85.048 4.7.01 5.555 0 5.827 0 8.001c0 2.172.01 2.444.048 3.297.04.852.174 1.433.372 1.942.205.526.478.972.923 1.417.444.445.89.719 1.416.923.51.198 1.09.333 1.942.372C5.555 15.99 5.827 16 8 16s2.444-.01 3.298-.048c.851-.04 1.434-.174 1.943-.372a3.916 3.916 0 0 0 1.416-.923c.445-.445.718-.891.923-1.417.197-.509.332-1.09.372-1.942C15.99 10.445 16 10.173 16 8s-.01-2.445-.048-3.299c-.04-.851-.175-1.433-.372-1.941a3.926 3.926 0 0 0-.923-1.417A3.911 3.911 0 0 0 13.24.42c-.51-.198-1.092-.333-1.943-.372C10.443.01 10.172 0 7.998 0h.003zm-.717 1.442h.718c2.136 0 2.389.007 3.232.046.78.035 1.204.166 1.486.275.373.145.64.319.92.599.28.28.453.546.598.92.11.281.24.705.275 1.485.039.843.047 1.096.047 3.231s-.008 2.389-.047 3.232c-.035.78-.166 1.203-.275 1.485a2.47 2.47 0 0 1-.599.919c-.28.28-.546.453-.92.598-.28.11-.704.24-1.485.276-.843.038-1.096.047-3.232.047s-2.39-.009-3.233-.047c-.78-.036-1.203-.166-1.485-.276a2.478 2.478 0 0 1-.92-.598 2.48 2.48 0 0 1-.6-.92c-.109-.281-.24-.705-.275-1.485-.038-.843-.046-1.096-.046-3.233 0-2.136.008-2.388.046-3.231.036-.78.166-1.204.276-1.486.145-.373.319-.64.599-.92.28-.28.546-.453.92-.598.282-.11.705-.24 1.485-.276.738-.034 1.024-.044 2.515-.045v.002zm4.988 1.328a.96.96 0 1 0 0 1.92.96.96 0 0 0 0-1.92zm-4.27 1.122a4.109 4.109 0 1 0 0 8.217 4.109 4.109 0 0 0 0-8.217zm0 1.441a2.667 2.667 0 1 1 0 5.334 2.667 2.667 0 0 1 0-5.334z"/></svg></a>
<a href="adsterra" title="YouTube"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M8.051 1.999h.089c.822.003 4.987.033 6.11.335a2.01 2.01 0 0 1 1.415 1.42c.101.38.172.883.22 1.402l.01.104.022.26.008.104c.065.914.073 1.77.074 1.957v.075c-.001.194-.01 1.108-.082 2.06l-.008.105-.009.104c-.05.572-.124 1.14-.235 1.558a2.007 2.007 0 0 1-1.415 1.42c-1.16.312-5.569.334-6.18.335h-.142c-.309 0-1.587-.006-2.927-.052l-.17-.006-.087-.004-.171-.007-.171-.007c-1.11-.049-2.167-.128-2.654-.26a2.007 2.007 0 0 1-1.415-1.419c-.111-.417-.185-.986-.235-1.558L.09 9.82l-.008-.104A31.4 31.4 0 0 1 0 7.68v-.123c.002-.215.01-.958.064-1.778l.007-.103.003-.052.008-.104.022-.26.01-.104c.048-.519.119-1.023.22-1.402a2.007 2.007 0 0 1 1.415-1.42c.487-.13 1.544-.21 2.654-.26l.17-.007.172-.006.086-.003.171-.007A99.788 99.788 0 0 1 7.858 2h.193zM6.4 5.209v4.818l4.157-2.408L6.4 5.209z"/></svg></a>
</div>
<p>© <span id="currentYear"></span> Techpk. All rights reserved.</p>
</footer>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Set current year in footer
document.getElementById('currentYear').textContent = new Date().getFullYear();
// Enhanced language list with Urdu and more
const languages = [
{ code: 'en', name: 'English' },
{ code: 'ur', name: 'Urdu' }, // Added Urdu language
{ code: 'ar', name: 'Arabic' },
{ code: 'fr', name: 'French' },
{ code: 'es', name: 'Spanish' },
{ code: 'de', name: 'German' },
{ code: 'hi', name: 'Hindi' },
{ code: 'or', name: 'Odia' },
{ code: 'te', name: 'Telugu' },
{ code: 'ta', name: 'Tamil' },
{ code: 'gu', name: 'Gujarati' },
{ code: 'sa', name: 'Sanskrit' },
{ code: 'zh-CN', name: 'Chinese (Simplified)' },
{ code: 'ja', name: 'Japanese' },
{ code: 'ru', name: 'Russian' },
{ code: 'pt', name: 'Portuguese' },
{ code: 'it', name: 'Italian' },
{ code: 'bn', name: 'Bengali' },
{ code: 'pa', name: 'Punjabi' },
{ code: 'mr', name: 'Marathi' },
{ code: 'ml', name: 'Malayalam' },
{ code: 'kn', name: 'Kannada' },
{ code: 'ko', name: 'Korean' },
{ code: 'tr', name: 'Turkish' },
{ code: 'nl', name: 'Dutch' },
{ code: 'sv', name: 'Swedish' }
];
const sourceLangSelect = document.getElementById('sourceLang');
const targetLangSelect = document.getElementById('targetLang');
const sourceTextarea = document.getElementById('sourceText');
const translatedTextarea = document.getElementById('translatedText');
const downloadBtn = document.getElementById('downloadBtn');
const clearBtn = document.getElementById('clearBtn');
const speakButtons = document.querySelectorAll('.speak-btn');
// Populate language dropdowns
languages.forEach(lang => {
// Add to source language select (excluding "Detect Language" option)
const optionSrc = new Option(lang.name, lang.code);
sourceLangSelect.add(optionSrc);
// Add to target language select
const optionTgt = new Option(lang.name, lang.code);
targetLangSelect.add(optionTgt);
});
// Set default target language
targetLangSelect.value = 'en'; // Default to English
// Translation functionality with RTL support for Urdu/Arabic
function translateText() {
const sourceText = sourceTextarea.value.trim();
const sLang = sourceLangSelect.value;
const tLang = targetLangSelect.value;
if (!sourceText) {
translatedTextarea.value = '';
translatedTextarea.classList.remove('rtl-text');
return;
}
// Show translating animation
translatedTextarea.value = "Translating...";
const url = `https://translate.googleapis.com/translate_a/single?client=gtx&sl=${sLang}&tl=${tLang}&dt=t&q=${encodeURIComponent(sourceText)}`;
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data && data[0] && data[0][0] && data[0][0][0]) {
const translation = data[0].map(item => item[0]).join('');
translatedTextarea.value = translation;
// Apply RTL styling for Urdu/Arabic
if (tLang === 'ur' || tLang === 'ar') {
translatedTextarea.classList.add('rtl-text');
} else {
translatedTextarea.classList.remove('rtl-text');
}
// Add animation to result
translatedTextarea.classList.add('animate__animated', 'animate__fadeIn');
setTimeout(() => {
translatedTextarea.classList.remove('animate__animated', 'animate__fadeIn');
}, 1000);
} else {
translatedTextarea.value = 'Translation not available.';
}
})
.catch(error => {
console.error('Translation Error:', error);
translatedTextarea.value = 'Translation failed. Please check console or try again.';
});
}
// Text-to-speech functionality
function speakText(text, lang) {
if ('speechSynthesis' in window) {
const utterance = new SpeechSynthesisUtterance(text);
// Set language based on the text area
utterance.lang = lang === 'source' ?
(sourceLangSelect.value === 'auto' ? 'en' : sourceLangSelect.value) :
targetLangSelect.value;
// For Urdu specifically
if (utterance.lang === 'ur') {
utterance.lang = 'ur-PK'; // Urdu-Pakistan
}
// For Arabic specifically
if (utterance.lang === 'ar') {
utterance.lang = 'ar-SA'; // Arabic-Saudi Arabia
}
speechSynthesis.cancel(); // Cancel any ongoing speech
speechSynthesis.speak(utterance);
} else {
alert('Text-to-speech is not supported in your browser. Please try Chrome or Edge.');
}
}
// Set up speak buttons
speakButtons[0].addEventListener('click', () => {
const text = sourceTextarea.value;
if (text) {
speakText(text, 'source');
// Add animation
speakButtons[0].classList.add('animate__animated', 'animate__pulse');
setTimeout(() => {
speakButtons[0].classList.remove('animate__animated', 'animate__pulse');
}, 1000);
}
});
speakButtons[1].addEventListener('click', () => {
const text = translatedTextarea.value;
if (text && text !== 'Translating...' && text !== 'Translation not available.') {
speakText(text, 'target');
// Add animation
speakButtons[1].classList.add('animate__animated', 'animate__pulse');
setTimeout(() => {
speakButtons[1].classList.remove('animate__animated', 'animate__pulse');
}, 1000);
}
});
// Download translation as text file
downloadBtn.addEventListener('click', () => {
const translation = translatedTextarea.value;
if (!translation || translation === 'Translating...' || translation === 'Translation not available.') {
alert('No translation to download!');
return;
}
const tLang = targetLangSelect.value;
const langName = languages.find(l => l.code === tLang)?.name || 'translation';
const filename = `techpk_${langName}_translation.txt`;
const blob = new Blob([translation], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
// Add download animation
downloadBtn.classList.add('animate__animated', 'animate__bounce');
setTimeout(() => {
downloadBtn.classList.remove('animate__animated', 'animate__bounce');
}, 1000);
});
// Clear all text
clearBtn.addEventListener('click', () => {
sourceTextarea.value = '';
translatedTextarea.value = '';
translatedTextarea.classList.remove('rtl-text');
// Add clear animation
clearBtn.classList.add('animate__animated', 'animate__shakeX');
setTimeout(() => {
clearBtn.classList.remove('animate__animated', 'animate__shakeX');
}, 1000);
});
// Auto-translate when text changes (with debounce)
let translateTimeout;
sourceTextarea.addEventListener('input', () => {
// Auto-detect RTL for source text when typing in Urdu/Arabic
const text = sourceTextarea.value;
const rtlChars = /[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/;
if (rtlChars.test(text)) {
sourceTextarea.classList.add('rtl-text');
} else {
sourceTextarea.classList.remove('rtl-text');
}
// Debounce the translation to avoid too many API calls
clearTimeout(translateTimeout);
translateTimeout = setTimeout(translateText, 500);
});
// Auto-translate when language changes
sourceLangSelect.addEventListener('change', translateText);
targetLangSelect.addEventListener('change', translateText);
// Language swap functionality with RTL handling
document.getElementById('swapLanguages').addEventListener('click', () => {
const sLangValue = sourceLangSelect.value;
const tLangValue = targetLangSelect.value;
const sourceTextValue = sourceTextarea.value;
const translatedTextValue = translatedTextarea.value;
// Swap selected languages (if source is not 'auto detect')
if (sLangValue !== 'auto') {
sourceLangSelect.value = tLangValue;
}
targetLangSelect.value = sLangValue === 'auto' ? targetLangSelect.value : sLangValue;
// Swap text only if source language was not auto-detect, or if translated text exists
if (sLangValue !== 'auto' || translatedTextValue) {
sourceTextarea.value = translatedTextValue;
// Handle RTL for swapped languages
if (sLangValue === 'ur' || sLangValue === 'ar') {
sourceTextarea.classList.add('rtl-text');
} else {
sourceTextarea.classList.remove('rtl-text');
}
// Trigger translation for the new source text
translateText();
}
// Add swap animation
const swapBtn = document.getElementById('swapLanguages');
swapBtn.classList.add('animate__animated', 'animate__rubberBand');
setTimeout(() => {
swapBtn.classList.remove('animate__animated', 'animate__rubberBand');
}, 1000);
});
// Add animation to elements when they come into view
const animateOnScroll = () => {
const elements = document.querySelectorAll('.animate__animated');
elements.forEach(el => {
const rect = el.getBoundingClientRect();
const isVisible = (rect.top <= window.innerHeight && rect.bottom >= 0);
if (isVisible) {
const animation = el.getAttribute('data-animation');
if (animation && !el.classList.contains(animation)) {
el.classList.add(animation);
}
}
});
};
// Run once on load and then on scroll
animateOnScroll();
window.addEventListener('scroll', animateOnScroll);
});
</script>
</body>
</html>
No comments:
Post a Comment
If you have any question you can ask me feelfree.