Jomelo / LCDMenuLib2

Create a tree menu. Use it with different lcd types / console output / ssh console.
MIT License
249 stars 46 forks source link

Change language doesnt do what I want #88

Closed vjeko2404 closed 1 year ago

vjeko2404 commented 1 year ago

Hi all!

First of all, I wanted to thank you for the great library! Its really beyond my expectations! Perhaps someone could help me with using more than one language:

my menus are defined as following (an example): LCDML_add(2, LCDML_0_1, 2, "Automatikmodus aus", NULL); LCDML_langDef(2, EN, "Automatic mode off"); LCDML_langDef(2, KR, "Iskljuci auto. nacin");

furthermore are the additional language objects made: LCDML_createCustomLang(_LCDML_DISP_cnt, EN); LCDML_createCustomLang(_LCDML_DISP_cnt, KR);

But when I change the lang_types g_lcdml_lang_select = LANG_EN; to LANG_EN or to LANG_KR, the LCD show always only the default language (LANG=DE). No matter what I do, it's always default language showed.

I saw that the example with serial control works as intended and I tryed to implement the change language into the LCD example but no avail. I would appreciate if you could give me some guides, what could I try next to get the code to work. It compiles without errors, all functions are working except the language change.

Just to be clear, doesnt matter if I change the lang_types g_lcdml_lang_select = LANG_EN; in the code or over the commands -> Default language ALWAYS prevails.

Thank you kindly for any kind of help!

EDIT: Forgot to say that Im using encoder control (works perfectly fine) and 20x4 LCD...don't know if that makes any difference...

EDIT_2: seems like there is nothing wrong with the library. I just can't manage to implement the multi language code from the example into the LCD i2C 20x4 example... If anyone can help or if anyone has managed to bind multi language into the LCD example, I would be grateful for the example code.

vjeko2404 commented 1 year ago

Solved it with global int.

` if ((tmp = LCDML.MENU_getDisplayedObj()) != NULL) { // Loop zur Anzeige von Zeilen und Sprachen do { if (tmp->checkCondition()) { if (tmp->checkType_menu() == true) { switch (sprache) {

          case 1:
            LCDML_getContent(content_text, tmp->getID());
            lcd.setCursor(1, n);
            lcd.print(content_text);
            break;

          case 2:
            LCDML_getCustomContent(EN, content_text, tmp->getID());
            lcd.setCursor(1, n);
            lcd.print(content_text);
            break;

          case 3:
            LCDML_getCustomContent(KR, content_text, tmp->getID());
            lcd.setCursor(1, n);
            lcd.print(content_text);
            break;
        }
        if (tmp->checkType_dynParam()) {
          tmp->callback(n);
        }
      }
      i++;
      n++;
    }
  } while (((tmp = tmp->getSibling(1)) != NULL) && (i < maxi));
}

} `

Great stuff this library of yours! Thank you so much for your work!