Browse Source

Add defines and templates for community languages
Add `Community made` submenu to `Select language`

3d-gussner 3 years ago
parent
commit
6d7d9089f7
6 changed files with 56 additions and 3 deletions
  1. 7 0
      Firmware/config.h
  2. 10 1
      Firmware/language.c
  3. 9 1
      Firmware/language.h
  4. 1 0
      Firmware/messages.c
  5. 1 0
      Firmware/messages.h
  6. 28 1
      Firmware/ultralcd.cpp

+ 7 - 0
Firmware/config.h

@@ -68,5 +68,12 @@
 
 #define LANG_SIZE_RESERVED     0x3000 // reserved space for secondary language (12288 bytes)
 
+//Community language support
+#define COMMUNITY_LANG_NL // Community Dutch language
+//#define COMMUNITY_LANG_QR // Community new language //..use this as a template and replace 'QR'
+
+#if defined(COMMUNITY_LANG_NL) //|| defined(COMMUNITY_LANG_QR) //..use last part as a template and replace 'QR'
+#define COMMUNITY_LANG_SUPPORT
+#endif
 
 #endif //_CONFIG_H

+ 10 - 1
Firmware/language.c

@@ -209,8 +209,17 @@ const char* lang_get_name_by_code(uint16_t code)
 	case LANG_CODE_ES: return _n("Espanol");
 	case LANG_CODE_FR: return _n("Francais");
 	case LANG_CODE_IT: return _n("Italiano");
-	case LANG_CODE_NL: return _n("Nederlands"); //community contribution
 	case LANG_CODE_PL: return _n("Polski");
+#ifdef COMMUNITY_LANG_SUPPORT //Community language support
+#ifdef COMMUNITY_LANG_NL
+	case LANG_CODE_NL: return _n("Nederlands"); //community contribution
+#endif // COMMUNITY_LANG_NL
+
+//Use the 3 lines below as a template and replace 'QR' and 'New language'
+//#ifdef COMMUNITY_LANG_QR 
+//	case LANG_CODE_QR: return _n("New language"); //community contribution
+//#endif // COMMUNITY_LANG_QR
+#endif // COMMUNITY_LANG_SUPPORT
 	}
 	return _n("??");
 }

+ 9 - 1
Firmware/language.h

@@ -95,8 +95,16 @@ typedef struct
 #define LANG_CODE_ES 0x6573 //!<'es'
 #define LANG_CODE_FR 0x6672 //!<'fr'
 #define LANG_CODE_IT 0x6974 //!<'it'
-#define LANG_CODE_NL 0x6e6c //!<'nl'
 #define LANG_CODE_PL 0x706c //!<'pl'
+#ifdef COMMUNITY_LANG_SUPPORT //Community language support
+#ifdef COMMUNITY_LANG_NL
+#define LANG_CODE_NL 0x6e6c //!<'nl'
+#endif // COMMUNITY_LANG_NL
+//Use the 3 lines below as a template and replace 'QR', '0X7172' and 'qr'
+//#ifdef COMMUNITY_LANG_QR
+//#define LANG_CODE_QR 0x7172 //!<'qr'
+//#endif // COMMUNITY_LANG_QR
+#endif // COMMUNITY_LANG_SUPPORT
 ///@}
 
 #if defined(__cplusplus)

+ 1 - 0
Firmware/messages.c

@@ -21,6 +21,7 @@ const char MSG_CALIBRATE_Z_AUTO[] PROGMEM_I1 = ISTR("Calibrating Z"); ////c=20 r
 const char MSG_CARD_MENU[] PROGMEM_I1 = ISTR("Print from SD"); ////
 const char MSG_CHECKING_X[] PROGMEM_I1 = ISTR("Checking X axis"); ////c=20
 const char MSG_CHECKING_Y[] PROGMEM_I1 = ISTR("Checking Y axis"); ////c=20
+const char MSG_COMMUNITY_MADE[] PROGMEM_I1 = ISTR("Community made"); ////c=18
 const char MSG_CONFIRM_NOZZLE_CLEAN[] PROGMEM_I1 = ISTR("Please clean the nozzle for calibration. Click when done."); ////c=20 r=8
 const char MSG_COOLDOWN[] PROGMEM_I1 = ISTR("Cooldown"); ////
 const char MSG_CRASH[] PROGMEM_I1 = ISTR("Crash"); ////c=7

+ 1 - 0
Firmware/messages.h

@@ -22,6 +22,7 @@ extern const char MSG_CALIBRATE_Z_AUTO[];
 extern const char MSG_CARD_MENU[];
 extern const char MSG_CHECKING_X[];
 extern const char MSG_CHECKING_Y[];
+extern const char MSG_COMMUNITY_MADE[];
 extern const char MSG_CONFIRM_NOZZLE_CLEAN[];
 extern const char MSG_COOLDOWN[];
 extern const char MSG_CRASH[];

+ 28 - 1
Firmware/ultralcd.cpp

@@ -4550,6 +4550,26 @@ void menu_setlang(unsigned char lang)
 	}
 }
 
+#ifdef COMMUNITY_LANG_SUPPORT
+#ifdef W25X20CL
+static void lcd_community_language_menu()
+{
+	MENU_BEGIN();
+	uint8_t cnt = lang_get_count();
+	if (lang_is_selected()) MENU_ITEM_BACK_P(_i("Select language")); //Back to previous Menu
+	for (int i = 8; i < cnt; i++) //all community languages
+		if (menu_item_text_P(lang_get_name_by_code(lang_get_code(i))))
+		{
+			menu_setlang(i);
+			return;
+		}
+	MENU_END();
+}
+#endif //W25X20CL
+#endif //COMMUNITY_LANG_SUPPORT && W52X20CL
+
+
+
 static void lcd_language_menu()
 {
 	MENU_BEGIN();
@@ -4570,7 +4590,7 @@ static void lcd_language_menu()
 		}
 	}
 	else
-		for (int i = 2; i < cnt; i++) //skip seconday language - solved in lang_select (MK3)
+		for (int i = 2; i < 8; i++) //skip seconday language - solved in lang_select (MK3) 'i < 8'  for 7 official languages
 #else //W25X20CL
 		for (int i = 1; i < cnt; i++) //all seconday languages (MK2/25)
 #endif //W25X20CL
@@ -4579,6 +4599,13 @@ static void lcd_language_menu()
 				menu_setlang(i);
 				return;
 			}
+
+#ifdef COMMUNITY_LANG_SUPPORT
+#ifdef W25X20CL
+		MENU_ITEM_SUBMENU_P(_T(MSG_COMMUNITY_MADE), lcd_community_language_menu); ////MSG_COMMUNITY_MADE c=18
+#endif //W25X20CL
+#endif //COMMUNITY_LANG_SUPPORT && W52X20CL
+
 	MENU_END();
 }
 #endif //(LANG_MODE != 0)