My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

multi_language.h 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /********************
  2. * multi_language.h *
  3. ********************/
  4. /****************************************************************************
  5. * Written By Marcio Teixeira 2019 - Aleph Objects, Inc. *
  6. * *
  7. * This program is free software: you can redistribute it and/or modify *
  8. * it under the terms of the GNU General Public License as published by *
  9. * the Free Software Foundation, either version 3 of the License, or *
  10. * (at your option) any later version. *
  11. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * To view a copy of the GNU General Public License, go to the following *
  18. * location: <http://www.gnu.org/licenses/>. *
  19. ****************************************************************************/
  20. #pragma once
  21. typedef const char Language_Str[];
  22. #if defined(LCD_LANGUAGE_5)
  23. #define NUM_LANGUAGES 5
  24. #elif defined(LCD_LANGUAGE_4)
  25. #define NUM_LANGUAGES 4
  26. #elif defined(LCD_LANGUAGE_3)
  27. #define NUM_LANGUAGES 3
  28. #elif defined(LCD_LANGUAGE_2)
  29. #define NUM_LANGUAGES 2
  30. #else
  31. #define NUM_LANGUAGES 1
  32. #endif
  33. // Setting the unused languages equal to each other allows
  34. // the compiler to optimize away the conditionals
  35. #ifndef LCD_LANGUAGE_2
  36. #define LCD_LANGUAGE_2 LCD_LANGUAGE
  37. #endif
  38. #ifndef LCD_LANGUAGE_3
  39. #define LCD_LANGUAGE_3 LCD_LANGUAGE_2
  40. #endif
  41. #ifndef LCD_LANGUAGE_4
  42. #define LCD_LANGUAGE_4 LCD_LANGUAGE_3
  43. #endif
  44. #ifndef LCD_LANGUAGE_5
  45. #define LCD_LANGUAGE_5 LCD_LANGUAGE_4
  46. #endif
  47. #define _GET_LANG(LANG) Language_##LANG
  48. #define GET_LANG(LANG) _GET_LANG(LANG)
  49. #if NUM_LANGUAGES > 1
  50. extern uint8_t lang;
  51. #define GET_TEXT(MSG) ( \
  52. lang == 0 ? GET_LANG(LCD_LANGUAGE)::MSG : \
  53. lang == 1 ? GET_LANG(LCD_LANGUAGE_2)::MSG : \
  54. lang == 2 ? GET_LANG(LCD_LANGUAGE_3)::MSG : \
  55. lang == 3 ? GET_LANG(LCD_LANGUAGE_4)::MSG : \
  56. GET_LANG(LCD_LANGUAGE_5)::MSG \
  57. )
  58. #define MAX_LANG_CHARSIZE _MAX(GET_LANG(LCD_LANGUAGE)::CHARSIZE, \
  59. GET_LANG(LCD_LANGUAGE_2)::CHARSIZE, \
  60. GET_LANG(LCD_LANGUAGE_3)::CHARSIZE, \
  61. GET_LANG(LCD_LANGUAGE_4)::CHARSIZE, \
  62. GET_LANG(LCD_LANGUAGE_5)::CHARSIZE)
  63. #else
  64. #define GET_TEXT(MSG) GET_LANG(LCD_LANGUAGE)::MSG
  65. #define MAX_LANG_CHARSIZE GET_LANG(LCD_LANGUAGE)::CHARSIZE
  66. #endif
  67. #define GET_TEXT_F(MSG) (const __FlashStringHelper*)GET_TEXT(MSG)
  68. #define MSG_CONCAT(A,B) pgm_p_pair_t(GET_TEXT(A),GET_TEXT(B))