![]() |
|
![]() |
|
|||||||
| Vintage Test Gear and Workshop Equipment For discussions about vintage test gear and workshop equipment such as coil winders. |
|
|
Thread Tools |
if == ' main ': app.run(debug=True, host='0.0.0.0', port=5000) Option 3: Python Script for Jawi-Rumi Conversion (Custom Rules) import re class JawiToRumiConverter: """ Custom Jawi to Rumi converter with common rules """
@app.route('/translate', methods=['POST']) def translate_jawi_to_rumi(): """ API endpoint to translate Jawi to Rumi """ try: data = request.get_json()
if (!inputText) { errorDiv.textContent = 'Please enter some Jawi text to translate.'; errorDiv.style.display = 'block'; return; } google translate jawi kepada rumi
// Hide previous error and show loading errorDiv.style.display = 'none'; loadingDiv.style.display = 'block'; outputDiv.textContent = '';
if not data or 'text' not in data: return jsonify({ 'error': 'No text provided', 'success': False }), 400 text = data['text'] # Detect language and translate # Jawi uses Arabic script (ms-Arab), Rumi uses Latin (ms-Latn) translation = translator.translate( text, src='ms', # Malay dest='ms' # Malay (same language, different script) ) # Alternative: Force script conversion # For more accurate Jawi to Rumi conversion, you might need # to specify source language as 'ms-Arab' but googletrans may not support it result = { 'original': text, 'translated': translation.text, 'source_lang': translation.src, 'target_lang': translation.dest, 'success': True } logger.info(f"Translated: {text[:50]}... -> {translation.text[:50]}...") return jsonify(result), 200 except Exception as e: logger.error(f"Translation error: {str(e)}") return jsonify({ 'error': str(e), 'success': False }), 500 @app.route('/batch-translate', methods=['POST']) def batch_translate(): """ Batch translation endpoint for multiple texts """ try: data = request.get_json() if == ' main ': app
jawi_text = "سلامت datang کأ لومبور" result = translator.translate_jawi_to_rumi(jawi_text)
function updateCharCount() { const count = document.getElementById('inputText').value.length; document.getElementById('charCount').textContent = count; } if == ' main ': app.run(debug=True
for jawi in test_texts: rumi = converter.convert(jawi) print(f"Jawi: {jawi}") print(f"Rumi: {rumi}") print("-" * 30) # requirements.txt # google-cloud-translate==3.11.0 from google.cloud import translate_v2 as translate import os