Detect and Translate Content in Google Sheets

Published on

I have a spreadsheet with content in a foreign language. How can I read it? It’s possible! You can detect and translate content in Google Sheets using its built-in functions.

Open your spreadsheet in Google Sheets and use the functions DETECTLANGUAGE and GOOGLETRANSLATE in combination. These are two individual Google Sheets functions that make it easy to translate content directly within your spreadsheet.

Why Combine These Functions?

Most of the time, it can be challenging to identify the foreign language you want to translate. Even if you manage to figure it out, you’ll need to know the corresponding language code.

The DETECTLANGUAGE function identifies the language code for you, which can then be used within the GOOGLETRANSLATE function. However, this step is optional because GOOGLETRANSLATE has a built-in option to automatically detect the language and translate the content to your specified language.

Let’s dive into how these functions work.

How to Use the DETECTLANGUAGE Function in Google Sheets

Syntax:

DETECTLANGUAGE(text_or_range)
  • text_or_range: This can be hardcoded text or a reference to a cell containing the text to evaluate. You can also refer to a one-dimensional range, in which case the function will identify the language of the very first cell in that range. Make sure the first cell is not empty.

Example of the DETECTLANGUAGE Function:

Suppose you have text in column A, starting from cell A1. Use the following formula in cell B1 and drag it down:

=DETECTLANGUAGE(A1)
Example of the DETECTLANGUAGE function in Google Sheets

If you want to detect the language of a range, use this:

=DETECTLANGUAGE(A1:A5)

In this case, the formula will detect the language of the text in the first cell of the range (A1).

How to Use the GOOGLETRANSLATE Function in Google Sheets

Since the topic is about how to detect and translate content in Google Sheets, let’s now look at the translation process.

Syntax:

GOOGLETRANSLATE(text, [source_language, target_language])
  • text: Hardcoded text or a cell reference to the text you want to translate.
  • source_language: The language code of the source text. If you don’t know this, you can either use the DETECTLANGUAGE function or set it to "auto".
  • target_language: The language code for the desired translation.

You can omit both source_language and target_language to allow the function to detect the source language and translate the text to your spreadsheet’s default language.

Example:

If the texts to translate are in A1:A4, the source language codes are in B1:B4, and the target language codes are in C1:C4, enter the following formula in cell D1 and drag it down to translate all the texts:

=GOOGLETRANSLATE(A1, B1, C1)
Examples of the GOOGLETRANSLATE function in Google Sheets

Detect and Translate Content in Google Sheets: Combined Formula

Here’s how you can combine the two functions to detect and translate content in Google Sheets:

Formula:

=GOOGLETRANSLATE(A1, DETECTLANGUAGE(A1), "en")
Illustration of how detect and translate functions work in Google Sheets

This formula uses the output of the DETECTLANGUAGE function as the source language and translates the text into English ("en").

Alternatively:

You can simplify this by using "auto" to let GOOGLETRANSLATE automatically detect the language:

=GOOGLETRANSLATE(A1, "auto", "en")

To translate text into your spreadsheet’s default language, use:

=GOOGLETRANSLATE(A1)

Language Codes for the GOOGLETRANSLATE Function

You can find a full list of language codes for use with GOOGLETRANSLATE on the Google Developers Language Codes page. To import them into your sheet, use this IMPORTHTML formula in cell A1 of an empty sheet:

=IMPORTHTML("https://developers.google.com/admin-sdk/directory/v1/languages", "table", 1)

Conclusion

By combining DETECTLANGUAGE and GOOGLETRANSLATE, you can efficiently detect and translate content in Google Sheets. Whether you’re working with a single cell or a large dataset, these functions make handling multilingual content seamless.

If you want an array formula, you can use the MAP lambda helper function. The generic formula is:

=MAP(range, LAMBDA(text, GOOGLETRANSLATE(text, "auto", "en")))

Replace range with the range containing the text you want to translate.

Follow the tips above to streamline your workflow and simplify translation tasks!

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

How to Extract Numbers from Text in Excel with Regex

You can use the REGEXEXTRACT or REGEXREPLACE functions to easily extract numbers from text...

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

How to Use OFFSET and XMATCH Functions Together in Excel

We often use the OFFSET and XMATCH functions together to match a value in...

How to Calculate Maximum Drawdown in Excel and Google Sheets

You can use the following dynamic array formula to calculate maximum drawdown (MDD) in...

More like this

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

Running Count with Structured References in Google Sheets

Running a count with structured references is achievable in Google Sheets tables using the...

Running Total with Structured Table References in Google Sheets

You can use two types of formulas to create a running total with structured...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.