Life saver: update locale generation

This commit is contained in:
SoftFever 2023-09-05 22:36:29 +08:00
parent 86f51cd9d0
commit 76d59ac033
25 changed files with 71 additions and 12 deletions

26
.github/workflows/check_locale.yml vendored Normal file
View file

@ -0,0 +1,26 @@
name: Check locale
on:
pull_request:
branches:
- main
paths:
- 'localization/**'
- ".github/workflows/check_locale.yml"
jobs:
publish_docs_to_wiki:
name: Publish docs to Wiki
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install gettext
run: |
sudo apt-get update
sudo apt-get install -y gettext
- name: Check translation format
run: |
./run_gettext.sh

1
.gitignore vendored
View file

@ -26,3 +26,4 @@ SVG
src/OrcaSlicer-doc/
.idea/
/.cache/
*.mo

View file

@ -81,7 +81,7 @@ export REQUIRED_DEV_PACKAGES="libmspack-dev libgstreamerd-3-dev libsecret-1-dev
# libwebkit2gtk-4.1-dev ??
export DEV_PACKAGES_COUNT=$(echo ${REQUIRED_DEV_PACKAGES} | wc -w)
if [ $(dpkg --get-selections | grep -E "$(echo ${REQUIRED_DEV_PACKAGES} | tr ' ' '|')" | wc -l) -lt ${DEV_PACKAGES_COUNT} ]; then
sudo apt install -y ${REQUIRED_DEV_PACKAGES} git cmake wget file
sudo apt install -y ${REQUIRED_DEV_PACKAGES} git cmake wget file gettext
fi
#FIXME: require root for -u option
@ -230,11 +230,8 @@ then
# make Slic3r
echo "[8/9] Building Slic3r..."
make -j$NCORES OrcaSlicer # Slic3r
# make .mo
# make gettext_po_to_mo # FIXME: DeftDawg: complains about msgfmt not existing even in SuperSlicer, did this ever work?
popd
run_gettext.sh
echo "done"
fi

View file

@ -20,4 +20,7 @@ cd build
cmake .. -G "Visual Studio 16 2019" -DBBL_RELEASE_TO_PUBLIC=1 -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./OrcaSlicer" -DCMAKE_BUILD_TYPE=Release -DWIN10SDK_PATH="C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0"
cmake --build . --config Release --target ALL_BUILD -- -m
cd ..
run_gettext.bat
cd build
cmake --build . --target install --config Release

View file

@ -78,6 +78,9 @@ cd build_$ARCH
echo "building slicer..."
cmake .. -GXcode -DBBL_RELEASE_TO_PUBLIC=1 -DCMAKE_PREFIX_PATH="$DEPS/usr/local" -DCMAKE_INSTALL_PREFIX="$PWD/OrcaSlicer" -DCMAKE_BUILD_TYPE=Release -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="$DEPS/usr/local" -DCMAKE_MACOSX_BUNDLE=ON -DCMAKE_OSX_ARCHITECTURES=${ARCH}
cmake --build . --config Release --target ALL_BUILD
cd ..
run_gettext.sh
cd build_$ARCH
mkdir -p OrcaSlicer
cd OrcaSlicer
rm -r ./OrcaSlicer.app

View file

@ -20,4 +20,7 @@ cd build
cmake .. -G "Visual Studio 17 2022" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./OrcaSlicer" -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release --target ALL_BUILD -- -m
cd ..
run_gettext.bat
cd build
cmake --build . --target install --config Release

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,9 +1,17 @@
@echo off
REM OrcaSlicer gettext
REM Created by SoftFever on 27/5/23.
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\src\hints\Release\hintsToPot ./resources ./localization/i18n
REM Check for --full argument
set FULL_MODE=0
for %%a in (%*) do (
if "%%a"=="--full" set FULL_MODE=1
)
if %FULL_MODE%==1 (
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/src/hints/Release/hintsToPot ./resources ./localization/i18n
)
REM Print the current directory
echo %cd%
set pot_file="./localization/i18n/OrcaSlicer.pot"
@ -19,6 +27,9 @@ goto :eof
set "dir=%~dp1"
set "name=%~n1"
set "lang=%name:OrcaSlicer_=%"
msgmerge -N -o "%file%" "%file%" "%pot_file%"
msgfmt --check-format -o "./resources/i18n/%lang%/OrcaSlicer.mo" "%file%"
if %FULL_MODE%==1 (
msgmerge -N -o "%file%" "%file%" "%pot_file%"
)
if not exist ./resources/i18n/%lang% mkdir ./resources/i18n/%lang%
msgfmt -o "./resources/i18n/%lang%/OrcaSlicer.mo" "%file%"
goto :eof

View file

@ -3,8 +3,20 @@
# OrcaSlicer gettext
# Created by SoftFever on 27/5/23.
#
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
# 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 $PWD
@ -15,7 +27,10 @@ do
lang=${dir##*/} # extract the language identifier
if [ -f "$dir/OrcaSlicer_${lang}.po" ]; then
msgmerge -N -o $dir/OrcaSlicer_${lang}.po $dir/OrcaSlicer_${lang}.po $pot_file
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
fi
done