This Python script allows you to translate a string of text into the language of your choice using the Google Translate service.
- Python 3.x
googletrans
library (version 4.0.0-rc1 or later)
-
Clone the repository.
-
Install the required dependencies using the following command:
pip install googletrans==4.0.0-rc1
-
Open a terminal or command prompt.
-
Navigate to the directory where the script is located.
-
Run the script using the following command:
python language_translator.py
-
Enter the text you want to translate when prompted.
-
Enter the target language code (e.g., 'fr' for French, 'es' for Spanish) when prompted. You can refer to the Google Translate language codes for a list of supported languages.
-
The script will output the translated text.
Here's an example of how to use the translation script:
Enter the text you want to translate: Hello, how are you?
Enter the target language (e.g., 'fr' for French, 'es' for Spanish): es
Translated text: ¡Hola, cómo estás?