make_lang_na.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. #
  3. # make_lang_na.sh
  4. #
  5. # Create non-accented language files given a list of accented language files.
  6. #
  7. which gsed >/dev/null || { echo "gsed is required for this script." ; exit 1 ; }
  8. which perl >/dev/null || { echo "perl is required for this script." ; exit 1 ; }
  9. #
  10. # Get language arguments
  11. #
  12. [ $# ] || { echo "One or more language codes (such as 'fr') must be supplied." ; exit 1 ; }
  13. LANG_ARG="$@"
  14. #
  15. # Change to working directory 'Marlin'
  16. #
  17. OLDWD=`pwd`
  18. [[ $(basename "$OLDWD") != 'Marlin' && -d "Marlin" ]] && cd Marlin
  19. [[ -f "Configuration.h" ]] || { echo -n "cd to the 'Marlin' folder to run " ; basename $0 ; exit 1; }
  20. #
  21. # Generate a non-accented language file
  22. #
  23. for ALANG in $LANG_ARG ; do
  24. echo "Generating a non-accented language for '${ALANG}'" >&2
  25. OUTFILE=src/lcd/language/language_${ALANG}_na.h
  26. cp src/lcd/language/language_${ALANG}.h $OUTFILE
  27. perl -pi -e 's/\s*#define DISPLAY_CHARSET_.+\n*//g' $OUTFILE
  28. perl -pi -e 's/\s*constexpr .+ CHARSIZE.+\n*//g' $OUTFILE
  29. perl -pi -e "s/namespace Language_${ALANG}/#define DISPLAY_CHARSET_ISO10646_1\n#define NOT_EXTENDED_ISO10646_1_5X7\n\nnamespace Language_${ALANG}_na/" $OUTFILE
  30. gsed -i 'y/āáǎàâäēéěèêīíǐìïîōóǒòöôūúǔùǖǘǚǜüûĀÁǍÀĒÉĚÈÊĪÍǏÌÎŌÓǑÒÔŪÚǓÙǕǗǙǛÜÛÇçÑñ/aaaaaaeeeeeiiiiiioooooouuuuuuuuuuAAAAEEEEEIIIIIOOOOOUUUUUUUUUUCcNn/' $OUTFILE
  31. perl -pi -e 's/ß/ss/g' $OUTFILE
  32. done
  33. cd "$OLDWD"