Skip to content

Commit

Permalink
Merge pull request #8 from RongYYYY/ckpt-final
Browse files Browse the repository at this point in the history
changing message to see if updates are realized
  • Loading branch information
ogometz authored Nov 16, 2024
2 parents f2f0b46 + 67dbf27 commit 59acb6a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_translation(post: str) -> str:
# f"If the text can be translated to English, return only the translated text to English with no additional text. Do not add, remove, or alter any punctuation marks; match the punctuation pattern of the original text exactly."
# f"For example, if the input is 'Hola' translate it to 'Hello' without any punctuation. If the input has punctuation, like '¡Hola!', translate it as 'Hello!' preserving the punctuation style."
# f"This is the input text: '{post}'."
f"Please translate the following text to english: '{post}'. Return only the translated text to English with no additional text. Do not add, remove, or alter any punctuation marks; match the punctuation pattern of the original text exactly. For example, if the input is 'Hola' translate it to 'Hello' without any punctuation. If the input has punctuation, like '¡Hola!', translate it as 'Hello!' preserving the punctuation style."
f"Please translate the following text to english: '{post}'. Return only the translated text to English with no additional text. Do not add, remove, or alter any punctuation marks; match the punctuation pattern of the original text exactly. For example, if the input is 'Hola' translate it to 'Hello' without any punctuation. If the input has punctuation, like '¡Hola!', translate it as 'Hello!' preserving the punctuation style."
)

try:
Expand All @@ -68,11 +68,11 @@ def get_translation(post: str) -> str:

def translate_content(content: str) -> tuple[bool, str]:
try:
is_eng = get_language(content)
if is_eng.lower() == "neither":
language = get_language(content)
if language.lower() == "neither":
return False, "Unknown language"

if is_eng.lower() == "english":
if language.lower() == "english":
return True, content
else:
translated = get_translation(content)
Expand All @@ -95,4 +95,4 @@ def translate_content(content: str) -> tuple[bool, str]:
return False, translated

except Exception as e:
return False, "There was an error translating the text"
return False, "There was an issue translating the text"

0 comments on commit 59acb6a

Please sign in to comment.