import json
import os
from ibm_watson import LanguageTranslatorV3
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from dotenv import load_dotenv

load_dotenv()

apikey = os.environ['apikey']
url = os.environ['url']
VERSION = '2018-05-01'

authenticator = IAMAuthenticator(apikey)
language_translator = LanguageTranslatorV3(version=VERSION,authenticator=authenticator)
language_translator.set_service_url(url)

def english_to_french(english_text='Hello'):
    #write the code here
    """
    This function translates french to english
    """
    french_text = language_translator.translate(
        text=english_text, model_id='en-fr'
    ).get_result()
    return french_text.get("translations")[0].get("translation")

def french_to_english(french_text='Bonjour'):
    #write the code here
    """
    This function translates french to english
    """
    english_text = language_translator.translate(
        text=french_text, model_id='fr-en'
    ).get_result()
    return english_text.get("translations")[0].get("translation")
import json
import os
from ibm_watson import LanguageTranslatorV3
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from dotenv import load_dotenv

load_dotenv()

apikey = os.environ['apikey']
url = os.environ['url']
VERSION = '2018-05-01'

authenticator = IAMAuthenticator(apikey)
language_translator = LanguageTranslatorV3(version=VERSION,authenticator=authenticator)
language_translator.set_service_url(url)

def english_to_french(english_text='Hello'):
    #write the code here
    """
    This function translates french to english
    """
    french_text = language_translator.translate(
        text=english_text, model_id='en-fr'
    ).get_result()
    return french_text.get("translations")[0].get("translation")

def french_to_english(french_text='Bonjour'):
    #write the code here
    """
    This function translates french to english
    """
    english_text = language_translator.translate(
        text=french_text, model_id='fr-en'
    ).get_result()
    return english_text.get("translations")[0].get("translation")
#write the code here This function translates french to english #write the code here This function translates french to english