how to get a str 's language?

mc 6,056 Reputation points
2025-10-21T07:51:14.54+00:00

I want to get a str's language

for example

I have str:var str="OK确定を選択して、bestimmenDéterminer확인Определение"

I want to get : OK is english 确定 is Chinese を選択して、 is Japanese and also Определение and bestimmen and Déterminer

Developer technologies | .NET | .NET Runtime
0 comments No comments
{count} votes

Answer accepted by question author
  1. Michael Le (WICLOUD CORPORATION) 3,495 Reputation points Microsoft External Staff
    2025-10-21T09:35:15.73+00:00

    Hello @mc ,

    There is no simple built-in solution in .NET or common libraries that can accurately detect multiple languages within a single text input like your example string. The main challenge is that your mixed text contains segments from different languages that need to be separated before detection can work effectively.

    You could consider looking into advanced NLP libraries or services that specialize in language detection.

    Azure Cognitive Services Text Analytics offers the most reliable language detection feature for this type of mixed content, though it is a commercial service.

    For free alternatives, ML.NET allows you to integrate custom machine learning models which could be trained for multi-language detection, but this would require significant effort and expertise in machine learning.

    Also, the LanguageDetection library might help to some extent but may not be perfect for mixed-language inputs since it's designed for single-language detection and hasn't been updated recently.

    I hope this clarifies the situation and gives you a clearer path forward.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Starry Night 600 Reputation points
    2025-10-22T08:16:29.7933333+00:00

    Language detection is one of the features offered by Azure AI Language, a collection of machine learning and AI algorithms in the cloud for developing intelligent applications that involve written language. Language detection is able to detect more than 100 languages in their primary script. In addition, the service offers script detection for each detected language using ISO 15924 standard for a select number of languages.

    You can start by referring to the following document:

    • Quickstarts are getting-started instructions to guide you through making requests to the service.
    • How-to guides contain instructions for using the service in more specific or customized ways.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.