File size: 602 Bytes
03a8026
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

from utils.translators.en_ru.en_ru import translator_en_ru

translators = {"ru": translator_en_ru}


def translate_recepie(recepie, lang="en"):

    translator = translators[lang]

    data = {"title": "", "ingredients": [], "directions": []}

    data["title"] = translator(recepie["title"])

    directions = "|".join(recepie["directions"])
    data["directions"] = [x.strip() for x in translator(directions).split(',')]

    ingredients = "/".join(recepie["ingredients"])
    data["ingredients"] = [x.strip()
                           for x in translator(ingredients).split('/')]

    return data