From c806f09b10c18fdb0359b7092c8c20acab7a5195 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Fri, 27 Sep 2024 03:02:55 +0200 Subject: [PATCH] Improving translations update script. --- LogarithmPlotter/i18n/update.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/LogarithmPlotter/i18n/update.sh b/LogarithmPlotter/i18n/update.sh index 3a01e14..8d589d5 100755 --- a/LogarithmPlotter/i18n/update.sh +++ b/LogarithmPlotter/i18n/update.sh @@ -4,7 +4,7 @@ # specificities so that lupdate doesn't cry out in pain. # See also: https://bugreports.qt.io/browse/QTBUG-123819 # - + escape() { str="$1" str="${str//\//\\/}" # Escape slashes @@ -19,15 +19,20 @@ replace() { sed -i "s/${from}/${to}/g" "$file" } +rm ../qml/eu/ad5001/LogarithmPlotter/js/index.mjs # Remove index which should not be scanned + files=$(find .. -name *.mjs) for file in $files; do echo "Moving '$file' to '${file%.*}.js'..." mv "$file" "${file%.*}.js" # Replacements to make it valid js replace "${file%.*}.js" "^import" "/*import" + replace "${file%.*}.js" "^export *" "/*export *" replace "${file%.*}.js" '.mjs"$' '.mjs"*/' replace "${file%.*}.js" "^export default" "/*export default*/" replace "${file%.*}.js" "^export" "/*export*/" + replace "${file%.*}.js" "async " "/*async */" + replace "${file%.*}.js" "await" "/*await */" done echo "----------------------------" @@ -38,7 +43,6 @@ lupdate -extensions js,qs,qml,py -recursive .. -ts lp_*.ts for lp in *.ts; do echo "Replacing locations in $lp..." for file in $files; do - echo " > Replacing for file $file..." replace "$lp" "${file%.*}.js" "$file" done done @@ -47,8 +51,11 @@ for file in $files; do echo "Moving '${file%.*}.js' to '$file'..." mv "${file%.*}.js" "$file" # Resetting changes - replace "$file" "^/*import" "import" - replace "$file" '.mjs"*/$' '.mjs"' - replace "$file" "^/*export default*/" "export default" + replace "$file" "/*await */" "await" + replace "$file" "/*async */" "async " replace "$file" "^/*export*/" "export" + replace "$file" "^/*export default*/" "export default" + replace "$file" "^/*import" "import" + replace "$file" "^/*export" "export" + replace "$file" '.mjs"*/$' '.mjs"' done