Text Translator API (UTK):
The TextTranslatorAPI_UTK node is a versatile tool designed to facilitate text translation across multiple languages using various translation service providers. It supports both free and paid APIs, including Google Translate, LibreTranslate, MyMemory, DeepL, Azure Translator, and GLM-4 Flash, among others. This node is particularly beneficial for users who require seamless translation capabilities within their workflows, offering an automatic mode that prioritizes free APIs and switches to alternatives if a service fails. It enhances user experience by supporting native language names and intelligently detecting whether an API key is required for a given service. Additionally, the node provides detailed logging for debugging and error handling, ensuring smooth operation even in the face of network or API failures. Its ability to handle batch translations and list inputs makes it a powerful tool for managing large-scale translation tasks efficiently.
Text Translator API (UTK) Input Parameters:
text
The text parameter is the string of text that you wish to translate. It serves as the primary input for the translation process. The content of this parameter directly impacts the translation output, as it determines what will be translated into the target language. There are no specific minimum or maximum values for this parameter, but it should be a valid string that the translation service can process.
target_lang
The target_lang parameter specifies the language code of the language into which you want the text to be translated. This parameter is crucial as it directs the translation service to produce the output in the desired language. The language code should be a valid ISO 639-1 code, such as "en" for English or "fr" for French. There are no default values, so you must specify this parameter for each translation request.
source_lang
The source_lang parameter indicates the language code of the original text. By default, it is set to "auto," allowing the translation service to automatically detect the source language. However, specifying this parameter can improve translation accuracy, especially when dealing with languages that might be easily confused. Like target_lang, this should be a valid ISO 639-1 code.
api_key
The api_key parameter is used to provide the necessary authentication credentials for accessing certain translation services that require it. Not all services need an API key, but for those that do, this parameter is essential for successful translation. If an API key is required and not provided, the translation request will fail. There is no default value, and it should be a valid key obtained from the service provider.
Text Translator API (UTK) Output Parameters:
translated_text
The translated_text parameter contains the result of the translation process. It is the text translated into the target language specified by the target_lang parameter. This output is crucial as it provides the user with the desired translation, allowing them to utilize the translated content in their projects or workflows.
provider_name
The provider_name parameter indicates the name of the translation service provider used for the translation. This information is useful for tracking which service was utilized, especially when multiple providers are available. It helps in understanding the source of the translation and can be used for debugging or optimizing future translation requests.
status_message
The status_message parameter provides a summary of the translation process, indicating whether it was successful or if there were any errors. This output is important for users to quickly assess the outcome of their translation request and take appropriate action if needed. It includes success messages or detailed error descriptions to aid in troubleshooting.
Text Translator API (UTK) Usage Tips:
- Ensure that you have a valid API key for services that require authentication to avoid translation failures.
- Use the automatic source language detection feature by setting
source_langto "auto" for convenience, but specify the source language when accuracy is critical. - Take advantage of the detailed logging provided by the node to troubleshoot any issues that arise during the translation process.
- Consider using batch translation capabilities for handling large volumes of text efficiently, reducing the need for multiple individual requests.
Text Translator API (UTK) Common Errors and Solutions:
Error: {provider} requires an API key but none provided
- Explanation: This error occurs when a translation service that requires an API key is selected, but no key is provided.
- Solution: Obtain a valid API key from the service provider and include it in the
api_keyparameter.
Error: Translation failed with {provider}: {result}
- Explanation: This error indicates that the translation request was unsuccessful, possibly due to network issues or incorrect parameters.
- Solution: Check the network connection and ensure that all input parameters are correctly specified. Review the detailed error message for specific guidance.
Error: Azure Translator error: {str(e)}
- Explanation: This error suggests that an exception occurred while using the Azure Translator service, potentially due to incorrect API usage or service unavailability.
- Solution: Verify the API key and parameters, and consult Azure's documentation for any service-specific requirements or limitations.
