Home > other >  How do I use two formulas in one cell on Google Sheets?
How do I use two formulas in one cell on Google Sheets?

Time:12-26

I'm trying to use the Googletranslate function on Google Sheets but would like the cell to detect English or Japanese. I wanted to use Detectlanguage to find out the language first but I'm not sure how to format it. Here's what I did but I get an error:

=if(=DETECTLANGUAGE(A2)="en",[=GOOGLETRANSLATE("jp"]))

If it's English, I wanted it to be translated to Japanese and vice versa. Does anyone know if I am on the right track? Thank you in advance.

CodePudding user response:

based on the GOOGLETRANSLATE and DETECTLANGUAGE functions,

try this:

=IF(DETECTLANGUAGE(A2)="en",GOOGLETRANSLATE(A2, "en", "ja"),GOOGLETRANSLATE(A2, "ja", "en"))

Source: https://support.google.com/docs/answer/3093331?hl=en https://support.google.com/docs/answer/3093278?hl=en

CodePudding user response:

A few problems with your attempted answer.

first to translate from English to Japanese you would use

=googletranslate("en","ja")

or if you want to detect the source language

=googletranslate("auto","ja")

The first language is the source language and the second is the target the list of supported languages and their codes is here (note ja not jp for Japanese) language docs: https://cloud.google.com/translate/docs/languages

next, when nesting functions (i.e. calling functions within other functions you do not prefix with =

so you would use something like this to return the desired target language

`=if(detectlanguage(a2)="en", "ja", "en")

you can put this all together like this:

=googletranslate("auto", if(detectlanguage(a2)="en", "ja", "en"))

  • Related