Going Stellar

Home/Google Sheets reference

Google Sheets function · Google-only

DETECTLANGUAGE in Google Sheets: syntax and examples

DETECTLANGUAGE returns the language code (en, ro, de) it finds in the text. Pair it with GOOGLETRANSLATE to translate only the cells that are not already in your target language.

Syntax

DETECTLANGUAGE(text_or_range)

Arguments

ArgumentTypeRequiredWhat it does
text_or_rangeanyyesThe text, or a cell reference, whose language to identify.

Examples

The examples use this table, starting in A1:

Text
Bună ziua, ce mai faci azi?
Hello, how are you today?
Guten Morgen, wie geht es dir?
=DETECTLANGUAGE(A2)

Result: ro

Romanian text returns the code ro.

Run in a Google Sheet (English US locale) on .

=DETECTLANGUAGE(A3)

Result: en

English text returns en.

Run in a Google Sheet (English US locale) on .

=DETECTLANGUAGE("Guten Morgen wie geht es dir")

Result: de

A string can be typed straight into the formula.

Run in a Google Sheet (English US locale) on .

=UPPER(DETECTLANGUAGE(A4))

Result: DE

The result is plain text, so other text functions work on it.

Run in a Google Sheet (English US locale) on .

=IF(DETECTLANGUAGE(A3)="en","keep","translate")

Result: keep

Branch on the detected code.

Run in a Google Sheet (English US locale) on .

Common errors

  • A range of several cells returns #VALUE!, even inside ARRAYFORMULA, despite the argument name text_or_range. Write one formula per cell and fill it down.
  • A number such as 12345 has no language: the result is und (undetermined), not an error.

Compared with Excel

Excel has no DETECTLANGUAGE function.

Sources

  1. DETECTLANGUAGE (Docs Editors Help)

Markdown version · All functions