From 215ad15bebdce1b7c6a5f4fb0867bdd3bfa931e6 Mon Sep 17 00:00:00 2001 From: wvffle Date: Fri, 25 Nov 2022 18:20:55 +0000 Subject: [PATCH] Remove unused scripts --- .gitlab-ci.yml | 1 - .gitpod.yml | 1 - front/package.json | 2 - front/scripts/i18n-compile.sh | 22 ---------- front/scripts/i18n-extract.sh | 54 ------------------------ front/scripts/print-duplicates-source.py | 32 -------------- 6 files changed, 112 deletions(-) delete mode 100755 front/scripts/i18n-compile.sh delete mode 100755 front/scripts/i18n-extract.sh delete mode 100755 front/scripts/print-duplicates-source.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9bd7ce4fd..47ad085c1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -290,7 +290,6 @@ build_front: - cd front script: - yarn install - - yarn run i18n-compile # this is to ensure we don't have any errors in the output, # cf https://dev.funkwhale.audio/funkwhale/funkwhale/issues/169 - yarn run build:deployment | tee /dev/stderr | (! grep -i 'ERROR in') diff --git a/.gitpod.yml b/.gitpod.yml index ddc67c6a2..0f6e92857 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -37,7 +37,6 @@ tasks: before: cd front init: | yarn install - yarn run i18n-compile command: yarn dev --host 0.0.0.0 --base /front/ - name: Welcome to Funkwhale development! diff --git a/front/package.json b/front/package.json index e8e83853c..e0912477f 100644 --- a/front/package.json +++ b/front/package.json @@ -14,8 +14,6 @@ "lint": "eslint --ext .ts,.js,.vue,.html src public/embed.html", "lint:tsc": "vue-tsc --noEmit", "fix-fomantic-css": "scripts/fix-fomantic-css.sh", - "i18n-compile": "scripts/i18n-compile.sh", - "i18n-extract": "scripts/i18n-extract.sh", "postinstall": "yarn run fix-fomantic-css" }, "dependencies": { diff --git a/front/scripts/i18n-compile.sh b/front/scripts/i18n-compile.sh deleted file mode 100755 index 4ede9b2e0..000000000 --- a/front/scripts/i18n-compile.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -cd "$(dirname "$0")/.." # change into base directory - -npm_binaries() { - if command -v yarn > /dev/null; then - yarn bin - else - npm bin - fi -} - -locales=$(jq -r '.[].code' src/locales.json | grep -v 'en_US') -mkdir -p src/translations - -for locale in $locales; do - "$(npm_binaries)/gettext-compile" "locales/$locale/LC_MESSAGES/app.po" --output "src/translations/$locale.json" -done - -# find locales -name '*.po' | xargs "$(npm_binaries)/.bin/gettext-compile" --output src/translations.json diff --git a/front/scripts/i18n-extract.sh b/front/scripts/i18n-extract.sh deleted file mode 100755 index b244fe086..000000000 --- a/front/scripts/i18n-extract.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -cd "$(dirname "$0")/.." # change into base directory - -npm_binaries() { - if command -v yarn > /dev/null; then - yarn bin - else - npm bin - fi -} - -locales=$(jq -r '.[].code' src/locales.json) -locales_dir="locales" -sources=$(find src -name '*.vue' -o -name '*.html' 2> /dev/null) -js_sources=$(find src -name '*.vue' -o -name '*.js') -touch "$locales_dir/app.pot" -GENERATE="${GENERATE-true}" - -# Create a main .pot template, then generate .po files for each available language. -# Extract gettext strings from templates files and create a POT dictionary template. -# shellcheck disable=SC2086 -"$(npm_binaries)/gettext-extract" --attribute v-translate --quiet --output "$locales_dir/app.pot" $sources - -# shellcheck disable=SC2086 -xgettext --language=JavaScript --keyword=npgettext:1c,2,3 \ - --from-code=utf-8 --join-existing --no-wrap \ - --package-name="$(jq -r '.name' package.json)" \ - --package-version="$(jq -r '.version' package.json)" \ - --output "$locales_dir/app.pot" $js_sources \ - --no-wrap - -# Fix broken files path/lines in pot -sed -e 's|#: src/|#: front/src/|' -i "$locales_dir/app.pot" - -if [ "$GENERATE" = 'true' ]; then - # Generate .po files for each available language. - echo "$locales" - for lang in $locales; do - po_file="$locales_dir/$lang/LC_MESSAGES/app.po" - echo "msgmerge --update $po_file" - mkdir -p "$(dirname "$po_file")" - - if [[ -f "$po_file" ]]; then - msgmerge --lang="$lang" --update "$po_file" "$locales_dir/app.pot" --no-wrap - else - msginit --no-wrap --no-translator --locale="$lang" --input="$locales_dir/app.pot" --output-file="$po_file" - fi - - msgattrib --no-wrap --no-obsolete -o "$po_file" "$po_file" - done -fi diff --git a/front/scripts/print-duplicates-source.py b/front/scripts/print-duplicates-source.py deleted file mode 100755 index 8d8d28d13..000000000 --- a/front/scripts/print-duplicates-source.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import collections - -import polib - - -def print_duplicates(path): - pofile = polib.pofile(path) - - contexts_by_id = collections.defaultdict(list) - for e in pofile: - contexts_by_id[e.msgid].append(e.msgctxt) - count = collections.Counter([e.msgid for e in pofile]) - duplicates = [(k, v) for k, v in count.items() if v > 1] - for k, v in sorted(duplicates, key=lambda r: r[1], reverse=True): - print(f"{v} entries - {k}:") - for ctx in contexts_by_id[k]: - print(f" - {ctx}") - print() - - total_duplicates = sum([v - 1 for _, v in duplicates]) - print(f"{total_duplicates} total duplicates") - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("po", help="Path of the po file to use as a source") - args = parser.parse_args() - - print_duplicates(path=args.po)