logo elektroda
logo elektroda
X
logo elektroda

Automatic text translation in Google Sheets (Excel online). Let's translate firmware.

p.kaczmarek2 3162 16

TL;DR

  • Google Sheets workflow uses GOOGLETRANSLATE to automate firmware string translation and build multilingual C/C++ resources.
  • The sheet stores English source text, language codes in columns, and absolute references with $ to fill translations across rows and columns.
  • The example uses GOOGLETRANSLATE, DetectLanguage, and CSV export, then generates preprocessor headers for separate language binaries like Tasmota’s compile-time model.
  • Google Translate speeds up the first pass, but translations still need human review because context and wording can be wrong.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Google Sheets columns with translations to various languages .
    Google Sheets offer a wide range of features, here I will focus on one of them - the GOOGLETRANSLATE function. This function allows us to automatically translate words and phrases between two languages, just like regular Google Translate, but its presence in the sheet can really save us a lot of time. In this particular case, I will demonstrate the translation of a potential home automation firmware, but I think it has many more applications and there is something for everyone.


    Basics of GOOGLETRANSLATE
    Open our Google sheet and type in A1 some example word - "Relay":

    Google Sheet with the word Przekaźnik entered in cell A1 .
    .
    In B1 type the equals sign and then start typing GOOGLE, a hint should already appear:
    GOOGLETRANSLATE function suggestion in Google Sheets .
    .
    Validate, now three arguments need to be entered:
    GOOGLETRANSLATE formula in Google Sheets .
    .
    The arguments are:
    - text to be translated (or a cell with it)
    - source language
    - target language
    Done:
    Google Sheet with GOOGLETRANSLATE formula translating the word Przekaźnik. .
    .
    Everything works:
    Google Sheet with translation function from Polish to English


    We are expanding the sheet .
    We already know how GOOGLETRANSLATE works, but it's time to start using it better. First a small change - in my firmware everything is in English, so the base language will be English. Apart from that, I'll throw out the language codes written "hard" in the cells so that they are in the first cell. So we are looking into the language codes:
    https://developers.google.com/admin-sdk/directory/v1/languages?hl=pl
    We create columns for each of them:
    Screenshot of a Google Sheet with technical translations in various languages. .
    .
    We enter the magic formula. The whole idea here is to use the character $ to enable absolute addressing for column A (source word), for the source language and for the target language row:
    Screenshot of Google Sheets showing the use of the GOOGLETRANSLATE function to translate the word Relay from English to Polish. .
    .
    Mark cell and stretch downwards:
    Google Sheets snippet with GOOGLETRANSLATE function. .
    .
    And then to the right:
    Google Sheets columns with translations to various languages .


    Related feature .
    While we're on the subject of translations, it's worth mentioning a related function, namely DetectLanguage - this returns the language code for a given word:
    Screenshot of a Google Sheet using the DETECTLANGUAGE function to identify the language of the word Achtung. .
    Thus we get:
    Google Sheets cell with the word Achtung and language code de .
    Can be useful if you do not recognise the language in question.

    Potential pitfall
    Is everything now perfectly translated? Unfortunately not, rather someone familiar with the language should review it. Google Translate isn't perfect and doesn't know the context, so strange translations still happen. Rather, what we have done should only be a base for further translations.


    Export results .
    Now it is a matter of further processing the data. A CSV file, or comma separated values, can be downloaded from Google Sheets.
    Screenshot of the download menu in Google Sheets showing the CSV option selection. .
    .
    This is how the file looks after downloading:
    Simple CSV file with technical translations into various languages
    .
    The structure of the file is really very simple. It can be loaded very easily in your own program, two steps are enough:
    - reading it line by line
    - divide the line into phrases according to commas
    Example code in C#:
    Code: C#
    Log in, to see the code
    .
    This code simply reads in such a file and extracts separate values from it. The loading is carried out line by line.

    How is the translation implemented for programs written in C/C++? .
    It's time to go one step further and think about how we can make language versions for our software. Let's look at some practical example here, how is this done in Tasmota for example?
    https://tasmota.github.io/docs/
    To start with, there can be two ways of translations:
    - a language version embedded at compile time in the firmware (only one, selected) - this requires changing the batch to change the language, but saves memory
    - you can also keep different language versions in the batch (or load them from files, etc.) - this takes more memory
    Tasmota has separate binary files for the languages:
    Tasmota installation options with a dropdown language selection menu..
    .
    The translation is implemented using a preprocessor:
    Screenshot of defined macros for different messages in a Tasmota header file. .
    .
    We have separate headers that define the subtitles, e.g:
    Code: C / C++
    Log in, to see the code
    .
    Here are some of them:
    List of language translation files for Tasmota
    .
    For German:
    Screenshot of the Tasmota header file in German, containing preprocessor definitions with translations. .
    .
    And then in the application code the simply executed #define is used, like this:
    Code: C / C++
    Log in, to see the code
    .
    It is important to note that only one of these headers is included at compile time. Then compilation is performed separately for each such header and the result is separate binaries, one file per language.


    Automatic header generation .
    Now that we know how translations are implemented by Tasmota, let's try to map the same in our code. Let's add the names of the preprocessor definitions to our sheet:
    Google Sheet with translations of words into various languages. .
    .
    Next, let's modify our code so that it automatically reads the CSV and creates translation headers:
    Code: C#
    Log in, to see the code
    .
    It's worth remembering that I start the loops here with 1 rather than 0, to skip the first name column for the preprocessor. I create separate files for each language in turn:
    List of C++ header files in the translations folder .
    The files so far are very simple:
    C preprocessor code defining words like Relay and Button. .
    .
    Here it would still be useful to make some kind of standard, instead of just NO, maybe better S_NO, etc. As in Tasmota, by the way, they have a D_ prefix there.
    So we change:
    Code: C#
    Log in, to see the code
    .
    to:
    Code: C#
    Log in, to see the code
    .
    Of course, this is just a seed and there are still a few potential things to improve with this, but for demonstration purposes this will suffice.

    Summary
    Undoubtedly Google Sheets can help with translation automation, including when translating a program to a microcontroller, although I still think some care needs to be taken when doing this and running any translation through someone who knows the language. In addition, it is worth remembering that the adventure does not end with the Sheets alone, because you can always download the CSV and process it further, even if only in simple self-written programmes, as I have also shown here..
    And what uses do you have for Google Sheets? Feel free to discuss.

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 14411 posts with rating 12356, helped 650 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 21166003
    Pawel_
    Level 12  
    Posts: 18
    Rate: 2
    Nonetheless, one would also have to check the quality of the translations themselves because, looking at the context, the word 'Current' should be translated as 'Current' and not 'Current'.
  • #3 21166134
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14411
    Help: 650
    Rate: 12356
    Congratulations, watchful eye, I wondered if anyone would see it, but I also included a warning about it in the text in the paragraph "Potential pitfall".

    Anyway, it wouldn't be the first time, how many one sees at least on the internet these "funny pictures"/photos with incorrect translations e.g. from some foreign restaurants or something.

    It's like with AI, it's a good tool if you check the results afterwards.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #4 21166218
    TechEkspert
    Editor
    Posts: 7048
    Help: 16
    Rate: 5458
    An interesting mechanism, however, in this way and without correction, unfortunately, Chinese translations of the GUI and instructions are most likely to be produced....
  • ADVERTISEMENT
  • #5 21166837
    krzbor
    Level 29  
    Posts: 1731
    Help: 40
    Rate: 1044
    @ElektrodaBot In the picture below are translations of technical phrases from English into Polish, Czech, German and Russian respectively. Are these translations correct?
    Table with translations of technical terms into Polish, Czech, German, and Russian.
  • ADVERTISEMENT
  • #6 21166839
    ElektrodaBot
    AI OpenAI ChatGPT4
    Posts: 8735
    Help: 350
    Rate: 919
    krzbor wrote:
    In the picture below are translations of technical phrases from English into Polish, Czech, German and Russian respectively. Are these translations correct?
    https://obrazki.elektroda.pl/1226228800_1721857988.jpg
    1. Relay:
    - en: Relay
    - en: Relay
    - cs: Relé
    - de: Relais
    - ru: Реле

    The translations are correct.

    2: Button:
    - en: Button
    - en: Button
    - cs: Knoflík
    - de: Taste
    - ru: Кнопка

    The translations are correct.

    Voltage:
    - en: Voltage
    - pl: Voltage
    - cs: Napětí
    - de: Stromspannung (better: Spannung)
    - ru: Напряжение .

    The word "Stromspannung" in German is correct, but it is more common to use simply "Spannung".

    4 Power:
    - en: Power
    - pl: Power
    - cs: Napájení (better: Výkon)
    - de: Leistung
    - ru: Власть (better: Мощность)

    In Czech "Napájení" means power supply, "Výkon" would be more appropriate. In Russian, the word "Власть" means power, while a more appropriate term would be "Мощность".

    5 Current:
    - en: Current
    - en: Current (better: Current)
    - cs: Aktuální (better: Proud)
    - de: Aktuell (better: Strom)
    - ru: Текущий (better: Ток)

    In translations for "Current" there is a misinterpretation as current instead of current. In Polish: "Prąd", Czech: "Proud", German: "Strom", Russian: "Ток".

    6 Options:
    - en: Options
    - en: Options
    - cs: Možnosti
    - de: Optionen
    - ru: Параметры (better: Опции)

    "Параметры" in Russian means parameters, more appropriate would be "Опции".

    7. Yes:
    - en: Yes
    - en: Yes
    - cs: Ano
    - de: Ja
    - ru: Да

    The translations are correct.

    8. no:
    - en: No
    - en: NO
    - cs: Ne
    - de: NEIN
    - ru: Нет

    The translations are correct.
    You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
  • #7 21166842
    krzbor
    Level 29  
    Posts: 1731
    Help: 40
    Rate: 1044
    Quite a good analysis. How about using ChatGPT instead of Google translator?
  • #8 21167045
    TechEkspert
    Editor
    Posts: 7048
    Help: 16
    Rate: 5458
    GPT has beaten google, I wonder if it will replace the search engine and translator in the future.
  • #9 21168545
    krzbor
    Level 29  
    Posts: 1731
    Help: 40
    Rate: 1044
    TechEkspert wrote:
    GPT has beaten google, I wonder if it will replace the search engine and translator in the future.

    This is almost certain to happen. Here is an example - Google translation of the words: trunc, extension, phone into Polish: cut off, extension, phone
    Chat command:
    Translate to Polish: trunc, extension, phone
    Answer:
    trunc - stem
    extension - extension
    phone - phone
    .
    As you can see, he didn't catch that these words are from the field of telephony - that's why I added the unambiguous term "phone"
    So I asked another question:
    These words are in the description of a telephone exchange. Do they then mean the same thing?
    Answer:
    In the context of a telephone exchange, the terms have different meanings. Here are the correct translations:

    trunc - connection
    extension - extension number
    phone - telephone

    Do these translations match your expectations?


    In chat GPT you only need to provide context information and the translations are correct.
  • #10 21168621
    Urgon
    Level 38  
    Posts: 7198
    Help: 197
    Rate: 2630
    AVE...

    I am currently correcting translations of articles from Dutch to Polish for EdW (sometimes I also write my own articles). Some professional machine-learning-based programme is used for the translation, I just correct factual errors and messy sentences. Sometimes you get flowers, such as "Viennese bridge" instead of "Vien bridge". Interestingly, machine translation from Dutch to English is usually quite correct, as both languages have similar grammar and vocabulary.

    Translating single words, especially if they have an unambiguous meaning, is much easier - a regular paper dictionary, for example, does this. The problem begins when whole sentences need to be translated, especially if they are not simple sentences. For example, translations from German into Polish, especially of articles from the press, are mechanically difficult. German journalists and editors are fond of constructing absurdly long, multiple-complex sentences where the main judgment is at the grey end, and by the time the reader gets to it, he or she may no longer remember the matching subject. Google Translate does a poor job of this....

    BTW, what happens when you run the lyrics of a song through Google Translate several times and translate them through different languages before going back to the original one? This:



    .
  • #11 21173109
    divadiow
    Level 38  
    Posts: 4852
    Help: 424
    Rate: 857
    That's brilliant

    Added after 4 [minutes]:

    Is this thread a preamble to making OpenBeken available in other languages?
  • #12 21173163
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14411
    Help: 650
    Rate: 12356
    Maybe we need to take another approach and make a single call to OpenAI GPT API with request to "detect the context and translate". It may be better than Google.
    Helpful post? Buy me a coffee.
  • #13 21176603
    krzbor
    Level 29  
    Posts: 1731
    Help: 40
    Rate: 1044
    p.kaczmarek2 wrote:
    Maybe we should take a different approach and make a single call to the OpenAI GPT API asking it to "detect context and translate". This might be better than Google.
    .
    We will try:
    @ElectrodBot
    Translate the following technical phrases (related to electricity) from English into Polish, Czech, German and Russian. Save the result as JSON.
    Relay, Button, Voltage, Power, Current, Options, Yes, No
  • #14 21176606
    ElektrodaBot
    AI OpenAI ChatGPT4
    Posts: 8735
    Help: 350
    Rate: 919
    krzbor wrote:
    Translate the following technical phrases (related to electricity) from English into Polish, Czech, German and Russian. Save the result as JSON.
    Relay, Button, Voltage, Power, Current, Options, Yes, No
    Code: text
    Log in, to see the code
    .
    You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
  • #15 21176610
    krzbor
    Level 29  
    Posts: 1731
    Help: 40
    Rate: 1044
    I think it worked out pretty well?
  • #16 21176618
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14411
    Help: 650
    Rate: 12356
    You did it a bit differently @krzbor than I assumed. I was thinking not to prompt in the prompt what the phrases are related to, but to write a prompt like (preferably in English) "Translate the phrases paying attention to their context so that they fit together". It seems to me that with the right prompt, you can make GPT into such a "smart translator" that will keep the context but without telling it explicitly that these are technical phrases (related to electricity) .

    With the available API from OpenAI, which I have already used, it would be possible to make such a plugin for Sheets which detects the context itself and translates, without telling it in advance that it is e.g. related to electricity
    Helpful post? Buy me a coffee.
  • #17 21190567
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14411
    Help: 650
    Rate: 12356
    p.kaczmarek2 wrote:
    with the right prompt, it is possible to make GPT into such a "smart translator" that will preserve the counter but without telling it explicitly that these are technical (current-related) phrases .
    .

    An elaboration of the idea can be found in this topic:
    Translation of concepts by AI while preserving context - ChatGPT prompt and beyond
    Helpful post? Buy me a coffee.
📢 Listen (AI):

Topic summary

✨ The discussion focuses on the use of the GOOGLETRANSLATE function in Google Sheets for automatic text translation, particularly in the context of translating firmware for home automation. Participants highlight the importance of verifying translation quality, as automated translations can often be inaccurate, especially with technical terms. Suggestions include using AI tools like ChatGPT for better context-aware translations. The conversation also touches on the potential for creating plugins that utilize AI to enhance translation accuracy by detecting context without explicit prompts. Various languages and technical phrases are discussed, emphasizing the challenges of translating complex sentences and the need for context in translations.
Generated by the language model.

FAQ

TL;DR: This workflow uses 3 function arguments and one reviewer rule: "check the results afterwards." It helps firmware, GUI, and OpenBeken developers translate string tables in Google Sheets, export CSV, and generate C/C++ language headers faster, while avoiding context mistakes in terms like "Current" and "Power." [#21166134]

Why it matters: It turns ad-hoc translation into a repeatable pipeline from spreadsheet to firmware build, while keeping human review in the loop.

Option Best use in the thread Strength Main weakness
Google Sheets + GOOGLETRANSLATE Bulk spreadsheet translation Fast fill across rows and columns Misses context for technical terms
ChatGPT / GPT API Context-aware technical translation Better when prompt preserves context Still needs verification
Human review Final production check Catches domain errors Slower manual effort

Key insight: Fast translation is easy; reliable technical translation is not. The thread’s strongest takeaway is to automate bulk work in Sheets, then review terminology and, where needed, add AI context handling before release.

Quick Facts

  • GOOGLETRANSLATE in the thread uses 3 arguments: source text, source language, and target language. That structure makes formulas easy to copy across a translation grid. [#21164665]
  • The sample CSV workflow has 2 parsing steps: read each line, then split the line by commas. The author also shows automatic .h file generation from the same CSV. [#21164665]
  • The firmware example translates English strings into 4 target languages: Polish, Czech, German, and Russian, then exports them as structured output. [#21176606]
  • The C/C++ localization method builds 1 binary per language by including only one translation header at compile time. The thread cites Tasmota as the model. [#21164665]
  • The generated-header script intentionally starts loops at index 1, not 0, to skip the macro-name column in the CSV. That prevents writing invalid #define names from the first column. [#21164665]

How do I use the GOOGLETRANSLATE function in Google Sheets to translate firmware strings from English into multiple languages?

Use a sheet with source strings in column A and language codes in the header row. 1. Put the English source word, such as Relay, in cell A1. 2. Enter =GOOGLETRANSLATE($A2,$B$1,C$1)-style logic with fixed references for source text and language cells. 3. Fill the formula down and then right to translate the full firmware table into multiple languages at once. The thread shows English as the base language and scales the formula across several columns. [#21164665]

What is the DetectLanguage function in Google Sheets, and when is it useful during translation work?

DetectLanguage returns the language code for a given word or phrase. It is useful when you receive text with no language label and need a quick guess before translating or sorting strings. The thread presents it as a related Sheets feature and shows it returning a code automatically for the entered text. Use it as a triage tool, not as final linguistic validation. [#21164665]

How does absolute addressing with the $ symbol help when copying translation formulas across rows and columns in Google Sheets?

It locks the parts of the formula that must not move when you fill cells. In the thread, $ keeps column A fixed for the source string, keeps the source-language cell fixed, and locks the target-language row so copied formulas still point to the right headers. That lets one formula expand across many rows and columns without manual editing. The practical result is faster bulk translation and fewer reference errors. [#21164665]

What language codes should I use with GOOGLETRANSLATE in Google Sheets, and where can I find them?

Use the language codes supported by Google and place them in the sheet headers. The thread explicitly points readers to Google’s language-code list, then uses those codes as inputs for source and target languages in the formula. In practice, that means one code for the base language and one code per destination column. Keeping codes in the first row makes the sheet easier to scale and maintain. [#21164665]

Why do Google Sheets translations of technical words like "Current" or "Power" come out wrong without context?

They fail because single words can have several meanings, and the formula sees little or no domain context. The thread shows Current being interpreted as "current/actual" instead of electrical current, and later contrasts that with context-aware translations such as Polish Prąd, German Strom, and Russian Ток. Power also shifts between authority, power supply, and electrical power unless context is clear. That is the core failure mode for GUI and firmware text. [#21166839]

What is the best way to review and correct machine-translated GUI or firmware text before using it in production?

Review every string with someone who knows the target language and the product context. The thread states that Google Translate is not perfect, does not know context well, and should serve only as a base for further correction. A practical flow is: bulk-translate first, compare key technical terms second, and approve only after a human reviewer checks labels, buttons, and electrical vocabulary. That prevents shipping obvious mistakes in GUI text. [#21164665]

How can I export translated text from Google Sheets to CSV and process it further in my own program?

Download the sheet as a CSV file, then load that file in your own toolchain. The thread shows Google Sheets exporting comma-separated values and notes that the resulting file structure is simple enough for custom parsing. Once exported, you can use the CSV as an intermediate format for scripts, firmware generators, or build tools. That makes Sheets a front end for translation entry rather than the final storage format. [#21164665]

What does a simple C# parser for a Google Sheets CSV translation file need to do line by line?

It needs to read each line, split it on commas, and process each field in order. The thread’s sample C# code uses StreamReader, loops until ReadLine() returns null, and then applies line.Split(',') to extract separate values. That is enough for a basic translation table loader. It is a minimal parser, so edge cases like embedded commas inside quoted text still need extra handling if your CSV becomes more complex. [#21164665]

How are language translations typically implemented in C or C++ firmware using preprocessor #define headers?

They are often implemented as one header file per language, with each UI string mapped to a macro. "A preprocessor-based translation header is a C/C++ header that stores localized text as #define macros, selects one language at compile time, and lets application code call the same macro names across builds." The thread shows examples like #define D_EMULATION "Emulation" and then using printf(D_EMULATION); in code. That keeps source code stable while the included header changes by language. [#21164665]

What is a preprocessor-based translation header, and how does Tasmota use it to build separate binaries for each language?

It is a header-per-language system selected during compilation. The thread says Tasmota keeps separate language headers, includes only one at compile time, and then builds a separate binary for each selected language. That approach saves runtime complexity and can save memory compared with storing all languages in one firmware image. The trade-off is operational: you must compile and distribute more than one firmware file. [#21164665]

How can I automatically generate .h translation files from a CSV file for a C/C++ project using C#?

Read the first CSV row as language names, open one output file per language, then write #define lines from each remaining row. The thread’s C# example creates a StreamWriter[], starts loops at index 1, and writes lines like #define S_NAME "text" into separate .h files. That generates one header per language in a translations/ folder. It is a direct bridge from spreadsheet-maintained strings to C/C++ firmware resources. [#21164665]

Which naming convention is better for generated translation macros in firmware headers, such as D_ or S_ prefixes?

A prefixed macro name is better than a bare word, and the thread prefers adding a prefix such as S_. The author notes that plain names like NO are weak and suggests a standard form, while also noting that Tasmota uses a D_ prefix. The exact prefix matters less than consistency across all files. Choose one convention, keep it stable, and avoid collisions with generic macros. [#21164665]

Google Translate vs ChatGPT for technical UI terms: which works better when context matters?

ChatGPT-style prompting works better when context matters, but both outputs still need review. In the thread, Google Translate misses telephony meaning for terms like trunc and extension, while ChatGPT gives better results after the user adds the context of a telephone exchange. A later test also shows AI producing correct JSON translations for 8 electrical UI terms across 4 languages. That makes GPT stronger for ambiguous technical wording, not automatically production-safe. [#21168545]

How should I prompt the OpenAI GPT API to detect context and translate technical phrases without explicitly telling it the domain?

Prompt it to infer context across the whole phrase set and translate consistently, rather than naming the field up front. The thread proposes a single API call with an instruction like: translate the phrases, pay attention to their context, and make them fit together. It also suggests a Sheets plugin that would detect context automatically before translating. That design aims to avoid hard-coding labels such as "electricity" into every request. [#21176618]

How could this Google Sheets and AI translation workflow be adapted to make OpenBeken available in additional languages?

Use Sheets for the source string table, export CSV, generate one header per language, and then add AI-assisted review for ambiguous UI terms. The thread explicitly connects the idea to broader firmware localization and later asks whether it could become a path toward more OpenBeken languages. A practical adaptation is: keep English as the base column, fill translations across target-language columns, then generate compile-time headers exactly as shown for C/C++ firmware. That gives OpenBeken a scalable localization pipeline. [#21173109]
Generated by the language model.
ADVERTISEMENT