Friday, 14 July 2023

language translate Ai

The HTML structure consists of a title, a heading displaying "Language Translator Tool," and a container element to hold the main components. The container includes two textareas: one for inputting the text to be translated (source) and another to display the translated text (target). Below the textareas, there is a div with two buttons - "Translate" and "Clear" - to initiate the translation and clear the text, respectively. The JavaScript code handles the button click events and performs the translation process.

To style the application, the CSS file style.css is linked to the HTML file. The body element has centered text alignment and uses the Arial font. The heading (h1) has a color of #333. The container element is centered on the page with a maximum width of 400px and a margin of 20px from the top. Both the source and target textareas have a width of 100%, a height of 200px, padding, and a border. The buttons are styled with a green background color, white text, and a hover effect. The target textarea has a bold font weight to emphasize the translated text.

The JavaScript code adds event listeners to the "Translate" and "Clear" buttons. When the "Translate" button is clicked, it retrieves the text from the source textarea and makes an API request to the MyMemory translation service. The source text is encoded and passed as a query parameter in the request URL along with the desired language pair (auto-detection to English). The response is processed, and if a translation is available, it is displayed in the target textarea. In case of any errors or failed translations, appropriate error messages are shown. The "Clear" button simply resets the text in both textareas.

Overall, this language translator tool provides a user-friendly interface, vibrant styling, and seamless translation functionality using the MyMemory translation service without the need for an API key


<!DOCTYPE html>
<html>
<head>
    <title>Language Translator Tool</title>
    <link rel="stylesheet" type="text/css" href="body {
    font-family: Arial, sans-serif;
    text-align: center;
}

h1 {
    color: #333;
}

.container {
    margin: 20px auto;
    max-width: 400px;
}

textarea {
    width: 100%;
    height: 200px;
    padding: 10px;
    box-sizing: border-box;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    resize: none;
}

#buttons {
    margin-bottom: 10px;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin-right: 10px;
    cursor: pointer;
}

button:hover {
    background-color: #45a049;
}

#target {
    font-weight: bold;
    color: #333;
}
">
</head>
<body>
    <h1>Language Translator Tool</h1>
    <div class="container">
        <textarea id="source" placeholder="Enter text to translate"></textarea>
        <div id="buttons">
            <button id="translateButton">Translate</button>
            <button id="clearButton">Clear</button>
        </div>
        <textarea id="target" placeholder="Translation will appear here" readonly></textarea>
    </div>

    <script src="<!DOCTYPE html>
<html>
<head>
    <title>Screen Recorder Tool</title>
    <link rel="stylesheet" type="text/css" href="let recorder;
let stream;

document.getElementById('startButton').addEventListener('click', startRecording);
document.getElementById('stopButton').addEventListener('click', stopRecording);

function startRecording() {
    navigator.mediaDevices.getUserMedia({ video: true, audio: true })
        .then(function (mediaStream) {
            stream = mediaStream;
            const videoElement = document.getElementById('recordedVideo');
            videoElement.srcObject = mediaStream;
            videoElement.play();

            recorder = new RecordRTC(mediaStream, {
                type: 'video'
            });
            recorder.startRecording();
        })
        .catch(function (error) {
            console.error('Error accessing media devices:', error);
        });
}

function stopRecording() {
    if (recorder) {
        recorder.stopRecording(function () {
            stream.getTracks().forEach(function (track) {
                track.stop();
            });

            const blob = recorder.getBlob();
            const videoURL = URL.createObjectURL(blob);

            const videoElement = document.getElementById('recordedVideo');
            videoElement.src = videoURL;
            videoElement.controls = true;
        });
    }
}
">
</head>
<body>
    <h1>Screen Recorder Tool</h1>
    <div class="container">
        <video id="recordedVideo" controls></video>
        <div id="buttons">
            <button id="startButton">Start Recording</button>
            <button id="stopButton">Stop Recording</button>
        </div>
    </div>

    <script src="https://cdn.webrtc-experiment.com/RecordRTC.js"></script>
    <script src="body {
    font-family: Arial, sans-serif;
    text-align: center;
}

h1 {
    color: #333;
}

.container {
    margin: 20px auto;
    max-width: 400px;
}

video {
    width: 100%;
    height: auto;
    margin-bottom: 10px;
}

#buttons {
    margin-bottom: 10px;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin-right: 10px;
    cursor: pointer;
}

button:hover {
    background-color: #45a049;
}
"></script>
</body>
</html>
"></script>
</body>
</html>

No comments:

Post a Comment

configuration of website

Menu Type: Dropdown with Full Width Ensure the navigation items in the dropdown menu contain relevant keywords related to the we...