How to properly identify different languages in a text chat Unity app?

Hello,

I’m developing a text chat and we need to give support for multiple languages, like Japanese, simplified and traditional Chinese, English, etc.

For example, if I wrote in English and someone else wrote in Simplified Chinese and another in Japanese, I should be able to see all 3 languages with their respective correct fonts.

I already have the fonts, I can change to the right font in the TextMesh editor. My question is: How can I properly identify the text language? (So I can use the right font)

The solution that I can see is to send the language used with every text message, but I would like to know with you guys if we have another possible solution to dynamically identify the language.

Thanks in advance.

The solution of sending the language is the safest. Trying to dynamically identify the language from the text will be difficult. You dont need to send it with every message though, have it part of the information you store on each user or have it as something that can be queried by your system.

There are a variety of different Libraries for this.. Some use server-communication, some do not.

Here are a few:

stratosblue/LanguageIdentification: .NET Port of Language Identification Library for langid-java. 移植自langid-java的语言识别库。 (github.com)
detectlanguage/detectlanguage-dotnet: Detect Language API .NET Client (github.com)
ivanakcheurov/ntextcat (github.com)

language-detection · GitHub Topics