Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow wildcard format for language names when running auto.sh #47

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: npm install

- name: Run auto.sh script
run: ./auto.sh any any ST
run: ./auto.sh ? ?

- name: Generate list of .zip files
id: generate_file_list
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ Converts wiktionary data from https://kaikki.org/ to yomitan-compatible dictiona

## Contributing

Instead of a language name, you can also write `?` to run for all languages.
- `./auto.sh ? English` will run for any language to English.
- `./auto.sh German ?` will run for German to any language.

The `auto.sh` script can also be run with flags:

- k: keep files (by default, the script deletes the downloaded files after running),
- d: redownload (by default, the script skips downloading if the file already exists),
- t: force_tidy (run tidy script again, even if its output already exists. useful when the tidy script is updated),
- y: force_ymt (run yomitan script again, even if its output already exists. useful when the yomitan script is updated),
- F: force = force_tidy + force_ymt,
- S: run for all source languages (`./auto.sh German English S` is like `./auto.sh * English`),
- T: run for all target languages (`./auto.sh German English T` is like `./auto.sh German *`).

Most often, you will want to run `./auto.sh German English kty` to recreate the dictionaries, then load them in yomitan and test them.

Expand Down
16 changes: 5 additions & 11 deletions auto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ if [ -z "$1" ] || [ -z "$2" ]; then
fi

# Parse flags
source_all=false
target_all=false
redownload=false
force_tidy=false
force_ymt=false
Expand All @@ -26,8 +24,6 @@ for flag in "${flags[@]}"; do
case "$3" in
*"$flag"*)
case "$flag" in
'S') source_all=true ;;
'T') target_all=true ;;
'd') redownload=true ;;
't') force_tidy=true ;;
'y') force_ymt=true ;;
Expand All @@ -47,8 +43,6 @@ if [ "$force_tidy" = true ]; then
force_ymt=true
fi

echo "[S] source_all: $source_all"
echo "[T] target_all: $target_all"
echo "[d] redownload: $redownload"
echo "[F] force: $force"
echo "[t] force_tidy: $force_tidy"
Expand All @@ -61,8 +55,8 @@ npm i
# Step 2: Run create-folder.js
node 1-create-folders.js

source_language="$1"
target_language="$2"
language_source="$1"
language_target="$2"

declare -a languages="($(
jq -r '.[] | @json | @sh' languages.json
Expand All @@ -72,11 +66,11 @@ for target_lang in "${languages[@]}"; do
target_iso=$(echo "${target_lang}" | jq -r '.iso')
target_language_name=$(echo "${target_lang}" | jq -r '.language')

if [ "$target_language_name" != "$target_language" ] && [ "$target_all" = false ]; then
if [ "$target_language_name" != "$language_target" ] && [ "$language_target" != "?" ]; then
continue
fi

target_languages="es de en fr ru zh"
target_languages="de en es fr ru zh"
if [[ ! "$target_languages" == *"$target_iso"* ]]; then
echo "Unsupported target language: $target_iso"
continue
Expand All @@ -91,7 +85,7 @@ for target_lang in "${languages[@]}"; do
language=$(echo "${source_lang}" | jq -r '.language')
flag=$(echo "${source_lang}" | jq -r '.flag')

if [ "$language" != "$source_language" ] && [ "$source_all" = false ]; then
if [ "$language" != "$language_source" ] && [ "$language_source" != "?" ]; then
continue
fi

Expand Down
Loading