fix(frontend): Arabic language support

This commit is contained in:
TheOnlyWayUp
2024-06-30 20:09:07 +00:00
parent 79c9447cbe
commit 9f24d437cb
+4 -4
View File
@@ -174,7 +174,7 @@ async def add_chapters(
): ):
chapters = [] chapters = []
for part in data["parts"]: for cidx, part in enumerate(data["parts"]):
content = await fetch_part_content(part["id"], cookies=cookies) content = await fetch_part_content(part["id"], cookies=cookies)
title = part["title"] title = part["title"]
clean_title = slugify(title) clean_title = slugify(title)
@@ -182,7 +182,7 @@ async def add_chapters(
# Thanks https://eu17.proxysite.com/process.php?d=5VyWYcoQl%2BVF0BYOuOavtvjOloFUZz2BJ%2Fepiusk6Nz7PV%2B9i8rs7cFviGftrBNll%2B0a3qO7UiDkTt4qwCa0fDES&b=1 # Thanks https://eu17.proxysite.com/process.php?d=5VyWYcoQl%2BVF0BYOuOavtvjOloFUZz2BJ%2Fepiusk6Nz7PV%2B9i8rs7cFviGftrBNll%2B0a3qO7UiDkTt4qwCa0fDES&b=1
chapter = epub.EpubHtml( chapter = epub.EpubHtml(
title=title, title=title,
file_name=f"{clean_title}.xhtml", file_name=f"{cidx}.xhtml", # Used to be clean_title.xhtml, but that broke Arabic support as slugify turns arabic strings into '', leading to multiple files with the same name, breaking those chapters.
lang=data["language"]["name"], lang=data["language"]["name"],
) )
@@ -200,11 +200,11 @@ async def add_chapters(
img = epub.EpubImage( img = epub.EpubImage(
media_type="image/jpeg", media_type="image/jpeg",
content=await response.read(), content=await response.read(),
file_name=f"static/{clean_title}/{idx}.jpeg", file_name=f"static/{cidx}/{idx}.jpeg",
) )
book.add_item(img) book.add_item(img)
content = content.replace( content = content.replace(
str(image), f'<img src="static/{clean_title}/{idx}.jpeg"/>' str(image), f'<img src="static/{cidx}/{idx}.jpeg"/>'
) )
chapter.set_content(f"<h1>{title}</h1>" + content) chapter.set_content(f"<h1>{title}</h1>" + content)