1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
from langdetect import detect # Détecte la langue d'un texte, d'une variable string
...
# ------- Nom Recette -------
flow_Ligne1 = []
styles = getSampleStyleSheet()
stl_Recette_EU = ParagraphStyle(
name='Normal',
alignment=1,
fontName='Verdana-Bold',
fontSize=24,
textColor="#7E2300",
)
stl_Recette_TH = ParagraphStyle(
name='Normal',
alignment=1,
fontName='THSarabun-Bold',
fontSize=24,
textColor="#7E2300",
)
stl_Recette_AR = ParagraphStyle(
name='Normal',
alignment=1,
fontName='arabtype',
fontSize=24,
textColor="#7E2300",
)
# Identification de la langue utilisée pour le titre de la recette puis orientation vers la bon style
lang_Nom_Rec = detect(Nom_Rec.get()) # detect langue du titre
print("lang_Nom_Rec", lang_Nom_Rec, type(lang_Nom_Rec))
if lang_Nom_Rec == "it":
Titre_Recette = Paragraph(Nom_Rec.get(), style=stl_Recette_EU)
if lang_Nom_Rec == "th":
Titre_Recette = Paragraph(Nom_Rec.get(), style=stl_Recette_TH)
if lang_Nom_Rec == "ar":
Titre_Recette = Paragraph(Nom_Rec.get(), style=stl_Recette_AR)
flow_Ligne1.append(Titre_Recette) |
Partager