Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LanguageDetectionError | Can't detect english language? #26

Open
nurzhannogerbek opened this issue Mar 12, 2018 · 3 comments
Open

LanguageDetectionError | Can't detect english language? #26

nurzhannogerbek opened this issue Mar 12, 2018 · 3 comments

Comments

@nurzhannogerbek
Copy link

Hello! =) First of all Thank you for this library.

I have one problem. Let me try to explain this little problem.

I use your library in my Django project. User can write english (latin) or russian (cyrillic) letters in field. If user write russian words it change word to latin letters but if user write english words I see next error:
LanguageDetectionError: Can't detect language for the text "document" given.

I use this code:
transliterate.translit(field_value, reversed=True)

Also I notice that in your project its impossible to detect english language, isn't it?

transliterate.detect_language(field_value) return None when user enter english word.

My aim is to transliterate only if user wrote russion word, but don't touch it user wrote english word. What can you advice?

@idchlife
Copy link

If I am correct, there is no language pack for english language in this library yet.
But... You can contribute!

https://github.com/barseghyanartur/transliterate/tree/master/src/transliterate/contrib/languages

@barseghyanartur
Copy link
Owner

@NogerbekNurzhan:

Yep. Honestly, auto-detection is very-very basic. I would suggest using another dedicated libraries for that.

@idchlife
Copy link

@NogerbekNurzhan also small idea.
How about doing reversed logic.

If it's not russian - it's english (well, we gotta stick to something, don't we?)

Use

# lang will be None if english
lang = detect_language(text)
translit(text, "ru", reversed=False if lang else True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants