<reponame>Bodhi1/xzceb-flask_eng_fr
"""
This function translate from English to French and vice versa
"""
import os
import json
from dotenv import load_dotenv
from ibm_watson import LanguageTranslatorV3
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

load_dotenv()

APIKEY = os.environ['apikey']
URL = os.environ['url']

AUTHENTICATOR = IAMAuthenticator(APIKEY)
language_translator = LanguageTranslatorV3(
    version = '2018-05-01',
    authenticator = AUTHENTICATOR
)

language_translator.set_service_url(URL)

def english_to_french(english_text):
    """
    translate from English to French
    """
    translation = language_translator.translate(
        text = english_text,
        model_id = 'en-fr').get_result()

    french_text = translation['translations'][0]['translation']

    return french_text

def french_to_english(french_text):
    """
    translate from French to English
    """
    translation = language_translator.translate(
        text = french_text,
        model_id = 'fr-en').get_result()

    english_text = translation['translations'][0]['translation']

    return english_text

"""
This function translate from English to French and vice versa
"""
import os
import json
from dotenv import load_dotenv
from ibm_watson import LanguageTranslatorV3
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

load_dotenv()

APIKEY = os.environ['apikey']
URL = os.environ['url']

AUTHENTICATOR = IAMAuthenticator(APIKEY)
language_translator = LanguageTranslatorV3(
    version = '2018-05-01',
    authenticator = AUTHENTICATOR
)

language_translator.set_service_url(URL)

def english_to_french(english_text):
    """
    translate from English to French
    """
    translation = language_translator.translate(
        text = english_text,
        model_id = 'en-fr').get_result()

    french_text = translation['translations'][0]['translation']

    return french_text

def french_to_english(french_text):
    """
    translate from French to English
    """
    translation = language_translator.translate(
        text = french_text,
        model_id = 'fr-en').get_result()

    english_text = translation['translations'][0]['translation']

    return english_text
This function translate from English to French and vice versa translate from English to French translate from French to English