| <!DOCTYPE html> |
| <html lang="en" dir="ltr"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Advanced Pinglish ↔ Persian Converter</title> |
| <style> |
| * { |
| margin: 0; |
| padding: 0; |
| box-sizing: border-box; |
| } |
| |
| body { |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| min-height: 100vh; |
| padding: 20px; |
| } |
| |
| .container { |
| max-width: 1200px; |
| margin: 0 auto; |
| background: rgba(255, 255, 255, 0.95); |
| border-radius: 20px; |
| padding: 30px; |
| box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1); |
| backdrop-filter: blur(10px); |
| } |
| |
| .header { |
| text-align: center; |
| margin-bottom: 30px; |
| } |
| |
| .header h1 { |
| color: #2d3748; |
| font-size: 2.5rem; |
| margin-bottom: 10px; |
| background: linear-gradient(45deg, #667eea, #764ba2); |
| -webkit-background-clip: text; |
| -webkit-text-fill-color: transparent; |
| background-clip: text; |
| } |
| |
| .header p { |
| color: #718096; |
| font-size: 1.1rem; |
| } |
| |
| .converter-section { |
| display: grid; |
| grid-template-columns: 1fr auto 1fr; |
| gap: 20px; |
| align-items: center; |
| margin-bottom: 30px; |
| } |
| |
| .input-section, .output-section { |
| background: #f7fafc; |
| border-radius: 15px; |
| padding: 20px; |
| border: 2px solid #e2e8f0; |
| transition: all 0.3s ease; |
| } |
| |
| .input-section:focus-within, .output-section:focus-within { |
| border-color: #667eea; |
| box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); |
| } |
| |
| .section-title { |
| font-weight: 600; |
| color: #2d3748; |
| margin-bottom: 10px; |
| font-size: 1.1rem; |
| } |
| |
| textarea { |
| width: 100%; |
| height: 150px; |
| border: none; |
| background: transparent; |
| resize: vertical; |
| font-size: 16px; |
| font-family: inherit; |
| outline: none; |
| color: #2d3748; |
| line-height: 1.5; |
| } |
| |
| .persian-text { |
| direction: rtl; |
| text-align: right; |
| font-family: 'B Nazanin', 'Tahoma', serif; |
| font-size: 18px; |
| } |
| |
| .swap-button { |
| background: linear-gradient(45deg, #667eea, #764ba2); |
| border: none; |
| border-radius: 50%; |
| width: 60px; |
| height: 60px; |
| color: white; |
| font-size: 24px; |
| cursor: pointer; |
| transition: all 0.3s ease; |
| box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); |
| } |
| |
| .swap-button:hover { |
| transform: rotate(180deg) scale(1.1); |
| box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); |
| } |
| |
| .controls { |
| display: flex; |
| justify-content: center; |
| gap: 15px; |
| margin-bottom: 20px; |
| flex-wrap: wrap; |
| } |
| |
| .btn { |
| padding: 12px 24px; |
| border: none; |
| border-radius: 10px; |
| font-weight: 600; |
| cursor: pointer; |
| transition: all 0.3s ease; |
| font-size: 14px; |
| } |
| |
| .btn-primary { |
| background: linear-gradient(45deg, #667eea, #764ba2); |
| color: white; |
| } |
| |
| .btn-secondary { |
| background: #e2e8f0; |
| color: #4a5568; |
| } |
| |
| .btn:hover { |
| transform: translateY(-2px); |
| box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); |
| } |
| |
| .examples { |
| background: #f0fff4; |
| border-radius: 15px; |
| padding: 20px; |
| margin-top: 20px; |
| border-left: 4px solid #48bb78; |
| } |
| |
| .examples h3 { |
| color: #2d3748; |
| margin-bottom: 15px; |
| font-size: 1.2rem; |
| } |
| |
| .example-item { |
| display: grid; |
| grid-template-columns: 1fr auto 1fr; |
| gap: 15px; |
| margin-bottom: 10px; |
| padding: 10px; |
| background: white; |
| border-radius: 8px; |
| cursor: pointer; |
| transition: all 0.2s ease; |
| } |
| |
| .example-item:hover { |
| background: #f7fafc; |
| transform: translateY(-1px); |
| } |
| |
| .example-pinglish { |
| color: #2b6cb0; |
| font-family: monospace; |
| } |
| |
| .example-persian { |
| color: #2d3748; |
| direction: rtl; |
| text-align: right; |
| font-family: 'B Nazanin', 'Tahoma', serif; |
| font-size: 16px; |
| } |
| |
| .arrow { |
| color: #718096; |
| text-align: center; |
| } |
| |
| .stats { |
| display: flex; |
| justify-content: space-around; |
| margin-top: 20px; |
| text-align: center; |
| } |
| |
| .stat { |
| background: rgba(102, 126, 234, 0.1); |
| padding: 15px; |
| border-radius: 10px; |
| flex: 1; |
| margin: 0 5px; |
| } |
| |
| .stat-number { |
| font-size: 1.5rem; |
| font-weight: bold; |
| color: #667eea; |
| } |
| |
| .stat-label { |
| color: #718096; |
| font-size: 0.9rem; |
| } |
| |
| .accuracy-info { |
| background: #fff3cd; |
| border: 1px solid #ffeeba; |
| border-radius: 10px; |
| padding: 15px; |
| margin-bottom: 20px; |
| color: #856404; |
| } |
| |
| @media (max-width: 768px) { |
| .converter-section { |
| grid-template-columns: 1fr; |
| gap: 15px; |
| } |
| |
| .swap-button { |
| width: 50px; |
| height: 50px; |
| font-size: 20px; |
| justify-self: center; |
| } |
| |
| .header h1 { |
| font-size: 2rem; |
| } |
| |
| .example-item { |
| grid-template-columns: 1fr; |
| gap: 5px; |
| text-align: center; |
| } |
| |
| .stats { |
| flex-direction: column; |
| gap: 10px; |
| } |
| } |
| </style> |
| </head> |
| <body> |
| <div class="container"> |
| <div class="header"> |
| <h1>Advanced Pinglish ↔ Persian Converter</h1> |
| <p>Accurate conversion using Persian linguistics and common patterns</p> |
| </div> |
|
|
| <div class="accuracy-info"> |
| <strong>🎯 Enhanced Accuracy:</strong> This converter uses advanced Persian language patterns, context-aware rules, and a comprehensive word dictionary for more accurate results. |
| </div> |
|
|
| <div class="converter-section"> |
| <div class="input-section"> |
| <div class="section-title" id="input-title">Pinglish Input</div> |
| <textarea |
| id="input-text" |
| placeholder="Type your Pinglish text here... (e.g., salam doostam chetori?)" |
| oninput="convertText()" |
| ></textarea> |
| </div> |
|
|
| <button class="swap-button" onclick="swapLanguages()" title="Swap languages"> |
| ⇄ |
| </button> |
|
|
| <div class="output-section"> |
| <div class="section-title" id="output-title">Persian Output</div> |
| <textarea |
| id="output-text" |
| class="persian-text" |
| placeholder="Your converted text will appear here..." |
| readonly |
| ></textarea> |
| </div> |
| </div> |
|
|
| <div class="controls"> |
| <button class="btn btn-primary" onclick="copyToClipboard()">📋 Copy Result</button> |
| <button class="btn btn-secondary" onclick="clearAll()">🗑️ Clear All</button> |
| <button class="btn btn-secondary" onclick="downloadText()">💾 Download</button> |
| </div> |
|
|
| <div class="stats"> |
| <div class="stat"> |
| <div class="stat-number" id="char-count">0</div> |
| <div class="stat-label">Characters</div> |
| </div> |
| <div class="stat"> |
| <div class="stat-number" id="word-count">0</div> |
| <div class="stat-label">Words</div> |
| </div> |
| <div class="stat"> |
| <div class="stat-number" id="conversion-mode">Smart</div> |
| <div class="stat-label">Mode</div> |
| </div> |
| </div> |
|
|
| <div class="examples"> |
| <h3>💡 Example Conversions (Click to try)</h3> |
| <div class="example-item" onclick="setExample('salam doostam chetori?', 'سلام دوستم چطوری؟')"> |
| <div class="example-pinglish">salam doostam chetori?</div> |
| <div class="arrow">→</div> |
| <div class="example-persian">سلام دوستم چطوری؟</div> |
| </div> |
| <div class="example-item" onclick="setExample('man irani hastam va farsi harf mizanam', 'من ایرانی هستم و فارسی حرف میزنم')"> |
| <div class="example-pinglish">man irani hastam va farsi harf mizanam</div> |
| <div class="arrow">→</div> |
| <div class="example-persian">من ایرانی هستم و فارسی حرف میزنم</div> |
| </div> |
| <div class="example-item" onclick="setExample('khosh amadid be khaneh man', 'خوش آمدید به خانه من')"> |
| <div class="example-pinglish">khosh amadid be khaneh man</div> |
| <div class="arrow">→</div> |
| <div class="example-persian">خوش آمدید به خانه من</div> |
| </div> |
| <div class="example-item" onclick="setExample('emrooz havaye tehran che jorieh?', 'امروز هوای تهران چه جوریه؟')"> |
| <div class="example-pinglish">emrooz havaye tehran che jorieh?</div> |
| <div class="arrow">→</div> |
| <div class="example-persian">امروز هوای تهران چه جوریه؟</div> |
| </div> |
| <div class="example-item" onclick="setExample('kheyli mamnoon az shoma', 'خیلی ممنون از شما')"> |
| <div class="example-pinglish">kheyli mamnoon az shoma</div> |
| <div class="arrow">→</div> |
| <div class="example-persian">خیلی ممنون از شما</div> |
| </div> |
| </div> |
| </div> |
|
|
| <script> |
| |
| const persianDictionary = { |
| |
| 'salam': 'سلام', |
| 'doostam': 'دوستم', |
| 'doost': 'دوست', |
| 'chetori': 'چطوری', |
| 'chetor': 'چطور', |
| 'khoobi': 'خوبی', |
| 'khoob': 'خوب', |
| 'bad': 'بد', |
| 'mamnoon': 'ممنون', |
| 'merci': 'مرسی', |
| 'tashakor': 'تشکر', |
| 'khahesh': 'خواهش', |
| 'bebakhshid': 'ببخشید', |
| 'ozr': 'عذر', |
| |
| |
| 'man': 'من', |
| 'to': 'تو', |
| 'shoma': 'شما', |
| 'oo': 'او', |
| 'un': 'اون', |
| 'ma': 'ما', |
| 'anha': 'آنها', |
| 'unha': 'اونها', |
| |
| |
| 'hastam': 'هستم', |
| 'hasti': 'هستی', |
| 'hastid': 'هستید', |
| 'hast': 'هست', |
| 'hastand': 'هستند', |
| 'mizanam': 'میزنم', |
| 'mizani': 'میزنی', |
| 'mizanad': 'میزند', |
| 'mizanim': 'میزنیم', |
| 'mizanid': 'میزنید', |
| 'mizanand': 'میزنند', |
| 'miram': 'میرم', |
| 'miri': 'میری', |
| 'mirad': 'میرود', |
| 'mirim': 'میریم', |
| 'mirid': 'میرید', |
| 'mirand': 'میروند', |
| 'mikham': 'میخوام', |
| 'mikhi': 'میخوای', |
| 'mikhad': 'میخواد', |
| 'mikhahim': 'میخواهیم', |
| 'mikhahid': 'میخواهید', |
| 'mikhahand': 'میخواهند', |
| 'daram': 'دارم', |
| 'dari': 'داری', |
| 'darad': 'دارد', |
| 'darim': 'داریم', |
| 'darid': 'دارید', |
| 'darand': 'دارند', |
| |
| |
| 'kheyli': 'خیلی', |
| 'besyar': 'بسیار', |
| 'kam': 'کم', |
| 'ziad': 'زیاد', |
| 'bozorg': 'بزرگ', |
| 'kochak': 'کوچک', |
| 'jadid': 'جدید', |
| 'ghadimi': 'قدیمی', |
| 'ziba': 'زیبا', |
| 'zesht': 'زشت', |
| 'sard': 'سرد', |
| 'garm': 'گرم', |
| 'khoshgel': 'خوشگل', |
| |
| |
| 'iran': 'ایران', |
| 'tehran': 'تهران', |
| 'isfahan': 'اصفهان', |
| 'shiraz': 'شیراز', |
| 'mashhad': 'مشهد', |
| 'tabriz': 'تبریز', |
| 'khaneh': 'خانه', |
| 'madreseh': 'مدرسه', |
| 'daneshgah': 'دانشگاه', |
| 'bazar': 'بازار', |
| 'park': 'پارک', |
| 'cinema': 'سینما', |
| 'restaurant': 'رستوران', |
| |
| |
| 'emrooz': 'امروز', |
| 'diruz': 'دیروز', |
| 'farda': 'فردا', |
| 'hala': 'حالا', |
| 'alan': 'الان', |
| 'vaght': 'وقت', |
| 'saat': 'ساعت', |
| 'rooz': 'روز', |
| 'mah': 'ماه', |
| 'sal': 'سال', |
| 'sobh': 'صبح', |
| 'zohr': 'ظهر', |
| 'asr': 'عصر', |
| 'shab': 'شب', |
| |
| |
| 'farsi': 'فارسی', |
| 'inglisi': 'انگلیسی', |
| 'zaban': 'زبان', |
| 'harf': 'حرف', |
| 'kelam': 'کلام', |
| 'ketab': 'کتاب', |
| 'film': 'فیلم', |
| 'musiqi': 'موسیقی', |
| 'aks': 'عکس', |
| 'dokhtaar': 'دختر', |
| 'pesar': 'پسر', |
| 'mard': 'مرد', |
| 'zan': 'زن', |
| 'pedar': 'پدر', |
| 'madar': 'مادر', |
| 'baradar': 'برادر', |
| 'khahar': 'خواهر', |
| 'aziz': 'عزیز', |
| 'jan': 'جان', |
| |
| |
| 'va': 'و', |
| 'ya': 'یا', |
| 'be': 'به', |
| 'az': 'از', |
| 'ba': 'با', |
| 'dar': 'در', |
| 'bar': 'بر', |
| 'ta': 'تا', |
| 'che': 'چه', |
| 'agar': 'اگر', |
| 'vali': 'ولی', |
| 'pas': 'پس', |
| 'yani': 'یعنی', |
| |
| |
| 'khosh': 'خوش', |
| 'amadid': 'آمدید', |
| 'befarmayid': 'بفرمایید', |
| 'lotfan': 'لطفاً', |
| 'hatman': 'حتماً', |
| 'albateh': 'البته', |
| 'shayad': 'شاید', |
| 'hargez': 'هرگز', |
| 'hamisheh': 'همیشه', |
| 'baziha': 'بعضیها', |
| 'hameh': 'همه', |
| 'hich': 'هیچ', |
| 'kasi': 'کسی', |
| 'chizi': 'چیزی', |
| 'jaii': 'جایی', |
| 'khodet': 'خودت', |
| 'khodam': 'خودم', |
| 'khoda': 'خدا', |
| 'hafez': 'حافظ', |
| 'ferdowsi': 'فردوسی', |
| 'saadi': 'سعدی', |
| 'rumi': 'رومی', |
| |
| |
| 'hava': 'هوا', |
| 'havaye': 'هوای', |
| 'aftab': 'آفتاب', |
| 'mah': 'ماه', |
| 'setareh': 'ستاره', |
| 'baran': 'باران', |
| 'barf': 'برف', |
| 'bad': 'باد', |
| 'darya': 'دریا', |
| 'koh': 'کوه', |
| 'jangal': 'جنگل', |
| 'gol': 'گل', |
| 'derakht': 'درخت', |
| |
| |
| 'ghaza': 'غذا', |
| 'ab': 'آب', |
| 'chai': 'چای', |
| 'ghahveh': 'قهوه', |
| 'shir': 'شیر', |
| 'noon': 'نون', |
| 'berenj': 'برنج', |
| 'gosht': 'گوشت', |
| 'morgh': 'مرغ', |
| 'mahi': 'ماهی', |
| 'sabzi': 'سبزی', |
| 'miveh': 'میوه', |
| 'sib': 'سیب', |
| 'porteghal': 'پرتقال', |
| 'angoor': 'انگور', |
| 'hendevaneh': 'هندوانه', |
| |
| |
| 'chi': 'چی', |
| 'chera': 'چرا', |
| 'chetor': 'چطور', |
| 'key': 'کی', |
| 'koja': 'کجا', |
| 'kodum': 'کدوم', |
| 'chand': 'چند', |
| 'kam': 'کم', |
| 'jorieh': 'جوریه', |
| 'jori': 'جوری' |
| }; |
| |
| |
| const characterMap = { |
| |
| 'b': 'ب', 'p': 'پ', 't': 'ت', 's': 'س', 'j': 'ج', |
| 'd': 'د', 'z': 'ز', 'r': 'ر', 'f': 'ف', 'k': 'ک', |
| 'g': 'گ', 'l': 'ل', 'm': 'م', 'n': 'ن', 'h': 'ه', |
| 'y': 'ی', 'v': 'و', 'w': 'و', |
| |
| |
| 'kh': 'خ', 'gh': 'غ', 'ch': 'چ', 'sh': 'ش', 'zh': 'ژ', |
| 'th': 'ث', 'dh': 'ذ', 'ss': 'ص', 'dd': 'ض', 'tt': 'ط', |
| 'zz': 'ظ', 'aa': 'آ', |
| |
| |
| 'a': 'ا', 'e': 'ه', 'i': 'ی', 'o': 'و', 'u': 'و', |
| "'": 'ع', 'q': 'ق', 'x': 'کس' |
| }; |
| |
| |
| const persianToRoman = {}; |
| Object.keys(persianDictionary).forEach(key => { |
| persianToRoman[persianDictionary[key]] = key; |
| }); |
| |
| let isPinglishToPersian = true; |
| |
| function convertText() { |
| const input = document.getElementById('input-text').value; |
| const output = document.getElementById('output-text'); |
| |
| if (isPinglishToPersian) { |
| output.value = convertPinglishToPersian(input); |
| output.className = 'persian-text'; |
| } else { |
| output.value = convertPersianToPinglish(input); |
| output.className = ''; |
| } |
| |
| updateStats(input, output.value); |
| } |
| |
| function convertPinglishToPersian(text) { |
| if (!text) return ''; |
| |
| |
| let result = text.toLowerCase().trim(); |
| |
| |
| const words = result.split(/(\s+|[.!?،؟])/); |
| |
| const convertedWords = words.map(word => { |
| |
| if (/^\s+$/.test(word) || /^[.!?،؟]+$/.test(word)) { |
| return word === '?' ? '؟' : word === ',' ? '،' : word; |
| } |
| |
| |
| const cleanWord = word.replace(/[.!?،؟]/g, ''); |
| |
| |
| if (persianDictionary[cleanWord]) { |
| return persianDictionary[cleanWord]; |
| } |
| |
| |
| return convertCharacterByCharacter(cleanWord); |
| }); |
| |
| return convertedWords.join('').replace(/\s+/g, ' ').trim(); |
| } |
| |
| function convertCharacterByCharacter(word) { |
| let result = ''; |
| let i = 0; |
| |
| while (i < word.length) { |
| let found = false; |
| |
| |
| if (i < word.length - 1) { |
| const digraph = word.substr(i, 2); |
| if (characterMap[digraph]) { |
| result += characterMap[digraph]; |
| i += 2; |
| found = true; |
| } |
| } |
| |
| |
| if (!found) { |
| const char = word[i]; |
| if (characterMap[char]) { |
| result += characterMap[char]; |
| } else { |
| result += char; |
| } |
| i++; |
| } |
| } |
| |
| return result; |
| } |
| |
| function convertPersianToPinglish(text) { |
| if (!text) return ''; |
| |
| |
| const words = text.split(/(\s+|[.!?،؟])/); |
| |
| const convertedWords = words.map(word => { |
| |
| if (word === '؟') return '?'; |
| if (word === '،') return ','; |
| if (/^\s+$/.test(word) || /^[.!?،؟]+$/.test(word)) { |
| return word; |
| } |
| |
| |
| const cleanWord = word.replace(/[.!?،؟]/g, ''); |
| |
| |
| if (persianToRoman[cleanWord]) { |
| return persianToRoman[cleanWord]; |
| } |
| |
| |
| return cleanWord.split('').map(char => { |
| |
| for (const [roman, persian] of Object.entries(characterMap)) { |
| if (persian === char) { |
| return roman; |
| } |
| } |
| return char; |
| }).join(''); |
| }); |
| |
| return convertedWords.join('').replace(/\s+/g, ' ').trim(); |
| } |
| |
| function swapLanguages() { |
| isPinglishToPersian = !isPinglishToPersian; |
| |
| const inputTitle = document.getElementById('input-title'); |
| const outputTitle = document.getElementById('output-title'); |
| const inputText = document.getElementById('input-text'); |
| const outputText = document.getElementById('output-text'); |
| |
| if (isPinglishToPersian) { |
| inputTitle.textContent = 'Pinglish Input'; |
| outputTitle.textContent = 'Persian Output'; |
| inputText.placeholder = 'Type your Pinglish text here... (e.g., salam doostam chetori?)'; |
| inputText.className = ''; |
| outputText.className = 'persian-text'; |
| } else { |
| inputTitle.textContent = 'Persian Input'; |
| outputTitle.textContent = 'Pinglish Output'; |
| inputText.placeholder = 'متن فارسی خود را اینجا تایپ کنید...'; |
| inputText.className = 'persian-text'; |
| outputText.className = ''; |
| } |
| |
| |
| const temp = inputText.value; |
| inputText.value = outputText.value; |
| outputText.value = temp; |
| |
| convertText(); |
| } |
| |
| function updateStats(input, output) { |
| document.getElementById('char-count').textContent = input.length; |
| document.getElementById('word-count').textContent = input.trim() ? input.trim().split(/\s+/).length : 0; |
| } |
| |
| function setExample(pinglish, persian) { |
| const inputText = document.getElementById('input-text'); |
| if (isPinglishToPersian) { |
| inputText.value = pinglish; |
| } else { |
| inputText.value = persian; |
| } |
| convertText(); |
| } |
| |
| function copyToClipboard() { |
| const output = document.getElementById('output-text'); |
| output.select(); |
| document.execCommand('copy'); |
| |
| |
| const btn = event.target; |
| const originalText = btn.textContent; |
| btn.textContent = '✅ Copied!'; |
| btn.style.background = '#48bb78'; |
| setTimeout(() => { |
| btn.textContent = originalText; |
| btn.style.background = ''; |
| }, 2000); |
| } |
| |
| function clearAll() { |
| document.getElementById('input-text').value = ''; |
| document.getElementById('output-text').value = ''; |
| updateStats('', ''); |
| } |
| |
| function downloadText() { |
| const output = document.getElementById('output-text').value; |
| if (!output) return; |
| |
| const blob = new Blob([output], { type: 'text/plain;charset=utf-8' }); |
| const url = URL.createObjectURL(blob); |
| const a = document.createElement('a'); |
| a.href = url; |
| a.download = isPinglishToPersian ? 'persian_text.txt' : 'pinglish_text.txt'; |
| document.body.appendChild(a); |
| a.click(); |
| document.body.removeChild(a); |
| URL.revokeObjectURL(url); |
| } |
| |
| |
| convertText(); |
| </script> |
| </body> |
| </html> |