soimort / translate-shell

:speech_balloon: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
https://www.soimort.org/translate-shell
The Unlicense
7k stars 392 forks source link

Strange bug with some Chinese sentences containg : #503

Closed dallascao closed 1 year ago

dallascao commented 1 year ago

./trans -b -no-bidi zh-CN:en '有效期:一年'

This will stuck and no translations will be returned.

Note: Not only Chinese. This won't work either:

./trans -b -no-bidi en:zh-cn 'Non:'

Update: This will also halt the program:

./trans en:zh-cn '{=zh+ja}'

dallascao commented 1 year ago

I replaced : with : and it fixed the problem.

soimort commented 1 year ago

Thanks for reporting this. In the 1st and 2nd examples, trans used to interpret parameters 有效期:一年 and Non: wrongly as source/target language codes, and that's why it failed to translate them as texts. Should be fixed now.

As for your 3rd example: because '{=zh+ja}' is a valid pair of target language codes (that overrides the previous parameter en:zh-cn), trans awaits standard input to translate. This is the expected behavior and not considered a bug.

soimort commented 1 year ago

Plus, if you want to translate strings like "{=zh+ja}" no matter what, separate it with parameters using a double-dash --:

./trans en:zh-cn -- '{=zh+ja}'