gumblex / zhconv

Simple conversion and localization between simplified and traditional Chinese using tables from MediaWiki.
https://pypi.python.org/pypi/zhconv
MIT License
520 stars 37 forks source link

Maybe raise a keyerror is a better way to process the locale not supported #8

Open Raibows opened 3 years ago

Raibows commented 3 years ago

Because return the not actually converted sentence may confuse someone that is careless about the supported locales. And I think raise an error early can stop future big error for user codes.

https://github.com/gumblex/zhconv/blob/078838e6f1427c970d5ede1b229b11048cac78a5/zhconv/zhconv.py#L235-L254

Let's see a mistake that may confuse the users in using the locale:

inputs = "我幹什麼不干你事"
print(convert(temp, locale='zh_cn'))
#output the same as the inputs but no warnings or erros 

Maybe many users like me use zh_cn instead of the correct zh_cn by mistake sometime.