Skip to content

Commit

Permalink
Merge pull request prusa3d#3336 from 3d-gussner/MK3_3.11.0
Browse files Browse the repository at this point in the history
Prepare for more Community languages
  • Loading branch information
DRracer authored Jan 3, 2022
2 parents 0be90dc + 6dd7681 commit 931e880
Show file tree
Hide file tree
Showing 49 changed files with 30,122 additions and 226 deletions.
19 changes: 14 additions & 5 deletions Firmware/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,22 @@
#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
#define COMMUNITY_LANG_GROUP 1

#if (COMMUNITY_LANG_GROUP == 1)
#define COMMUNITY_LANG_GROUP1_NL // Community Dutch language
#define COMMUNITY_LANG_GROUP1_SV // Community Swedish language
#define COMMUNITY_LANG_GROUP1_DA // Community Danish language
#define COMMUNITY_LANG_GROUP1_SL // Community Slovanian language
#define COMMUNITY_LANG_GROUP1_HU // Community Hungarian language
#define COMMUNITY_LANG_GROUP1_LB // Community Luxembourgish language
#define COMMUNITY_LANG_GROUP1_HR // Community Croatian language
//#define COMMUNITY_LANG_GROUP1_QR // Community new language //..use this as a template and replace 'QR'
#endif

#if (COMMUNITY_LANG_GROUP >=1 )
#define COMMUNITY_LANGUAGE_SUPPORT
#endif
// Sanity checks for correct configuration of XFLASH_DUMP options
#if defined(XFLASH_DUMP) && !defined(XFLASH)
#error "XFLASH_DUMP requires XFLASH support"
Expand Down
32 changes: 25 additions & 7 deletions Firmware/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,34 @@ const char* lang_get_name_by_code(uint16_t code)
case LANG_CODE_FR: return _n("Francais");
case LANG_CODE_IT: return _n("Italiano");
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
#ifdef COMMUNITY_LANGUAGE_SUPPORT //Community language support
#ifdef COMMUNITY_LANG_GROUP1_NL
case LANG_CODE_NL: return _n("Nederlands"); //community Dutch contribution
#endif // COMMUNITY_LANG_GROUP1_NL
#ifdef COMMUNITY_LANG_GROUP1_SV
case LANG_CODE_SV: return _n("Svenska"); //community Swedish contribution
#endif // COMMUNITY_LANG_GROUP1_SV
#ifdef COMMUNITY_LANG_GROUP1_DA
case LANG_CODE_DA: return _n("Dansk"); //community Danish contribution
#endif // COMMUNITY_LANG_GROUP1_DA
#ifdef COMMUNITY_LANG_GROUP1_SL
case LANG_CODE_SL: return _n("Slovenscina"); //community Slovanian contribution
#endif // COMMUNITY_LANG_GROUP1_SL
#ifdef COMMUNITY_LANG_GROUP1_HU
case LANG_CODE_HU: return _n("Magyar"); //community Hungarian contribution
#endif // COMMUNITY_LANG_GROUP1_HU
#ifdef COMMUNITY_LANG_GROUP1_LB
case LANG_CODE_LB: return _n("Letzebuergesch"); //community Luxembourgish contribution
#endif // COMMUNITY_LANG_GROUP1_LB
#ifdef COMMUNITY_LANG_GROUP1_HR
case LANG_CODE_HR: return _n("Hrvatski"); //community Croatian contribution
#endif // COMMUNITY_LANG_GROUP1_HR

//Use the 3 lines below as a template and replace 'QR' and 'New language'
//#ifdef COMMUNITY_LANG_QR
//#ifdef COMMUNITY_LANG_GROUP1_QR
// case LANG_CODE_QR: return _n("New language"); //community contribution
//#endif // COMMUNITY_LANG_QR
#endif // COMMUNITY_LANG_SUPPORT
//#endif // COMMUNITY_LANG_GROUP1_QR
#endif // COMMUNITY_LANGUAGE_SUPPORT
}
return _n("??");
}
Expand Down
30 changes: 24 additions & 6 deletions Firmware/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,33 @@ typedef struct
#define LANG_CODE_FR 0x6672 //!<'fr'
#define LANG_CODE_IT 0x6974 //!<'it'
#define LANG_CODE_PL 0x706c //!<'pl'
#ifdef COMMUNITY_LANG_SUPPORT //Community language support
#ifdef COMMUNITY_LANG_NL
#ifdef COMMUNITY_LANGUAGE_SUPPORT //Community language support
#ifdef COMMUNITY_LANG_GROUP1_NL
#define LANG_CODE_NL 0x6e6c //!<'nl'
#endif // COMMUNITY_LANG_NL
#endif // COMMUNITY_LANG_GROUP1_NL
#ifdef COMMUNITY_LANG_GROUP1_SV
#define LANG_CODE_SV 0x7376 //!<'sv'
#endif // COMMUNITY_LANG_GROUP1_SV
#ifdef COMMUNITY_LANG_GROUP1_DA
#define LANG_CODE_DA 0x6461 //!<'da'
#endif // COMMUNITY_LANG_GROUP1_DA
#ifdef COMMUNITY_LANG_GROUP1_SL
#define LANG_CODE_SL 0x736C //!<'sl'
#endif // COMMUNITY_LANG_GROUP1_SL
#ifdef COMMUNITY_LANG_GROUP1_HU
#define LANG_CODE_HU 0x6875 //!<'hu'
#endif // COMMUNITY_LANG_GROUP1_HU
#ifdef COMMUNITY_LANG_GROUP1_LB
#define LANG_CODE_LB 0x6C62 //!<'lb'
#endif // COMMUNITY_LANG_GROUP1_LB
#ifdef COMMUNITY_LANG_GROUP1_HR
#define LANG_CODE_HR 0x6872 //!<'hr'
#endif // COMMUNITY_LANG_GROUP1_HR
//Use the 3 lines below as a template and replace 'QR', '0X7172' and 'qr'
//#ifdef COMMUNITY_LANG_QR
//#ifdef COMMUNITY_LANG_GROUP1_QR
//#define LANG_CODE_QR 0x7172 //!<'qr'
//#endif // COMMUNITY_LANG_QR
#endif // COMMUNITY_LANG_SUPPORT
//#endif // COMMUNITY_LANG_GROUP1_QR
#endif // COMMUNITY_LANGUAGE_SUPPORT
///@}

#if defined(__cplusplus)
Expand Down
8 changes: 4 additions & 4 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4442,7 +4442,7 @@ void menu_setlang(unsigned char lang)
}
}

#ifdef COMMUNITY_LANG_SUPPORT
#ifdef COMMUNITY_LANGUAGE_SUPPORT
#ifdef XFLASH
static void lcd_community_language_menu()
{
Expand All @@ -4458,7 +4458,7 @@ static void lcd_community_language_menu()
MENU_END();
}
#endif //XFLASH
#endif //COMMUNITY_LANG_SUPPORT && W52X20CL
#endif //COMMUNITY_LANGUAGE_SUPPORT && W52X20CL



Expand Down Expand Up @@ -4492,11 +4492,11 @@ static void lcd_language_menu()
return;
}

#ifdef COMMUNITY_LANG_SUPPORT
#ifdef COMMUNITY_LANGUAGE_SUPPORT
#ifdef XFLASH
MENU_ITEM_SUBMENU_P(_T(MSG_COMMUNITY_MADE), lcd_community_language_menu); ////MSG_COMMUNITY_MADE c=18
#endif //XFLASH
#endif //COMMUNITY_LANG_SUPPORT && W52X20CL
#endif //COMMUNITY_LANGUAGE_SUPPORT && W52X20CL

MENU_END();
}
Expand Down
7 changes: 3 additions & 4 deletions PF-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE
# it will use the default Arduino IDE folders and so can corrupt the build environment.
#
# Version: 2.0.0-Build_63
# Version: 2.0.0-Build_66
# Change log:
# 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt'
# 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown
Expand Down Expand Up @@ -165,6 +165,7 @@
# 23 Jun 2021, 3d-gussner, Improve MK404 usage
# 24 Jun 2021, 3d-gussner, Fix MK404 user interaction not to show if compiling 'All' variants
# 24 Jun 2021, 3d-gussner, MK404 is only supported on Linux at this moment.
# 03 Jan 2022, 3d-gussner, Remove calling lang-community.sh as not needed anymore

SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"

Expand Down Expand Up @@ -220,7 +221,7 @@ while getopts b:c:d:g:h:i:j:l:m:n:o:p:v:x:y:?h flag
# '?' 'h' argument usage and help
if [ "$help_flag" == "1" ] ; then
echo "***************************************"
echo "* PF-build.sh Version: 2.0.0-Build_63 *"
echo "* PF-build.sh Version: 2.0.0-Build_66 *"
echo "***************************************"
echo "Arguments:"
echo "$(tput setaf 2)-b$(tput sgr0) Build/commit number"
Expand Down Expand Up @@ -1302,8 +1303,6 @@ create_multi_firmware()
# build languages
echo "$(tput setaf 3)"
./lang-build.sh || failures 25
# build community languages
./lang-community.sh || failures 25
# Combine compiled firmware with languages
./fw-build.sh || failures 25
cp not_tran.txt not_tran_$VARIANT.txt
Expand Down
33 changes: 31 additions & 2 deletions lang/config.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh
#!/bin/bash
#
# config.sh - multi-language support configuration script
# Definition of absolute paths etc.
# This file is 'included' in all scripts.
#
# Arduino main folder:
if [ -z "$ARDUINO" ]; then
export ARDUINO=C:/arduino-1.8.5
export ARDUINO=../../PF-build-env-1.0.6/1.8.5-1.0.4-linux-64 #C:/arduino-1.8.5
fi
#
# Arduino builder:
Expand All @@ -29,7 +29,30 @@ export INOELF="$OUTDIR/Firmware.ino.elf"
#
# Generated hex file:
export INOHEX="$OUTDIR/Firmware.ino.hex"
#
# Set default languages
if [ -z "$LANGUAGES" ]; then
export LANGUAGES="cz de es fr it pl"
fi
#
# Check for community languages
MAX_COMMINITY_LANG=10 # Total 16 - 6 default
COMMUNITY_LANGUAGES=""
#Search Firmware/config.h for active community group
COMMUNITY_LANG_GROUP=$(grep --max-count=1 "^#define COMMUNITY_LANG_GROUP" ../Firmware/config.h| cut -d ' ' -f3)

# Search Firmware/config.h for active community languanges
if [ "$COMMUNITY_LANG_GROUP" = "1" ]; then
COMMUNITY_LANGUAGES=$(grep --max-count=$MAX_COMMINITY_LANG "^#define COMMUNITY_LANG_GROUP1_" ../Firmware/config.h| cut -d '_' -f4 |cut -d ' ' -f1 |tr '[:upper:]' '[:lower:]'| tr '\n' ' ')
elif [ "$COMMUNITY_LANG_GROUP" = "2" ]; then
COMMUNITY_LANGUAGES=$(grep --max-count=$MAX_COMMINITY_LANG "^#define COMMUNITY_LANG_GROUP2_" ../Firmware/config.h| cut -d '_' -f4 |cut -d ' ' -f1 |tr '[:upper:]' '[:lower:]'| tr '\n' ' ')
elif [ "$COMMUNITY_LANG_GROUP" = "3" ]; then
COMMUNITY_LANGUAGES=$(grep --max-count=$MAX_COMMINITY_LANG "^#define COMMUNITY_LANG_GROUP3_" ../Firmware/config.h| cut -d '_' -f4 |cut -d ' ' -f1 |tr '[:upper:]' '[:lower:]'| tr '\n' ' ')
fi

if [ -z "$COMMUNITY_LANGUAGES" ]; then
export COMMUNITY_LANGUAGES="$COMMUNITY_LANGUAGES"
fi

echo "config.sh started" >&2

Expand Down Expand Up @@ -59,6 +82,12 @@ if [ -e $INOELF ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=7; fi
echo -n " Generated hex file: " >&2
if [ -e $INOHEX ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=8; fi

echo -n " Languages: " >&2
echo "$LANGUAGES" >&2

echo -n " Community languages: " >&2
echo "$COMMUNITY_LANGUAGES" >&2

if [ $_err -eq 0 ]; then
echo "config.sh finished with success" >&2
export CONFIG_OK=1
Expand Down
80 changes: 20 additions & 60 deletions lang/fw-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ LNG=$1
# Params:
IGNORE_MISSING_TEXT=1

# List of supported languages
if [ -z "$LANGUAGES" ]; then
LANGUAGES="cz de es fr it pl"
fi

# Community languages
if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "fw-build languages:$LANGUAGES" >&2

finish()
{
Expand Down Expand Up @@ -133,70 +143,20 @@ if [ ! -z "$LNG" ]; then
finish 0
else
echo "Updating languages:" >&2
if [ -e lang_cz.bin ]; then
echo -n " Czech : " >&2
./update_lang.sh cz 2>./update_lang_cz.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_de.bin ]; then
echo -n " German : " >&2
./update_lang.sh de 2>./update_lang_de.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_it.bin ]; then
echo -n " Italian: " >&2
./update_lang.sh it 2>./update_lang_it.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_es.bin ]; then
echo -n " Spanish: " >&2
./update_lang.sh es 2>./update_lang_es.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_fr.bin ]; then
echo -n " French : " >&2
./update_lang.sh fr 2>./update_lang_fr.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
if [ -e lang_pl.bin ]; then
echo -n " Polish : " >&2
./update_lang.sh pl 2>./update_lang_pl.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
#Community language support
#Dutch
if [ -e lang_nl.bin ]; then
echo -n " Dutch : " >&2
./update_lang.sh nl 2>./update_lang_nl.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
fi

#Use the 6 lines below as a template and replace 'qr' and 'New language'
#New language
# if [ -e lang_qr.bin ]; then
# echo -n " New language : " >&2
# ./update_lang.sh qr 2>./update_lang_qr.out 1>/dev/null
# if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
# fi

# echo "skipped" >&2
for lang in $LANGUAGES; do
if [ -e lang_$lang.bin ]; then
echo -n " $lang : " >&2
./update_lang.sh $lang 2>./update_lang_$lang.out 1>/dev/null
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; finish 1; fi
fi
done
fi

#create binary file with all languages
rm -f lang.bin
if [ -e lang_cz.bin ]; then cat lang_cz.bin >> lang.bin; fi
if [ -e lang_de.bin ]; then cat lang_de.bin >> lang.bin; fi
if [ -e lang_es.bin ]; then cat lang_es.bin >> lang.bin; fi
if [ -e lang_fr.bin ]; then cat lang_fr.bin >> lang.bin; fi
if [ -e lang_it.bin ]; then cat lang_it.bin >> lang.bin; fi
if [ -e lang_pl.bin ]; then cat lang_pl.bin >> lang.bin; fi
#Community language support
# Dutch
if [ -e lang_nl.bin ]; then cat lang_nl.bin >> lang.bin; fi

#Use the 2 lines below as a template and replace 'qr'
## New language
#if [ -e lang_qr.bin ]; then cat lang_qr.bin >> lang.bin; fi
for lang in $LANGUAGES; do
if [ -e lang_$lang.bin ]; then cat lang_$lang.bin >> lang.bin; fi
done

# Check that the language data doesn't exceed the reserved XFLASH space
echo " checking language data size:"
Expand Down
34 changes: 14 additions & 20 deletions lang/fw-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
# Remove all firmware output files from lang folder.
#

# Config:
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi

if [ ! -z "$COMMUNITY_LANGUAGES" ]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
fi
echo "fw-clean languages:$LANGUAGES" >&2

result=0

rm_if_exists()
Expand Down Expand Up @@ -31,32 +40,17 @@ rm_if_exists progmem1.txt
rm_if_exists textaddr.txt
rm_if_exists firmware.bin
rm_if_exists firmware.hex
rm_if_exists firmware_cz.hex
rm_if_exists firmware_de.hex
rm_if_exists firmware_es.hex
rm_if_exists firmware_fr.hex
rm_if_exists firmware_it.hex
rm_if_exists firmware_pl.hex
rm_if_exists progmem.out
rm_if_exists textaddr.out
rm_if_exists update_lang.out
rm_if_exists update_lang_cz.out
rm_if_exists update_lang_de.out
rm_if_exists update_lang_es.out
rm_if_exists update_lang_fr.out
rm_if_exists update_lang_it.out
rm_if_exists update_lang_pl.out
rm_if_exists lang.bin
rm_if_exists lang.hex
#Community language support
#Dutch
rm_if_exists firmware_nl.hex
rm_if_exists update_lang_nl.out

#Use the 2 lines below as a template and replace 'qr'
##New language
#rm_if_exists firmware_qr.hex
#rm_if_exists update_lang_qr.out

for lang in $LANGUAGES; do
rm_if_exists firmware_$lang.hex
rm_if_exists update_lang_$lang.out
done

echo -n "fw-clean.sh finished" >&2
if [ $result -eq 0 ]; then
Expand Down
Loading

0 comments on commit 931e880

Please sign in to comment.