Category: FUNCTION | Updated: 2026-11-22
How to Use the DETECTLANGUAGE Function: Automatically Identify the Language of Text
Overview of the DETECTLANGUAGE Function
The DETECTLANGUAGE function automatically identifies what language a specified text string or cell content is written in and returns its 2-letter language code (ISO 639-1). It is useful for sorting multilingual customer inquiries or building conditional logic combined with the GOOGLETRANSLATE function.
Syntax
=DETECTLANGUAGE(text)
- text: The text string whose language you want to identify, or a cell (or range of cells) containing the text.
Practical Examples with a Table
This example identifies the language codes for greetings in various languages entered in column A.
| Cell | A (Target Text) | B (Formula) | C (Detected Result) |
|---|---|---|---|
| 1 | Text | Formula | Language Code |
| 2 | おはようございます | =DETECTLANGUAGE(A2) |
ja |
| 3 | Good morning | =DETECTLANGUAGE(A3) |
en |
| 4 | Merci beaucoup | =DETECTLANGUAGE(A4) |
fr |
| 5 | 谢谢 | =DETECTLANGUAGE(A5) |
zh-CN |
Common Errors and Precautions
- Misidentification of short words or proper nouns: Single-word strings or proper nouns written in the Latin alphabet may be misidentified as an unintended language (for example, English being detected as German
deor Frenchfr). - Cells containing only numbers or symbols: Passing a cell that contains only numbers or symbols may return
und(undefined) because the language cannot be determined. - Offline behavior: Because it communicates with Google’s servers to detect the language, it will not work and will return an error when offline.
Frequently Asked Questions
Q. What kind of result does the DETECTLANGUAGE function return?
A. It returns the 2-letter language code corresponding to the detected language (such as "ja" for Japanese or "en" for English).
Q. What happens if DETECTLANGUAGE checks text containing multiple languages?
A. It returns only the single language code judged to be the most dominant (highest proportion) in the text.