Developer Documentation
Getting Started
Welcome to the developer documentation for integrating Written Translator into your website. This guide will help you get started with adding the necessary script and calling the function to begin translations.
Overview
1. Sign Up
To use Written Translator, an api key is required. This api key will be associated to your account at signup.
Visit the Account Page to find your api key.
2. Adding the Script to Your Website
To use the WTStartTranslation
function, you need to include the script in your HTML file. Follow these steps:
- Add the following script tag to your html headers
<script src="future/written-translator-package.js" accountKey="[API_KEY]"></script>
Replace [API_KEY]
with your account's API Key from step 1.
3. Calling the WTStartTranslation Function
Once the script is included in your HTML file, you can call the WTStartTranslation
function to start the translation process. The function takes two parameters: sourceLanguage
and targetLanguage
.
For single-page applications and dynamic content, call WTStartTranslation(s, t)
AFTER content has rendered.
Function Signature
window.WTStartTranslation(sourceLanguage, targetLanguage);
sourceLanguage
: The language code of the source language (e.g., 'en' for English).
targetLanguage
: The language code of the target language (e.g., 'es' for Spanish).
4. Example Usage
Here is an example of how to call the WTStartTranslation
function:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Translation Example</title>
<script src="path/to/your/script.js"></script>
<script>
function startTranslation() {
const sourceLanguage = 'en';
const targetLanguage = 'es';
window.WTStartTranslation(sourceLanguage, targetLanguage);
}
</script>
</head>
<body>
<h1>Welcome to Our Website</h1>
<p>This is an example paragraph that will be translated.</p>
</body>
</html>
In this example:
- The script is included in the
<head>
section. - A button is provided to start the translation when clicked.
- The
startTranslation
function callswindow.WTStartTranslation
with 'en' as the source language and 'es' as the target language.
5. Troubleshooting
If you encounter any issues, consider the following troubleshooting steps:
- Ensure the path to
script.js
is correct. - Verify that the
WTStartTranslation
function is defined inscript.js
. - Check for any JavaScript errors in the browser console.
For further assistance, please refer to the detailed documentation or contact support.
This concludes the getting started guide for integrating the WTStartTranslation
function into your website. Happy translating!