ID EN
#Dynamic array

DETECTLANGUAGE

Excel Functions

Detect the language of a given text string

Syntax

EXCEL
=DETECTLANGUAGE(text)

Arguments

Parameter Description
text A sample of the language as a text string.

Return Value

A language code

Details

The DETECTLANGUAGE figures the language for a given text string. The result from DETECTLANGUAGE is a short language code indicating the language. For example, if the language is English, the result is "en"; if the language is French, the result is "fr"; if the language is Japanese, the result is "ja", and so on. Some of these codes are intuitive, but some aren't. See below for a list of common language codes. DETECTLANGUAGE only accepts one argument, text, so the syntax is very simple and looks like this: Typically, the text is supplied as a cell reference like A1, but it can also be hardcoded as a string like "apple". To use the DETECTLANGUAGE function, simply provide some text. For example, if we give DETECTLANGUAGE the word "apple", it "detects" English and returns "en": Likewise, if we

Examples

Example 1

The DETECTLANGUAGE figures the language for a given text string. The result from DETECTLANGUAGE is a short language code indicating the language. For

EXCEL
=DETECTLANGUAGE(text)
Basic Example

To use the DETECTLANGUAGE function, simply provide some text. For example, if we give DETECTLANGUAGE the word "apple", it "detects" English and return

EXCEL
=DETECTLANGUAGE("apple")  //  returns "en"
Basic Example

Likewise, if we give DETECTLANGUAGE the word for "apple" in four languages (French, Italian, German, and Spanish), it returns the four corresponding l

EXCEL
=DETECTLANGUAGE("pomme")  //  returns "fr"
=DETECTLANGUAGE("mela")  //  returns "it"
=DETECTLANGUAGE("Apfel")  //  returns "de"
=DETECTLANGUAGE("manzana")  //  returns "es"
Example: Get language codes

In the worksheet below, we have text for "Is there a coffee shop around here?" in 12 languages. The goal is to determine the language codes based on t

EXCEL
=DETECTLANGUAGE(B5)
Example: Get language names

Then we can use the XLOOKUP function to get the correct language for a given code, as seen in column E of the worksheet below. The formula in cell E5

EXCEL
=XLOOKUP(D5,languages[Code],languages[Language])
Example: Get language names

If you want to look up the language name from the code in one step, you can combine the formulas above into one formula like this:

EXCEL
=XLOOKUP(DETECTLANGUAGE(B5),languages[Code],languages[Language])

See Also

TRANSLATE