I am trying translate some text from English to Chinese(Tradional), below is my code:
def translate(text, dest='zh-tw'):
if not text:
return text # 返回原文本如果是 None 或空字符串
translator = Translator()
result = translator.translate(text, dest).text
print(f"Translated '{text}' to '{result}'")
return result
I tried translate a text that contained a Placeholder like this:
tried the other comment? replace it with 1 before translating, and replace it back later. or just look for the ___% and the %after that, and replace it back with the content you wanted
Googletrans version:
I'm submitting a ...
Current behavior:
I am trying translate some text from English to Chinese(Tradional), below is my code:
I tried translate a text that contained a Placeholder like this:
and it responsed this text:
(If you want to know why the placeholder have some underline with the placeholder? Because I find this post on StackOverflow: How to tell Googletrans to ignore certain parts?)
Expected behavior:
It won't translate placeholder, like below:
Steps to reproduce:
Below is my code, but I think it won't help... Translator.py: https://gist.github.com/510208/a60f2752872eabe11e8552e94d278e45 Checkformat.py: https://gist.github.com/510208/8b07f6a939bb8fa970cefdc9e86e8077
Related code: