orcaslicer/run_gettext.sh
Dzmitry Neviadomski 7b31ee3a45
ENH: Improve macOS build script (#4310)
* ENH: Improve macOS build script

 - Update shebang to bash, as it is already expected to be present in
   run_gettext.sh
 - Added fail-fast shell options.
 - Changed default CMake generator to Ninja
 - Adopted configuration for non-multi-config generators (Ninja, Make)
 - Added new options:
   - Allow to set CMake generator back to Xcode, no option for make
     thou.
   - Allow to build without reconfiguring CMake, improves build times.
     Unnecessary Cmake reconfigurations require full rebuild.
   - Allow to set build configuration for CMake
 - Reorganized targets into separate function to break "cd" dependency.
 - Reformat shell code.
 - Fix all warnings reported by ShellCheck linter tool.
 - Update run_gettext.sh to respect build dir in full mode.

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* FIX: Install ninja with brew on CI.

Test if building works with Ninja by default.

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* ENH: Set Xcode back as default generator.

Use Ninja on CI with explicit option.

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* FIX: Partially revent changes in run_gettext.sh

Revert changes for option parsing.
Leave fixes for issues found by ShellCheck linter tool.

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

---------

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
2024-03-05 22:35:46 +08:00

41 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
# OrcaSlicer gettext
# Created by SoftFever on 27/5/23.
#
# Check for --full argument
FULL_MODE=false
for arg in "$@"
do
if [ "$arg" = "--full" ]; then
FULL_MODE=true
fi
done
if $FULL_MODE; then
xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost -f ./localization/i18n/list.txt -o ./localization/i18n/OrcaSlicer.pot
./build_arm64/src/hints/Release/hintsToPot.app/Contents/MacOS/hintsToPot ./resources ./localization/i18n
fi
echo "$0: working dir = $PWD"
pot_file="./localization/i18n/OrcaSlicer.pot"
for dir in ./localization/i18n/*/
do
dir=${dir%*/} # remove the trailing "/"
lang=${dir##*/} # extract the language identifier
if [ -f "$dir/OrcaSlicer_${lang}.po" ]; then
if $FULL_MODE; then
msgmerge -N -o "$dir/OrcaSlicer_${lang}.po" "$dir/OrcaSlicer_${lang}.po" "$pot_file"
fi
mkdir -p "resources/i18n/${lang}"
msgfmt --check-format -o "resources/i18n/${lang}/OrcaSlicer.mo" "$dir/OrcaSlicer_${lang}.po"
# Check the exit status of the msgfmt command
if [ $? -ne 0 ]; then
echo "Error encountered with msgfmt command for language ${lang}."
exit 1 # Exit the script with an error status
fi
fi
done