Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
ci: 測試新覆蓋腳本
Browse files Browse the repository at this point in the history
  • Loading branch information
xMikux committed Oct 16, 2022
1 parent 6d0f56f commit c3baac3
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 88 deletions.
44 changes: 44 additions & 0 deletions .github/scripts/assets_folder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

list_dir () {
find ../assets/ -maxdepth 1 -type d -exec echo "$1" \; > "$2"
}

readme_generate () {
file_name=readme_result.md
list_dir '<li>{}</li>' $file_name
sed -i "s+<li>../assets/</li>++" $file_name
sed -i "s+<li>../assets/minecraft</li>++" $file_name
sed -i "s+../assets/++" $file_name
sed -i "/^$/d" $file_name
}

modslist_generate () {
file_name=modslist_result.md
list_dir '| {} | :x: | |' $file_name
sed -i "1s+| ../assets/ | :x: | |++" $file_name
sed -i "s+| {} | ../assets/minecraft | :x: | |++" $file_name
sed -i "s+../assets/++" $file_name
sed -i "/^$/d" $file_name
}

modslist_added_generate () {
file_name=modslist_result.md
x_placeholder=" | :x: | |"
x_x_placeholder=" | :x: |"
question_placeholder=" | :question: |"
check_placeholder=" | :heavy_check_mark: |"
# sed -i "s+MODNAME$x_placeholder+MODNAME$check_placeholder [已回饋]() |+" $file_name

sed -i "s+screencapper$x_placeholder+screencapper$check_placeholder [已回饋](https://github.com/Deftu/Screencapper/pull/6),但翻譯有變動,需再度 PR |+" $file_name
sed -i "s+sodium$x_placeholder+sodium$x_x_placeholder 由於 Crowdin 並未連上主專案進行同步翻譯 |+" $file_name
sed -i "s+sodium-extra$x_placeholder+sodium-extra$check_placeholder 已提交上 Crowdin |+" $file_name
sed -i "s+automodpack$x_placeholder+automodpack$check_placeholder [已回饋](https://github.com/Skidamek/AutoModpack/pull/64) |+" $file_name
sed -i "s+energymeter$x_placeholder+energymeter$question_placeholder [等待合併](https://github.com/AlmostReliable/energymeter-forge/pull/26) |+" $file_name
sed -i "s+fluxnetworks$x_placeholder+fluxnetworks$check_placeholder [已回饋](https://github.com/SonarSonic/Flux-Networks/pull/482),需要更新。 |+" $file_name
sed -i "s+trashcans$x_placeholder+trashcans$question_placeholder [等待合併](https://github.com/SuperMartijn642/TrashCans/pull/20) |+" $file_name
}

readme_generate
modslist_generate
modslist_added_generate
179 changes: 179 additions & 0 deletions .github/scripts/override_mods.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#!/bin/bash

# shellcheck disable=2271,2260,2086

echo ">>> 模組翻譯覆蓋腳本 <<<"
echo ">>> 某些模組的翻譯如果搭配其他翻譯包"
echo ">>> 所使用會將翻譯好的內容變成未翻譯"
echo ">>> 此步驟將會把一些已知的模組翻譯覆蓋掉"

home () {
cd "$GITHUB_WORKSPACE" || exit
}

mk_workdir () {
mkdir workdir
cd workdir || exit
}

rm_workdir () {
rm -r workdir
}

mega_override () {
mk_workdir
pwd

echo "小資訊:"
echo "megatools 並不知道原始連結是甚麼"
echo "這邊有一個修正連結的問題 https://github.com/megous/megatools/issues/157#issuecomment-615835778"

echo "安裝 megatools..."
sudo apt-get update
sudo apt-get install -y megatools

echo "覆蓋 $1..."

echo "設置 $2 路徑變數"
PATH_MEGA=$3

echo "下載 $1..."
megadl "$4"

echo "解壓縮 $5"
unzip "$5"

echo "回到工作目錄..."
cd ..

echo "移動 $1 的翻譯內容..."
mv workdir/$PATH_MEGA assets

echo "檢查 $1 覆蓋內容是否存在"
if [ -f "$PATH_MEGA/lang/zh_tw.json" ]; then
echo "翻譯存在!"
else
echo "錯誤!覆蓋 $1 翻譯失敗。"
exit 1
fi

echo "完成 $1 覆蓋!清理工作資料夾"
rm_workdir
}


mediafire_override () {
mk_workdir

echo "覆蓋 $1..."

echo "設置 $1 路徑變數"
PATH_MEDIAFIRE=$2

echo "下載 $1"
wget "$(wget -qO - "$3" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')"

echo "取出 $1 翻譯檔"
$JAVA_HOME_17_X64/bin/jar xf $4 $PATH_MEDIAFIRE/zh_tw.json

echo "回到工作目錄..."
cd ..

echo "創建 $1 語言資料夾..."
mkdir -p $PATH_MEDIAFIRE

echo "複製 $1 的翻譯內容..."
cp workdir/$PATH_MEDIAFIRE/zh_tw.json $PATH_MEDIAFIRE/

echo "檢查 $1 覆蓋內容是否存在"
if [ -f "$PATH_MEDIAFIRE/zh_tw.json" ]; then
echo "翻譯存在!"
else
echo "錯誤!覆蓋 $1 翻譯失敗。"
exit 1
fi

echo "完成 $1 覆蓋!清理工作資料夾"
rm_workdir
}


mediafire_tinker_override () {
mk_workdir

echo "覆蓋 $1..."

echo "設置 $1 路徑變數"
PATH_MEDIAFIRE_TINKER=$2
PATH_MEDIAFIRE_TINKER_BOOKS=$3

echo "下載 $1"
wget "$(wget -qO - "$4" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')"

echo "解壓縮 $1 Jar"
$JAVA_HOME_17_X64/bin/jar xf $5

echo "回到工作目錄..."
cd ..

echo "創建 $1 語言資料夾..."
mkdir -p $PATH_MEDIAFIRE_TINKER

echo "複製 $1 的翻譯內容..."
cp workdir/$PATH_MEDIAFIRE_TINKER/zh_tw.json $PATH_MEDIAFIRE_TINKER/

echo "創建 $1 書本資料夾"
mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/tinkers_gadgetry
mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/puny_smelting
mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/mighty_smelting
mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/materials_and_you
mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/fantastic_foundry
mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/encyclopedia

echo "複製 $1 的書本內容..."
cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/tinkers_gadgetry/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/tinkers_gadgetry
cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/puny_smelting/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/puny_smelting
cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/mighty_smelting/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/mighty_smelting
cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/materials_and_you/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/materials_and_you
cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/fantastic_foundry/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/fantastic_foundry
cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/encyclopedia/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/encyclopedia

echo "檢查 $1 覆蓋內容是否存在"
if [ -f "$PATH_MEDIAFIRE_TINKER/zh_tw.json" ]; then
echo "翻譯存在!"
else
echo "錯誤!覆蓋 $1 翻譯失敗。"
exit 1
fi

echo "完成 $1 覆蓋!清理工作資料夾"
rm_workdir
}


# Main

## 回到工作目錄
home

## Mega

### BloodMagic
mega_override "BloodMagic" "BLOODMAGIC" "assets/bloodmagic" "https://mega.nz/#!KR0CQC5Z!MkEdb3M5q9FHLIgY7WLE18T8EqKFMVUd1guryQWdTQc" "1.18 BloodMagic-zh_tw-v2.zip"
echo "修正 BloodMagic 的全形空格"
sed -i 's/ //1' assets/bloodmagic/patchouli_books/guide/zh_tw/entries/altar/soul_network.json

## Mediafire

### ProjectE
mediafire_override "ProjectE" "assets/projecte/lang" "https://www.mediafire.com/file/uhtspihpscmrqsb/ProjectE-1.19.2-PE1.0.1B-tw.jar" "ProjectE-1.19.2-PE1.0.1B-tw.jar"

### The Twilight Forest
mediafire_override "The Twilight Forest" "assets/twilightforest/lang" "https://www.mediafire.com/file/kl96rxo50e68j93/twilightforest-1.18.2-4.1.1423-universal-tw.jar" "twilightforest-1.18.2-4.1.1423-universal-tw.jar"

### Productive Bees
mediafire_override "Productive Bees" "assets/productivebees/lang" "https://www.mediafire.com/file/raz0dqfohs5jk29/productivebees-1.19.2-0.10.2.0-tw.jar" "productivebees-1.19.2-0.10.2.0-tw.jar"

### Tinker (特殊)

mediafire_tinker_override "Tinkers' Construct" "assets/tconstruct/lang" "assets/tconstruct/book" "https://www.mediafire.com/file/snogv3qqn57o8rf/TConstruct-1.18.2-3.5.2.40-tw.jar" "TConstruct-1.18.2-3.5.2.40-tw.jar"
88 changes: 4 additions & 84 deletions .github/workflows/Auto-Packer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- pack.mcmeta
workflow_dispatch: {}

permissions:
contents: write

jobs:
Packer:
runs-on: ubuntu-latest
Expand All @@ -34,90 +37,7 @@ jobs:
# wget https://raw.githubusercontent.com/Creators-of-Create/Create/mc1.18/dev/src/main/resources/assets/create/lang/zh_tw.json -P $PATH_Create

- name: Override mods
run: |
echo ">>> 模組翻譯覆蓋 <<<"
echo ">>> 某些模組的翻譯如果搭配其他翻譯包"
echo ">>> 所使用會將翻譯好的內容變成未翻譯"
echo ">>> 此步驟將會把一些已知的模組翻譯覆蓋掉"
echo "Override ProjectE..."
PATH_ProjectE=assets/projecte/lang
mkdir -p $PATH_ProjectE
mkdir workdir
cd workdir
wget $(wget -qO - "https://www.mediafire.com/file/uhtspihpscmrqsb/ProjectE-1.19.2-PE1.0.1B-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
$JAVA_HOME_17_X64/bin/jar xf ProjectE-1.19.2-PE1.0.1B-tw.jar $PATH_ProjectE/zh_tw.json
cd ..
cp workdir/$PATH_ProjectE/zh_tw.json $PATH_ProjectE/
rm -r workdir
echo "Override BloodMagic..."
mkdir workdir
cd workdir
sudo apt-get update
sudo apt-get install -y megatools
echo "Small Info:"
echo "The original download link is https://mega.nz/file/KR0CQC5Z#MkEdb3M5q9FHLIgY7WLE18T8EqKFMVUd1guryQWdTQc"
echo "But megatools look like don't know what is this"
echo "This fix I see from https://github.com/megous/megatools/issues/157#issuecomment-615835778"
megadl 'https://mega.nz/#!KR0CQC5Z!MkEdb3M5q9FHLIgY7WLE18T8EqKFMVUd1guryQWdTQc'
unzip 1.18\ BloodMagic-zh_tw-v2.zip
cd ..
mv workdir/assets/bloodmagic assets
rm -r workdir
echo "Fix error space"
sed -i 's/ //1' assets/bloodmagic/patchouli_books/guide/zh_tw/entries/altar/soul_network.json
echo "Override Tinkers' Construct..."
PATH_TConstruct=assets/tconstruct/lang
PATH_TConstruct_Books=assets/tconstruct/book
mkdir -p $PATH_TConstruct
mkdir workdir
cd workdir
wget $(wget -qO - "https://www.mediafire.com/file/snogv3qqn57o8rf/TConstruct-1.18.2-3.5.2.40-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
$JAVA_HOME_17_X64/bin/jar xf TConstruct-1.18.2-3.5.2.40-tw.jar
cd ..
cp workdir/$PATH_TConstruct/zh_tw.json $PATH_TConstruct/
echo ">> Tinkers' Construct Books"
echo ">> Setup folders..."
mkdir -p $PATH_TConstruct_Books/tinkers_gadgetry
mkdir -p $PATH_TConstruct_Books/puny_smelting
mkdir -p $PATH_TConstruct_Books/mighty_smelting
mkdir -p $PATH_TConstruct_Books/materials_and_you
mkdir -p $PATH_TConstruct_Books/fantastic_foundry
mkdir -p $PATH_TConstruct_Books/encyclopedia
echo ">> Setup folder done!"
echo ">> Copy Tinkers' Construct Books"
cp -r workdir/$PATH_TConstruct_Books/tinkers_gadgetry/zh_tw $PATH_TConstruct_Books/tinkers_gadgetry
cp -r workdir/$PATH_TConstruct_Books/puny_smelting/zh_tw $PATH_TConstruct_Books/puny_smelting
cp -r workdir/$PATH_TConstruct_Books/mighty_smelting/zh_tw $PATH_TConstruct_Books/mighty_smelting
cp -r workdir/$PATH_TConstruct_Books/materials_and_you/zh_tw $PATH_TConstruct_Books/materials_and_you
cp -r workdir/$PATH_TConstruct_Books/fantastic_foundry/zh_tw $PATH_TConstruct_Books/fantastic_foundry
cp -r workdir/$PATH_TConstruct_Books/encyclopedia/zh_tw $PATH_TConstruct_Books/encyclopedia
echo ">> Copy books done!"
rm -r workdir
echo "Override The Twilight Forest..."
PATH_TwilightForest=assets/twilightforest/lang
mkdir -p $PATH_TwilightForest
mkdir workdir
cd workdir
wget $(wget -qO - "https://www.mediafire.com/file/kl96rxo50e68j93/twilightforest-1.18.2-4.1.1423-universal-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
$JAVA_HOME_17_X64/bin/jar xf twilightforest-1.18.2-4.1.1423-universal-tw.jar $PATH_TwilightForest/zh_tw.json
cd ..
cp workdir/$PATH_TwilightForest/zh_tw.json $PATH_TwilightForest/
rm -r workdir
echo "Override Productive Bees..."
PATH_ProductiveBees=assets/productivebees/lang
mkdir -p $PATH_ProductiveBees
mkdir workdir
cd workdir
wget $(wget -qO - "https://www.mediafire.com/file/raz0dqfohs5jk29/productivebees-1.19.2-0.10.2.0-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
$JAVA_HOME_17_X64/bin/jar xf productivebees-1.19.2-0.10.2.0-tw.jar $PATH_ProductiveBees/zh_tw.json
cd ..
cp workdir/$PATH_ProductiveBees/zh_tw.json $PATH_ProductiveBees/
rm -r workdir
run: sh .github/scripts/override_mods.sh

- name: Make ModsTranslationPack (1.19.x)
uses: ComunidadAylas/PackSquash-action@master
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/CI_Release_Me.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- main
workflow_dispatch: {}

permissions:
contents: write
pull-requests: write

jobs:
release-please:
name: Release Please
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Ignore Minecraft Lang Files

docs/Minecraft-Lang

# Ignore My Tools

tools

0 comments on commit c3baac3

Please sign in to comment.