Skip to content

Commit

Permalink
Life saver: update locale generation
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftFever committed Sep 5, 2023
1 parent 86f51cd commit 76d59ac
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 12 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/check_locale.yml
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ SVG
src/OrcaSlicer-doc/
.idea/
/.cache/
*.mo
7 changes: 2 additions & 5 deletions BuildLinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions build_release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions build_release_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions build_release_vs2022.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 removed resources/i18n/cs/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/de/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/en/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/es/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/fr/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/hu/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/it/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/ja/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/ko/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/nl/OrcaSlicer.mo
Binary file not shown.
Empty file added resources/i18n/placeholder.txt
Empty file.
Binary file removed resources/i18n/ru/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/sv/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/tr/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/uk/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/zh_TW/OrcaSlicer.mo
Binary file not shown.
Binary file removed resources/i18n/zh_cn/OrcaSlicer.mo
Binary file not shown.
19 changes: 15 additions & 4 deletions run_gettext.bat
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
21 changes: 18 additions & 3 deletions run_gettext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 76d59ac

Please sign in to comment.