6

पर आधारित Google लिप्यंतरण कैसे करें मैं एक तमिल भाषा आधारित वेब एप्लिकेशन कर रहा हूं। मेरे आवेदन में, मैंने उपयोगकर्ता विवरण जोड़ने के लिए गतिशील फ़ील्ड का उपयोग किया। इसलिए, गतिशील फ़ील्ड में यह सुनिश्चित करने के लिए कई कक्षाएं हैं या कक्षा के आधार पर Google लिप्यंतरण का उपयोग कैसे करें?क्लास न आईडी

<script type="text/javascript" src="http://www.google.com/jsapi"></script> 
<script type="text/javascript"> 
    // Load the Google Transliteration API 
    google.load("elements", "1", { 
    packages: "transliteration" 
    }); 

    function onLoad() { 
    var options = { 
     sourceLanguage: 'en', 
     destinationLanguage: 'ta', 
     shortcutKey: 'ctrl+m', 
     transliterationEnabled: true 
    }; 

    // Create an instance on TransliterationControl with the required 
    var control = new google.elements.transliteration.TransliterationControl(options); 

    // Enable transliteration in the textfields with the given ids. 
    var ids = ['temrorary_address', 'permanant_address', 'bankbranch', 'member_name', 'father_husband', 'workingoffice_address', ]; 
    control.makeTransliteratable(ids); 

    // Show the transliteration control which can be used to toggle between 
    // English and Hindi and also choose other destination language. 
    control.showControl('translControl'); 
    } 
    google.setOnLoadCallback(onLoad); 
</script> 

उत्तर

1

makeTransliteratable इनपुट न केवल आईडी लेकिन तत्व संदर्भ की एक सरणी के रूप में अच्छी तरह से हो सकता है। तो तुम लिख सकते हैं:

// Enable transliteration in the textfields with the given Class. 
var elements = document.getElementsByClassName('Type-Your-Class-Here'); 
control.makeTransliteratable(elements); 

लेकिन अगर आप क्षेत्रों गतिशील जोड़ रहे हैं, यह मदद नहीं करता है। फ़ील्ड के लिए गतिशील रूप से जोड़े जाने के लिए आपको हर बार नया फ़ील्ड जोड़ने पर control.makeTransliteratable पर कॉल करना होगा।

संबंधित मुद्दे