Translate OLED Texts

Hi,

is there a library or best practice to support translation of e.g. OLED texts like babel with python? I like to provide different languages to be selected and optimize the handling.

Regards,
Nils

Do you mean to display text in different languages on an OLED?

If so, what languages and character fonts do you plan to use?

To my knowledge, I have not seen one; my belief is you would need to code the non-English display "text" strings yourself. You could keep multiple strings in flash in array-like fashion and allow the end-user to select the language off-set.
Arduino character arrays stored in flash at DuckDuckGo

Alternately, you can use compiler pre-processor directives to create a single binary that is language-specific; that is:
(see #ifdef and #ifndef)
Arduino Preprocessor Directives Tutorial - ifdef & endif (deviceplus.com)

Don't forget that the OLED requires a font library for each language character set.

I don't write it's best practice but that's the way I do to switch languages at compile time:

  • Each printout get its own #define text or char constant.
  • all #define of one language come together in one text_en.h file (in a separate tab),
  • at the end of the development I make a copy of the language file to my target language rename it to text_ge.h and translate the content.
  • finally I include either text_en.h or text_ge.h

short example of such a include file:

/* *******************************************************************
   all Text definitions
   ***************************************************************** */

#define TXT_ISO_LANGUAGE       "de"
#define TXT_LIQUID_INGESTION   "Flüssigkeitsaufnahme"
#define TXT_LIQUID_TOTAL       "Gesamt"
#define TXT_LIQUID_TOTAL_SHORT "Sum"

const char  *txtLiquid[]        = {"Wasser", "Kaffee","Sonstiges"};  
const char  *txtLiquidShort[]   = {"Was", "Kaf", "Son"};             

The characterset is actually not a problem. Its german and english language I like to provide for selection via webgui. I am looking for something like a global var lang and the definition in one.

What do you think about this? :

byte lang = 1  <- 0: german, 1: english,...
const char  *txtLiquid[]        = {"Wasser", "Water"};  

void printOled() 
{
    printBlaBla(*txtLiquid[lang]);
}

@noiasca : Why do you define the array as a pointer? (Never done that in my hobby projects so I am not familiar with that...)

old dogs don't learn new tricks. It works. No need for a change. Its just an array of "strings".

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.