pythongoogle-translatelanguage-translationgoogletrans

googletrans doesn't translate the numbers


The translator works fine for the phrases and word but doesn't convert the English numbers into other languages

if I did this

nep= translator.translate('12', dest='nepali')
print(nep.text)

the output will be :

 12

but it should be:

 १२

Solution

  • The Hindu-Arabic counting system (google this) is not English, it is used by many languages, and has existed well before the English language did. I would think that translate would know this. What you need to do is translate the Hindu-Arabic numbers into English words first, then you can translate them.

    >> pip install num2words
    
    import num2words
    print(num2words.num2words(5))
    print(num2words.num2words(57))