From ad0dbbb4763a69cf6831a790dca1f142e4c2b585 Mon Sep 17 00:00:00 2001 From: Sean Burau Date: Mon, 8 May 2023 13:29:09 -0700 Subject: [PATCH] Update locale.sh to run in parallel for 100x speedup on launch. Currently each locale is fetched serially, which means the user must wait for MANY roundtrip HTTP calls to start and complete. Since each locale file is relatively tiny, fetching them all in parallel results in a near-instant startup time and the user can see the installation modal much more quickly. Since I was here I deduplicated all the redundant lines so new locales can be added much more easily. This more compact form also helps eliminate certain classes of bugs. I noticed that all the licenses were actually being fetched twice, likely due to copy-paste human error. --- files/builds/stable-branch/locale/locale.sh | 123 ++++++++------------ 1 file changed, 48 insertions(+), 75 deletions(-) diff --git a/files/builds/stable-branch/locale/locale.sh b/files/builds/stable-branch/locale/locale.sh index a268d9f..d369354 100644 --- a/files/builds/stable-branch/locale/locale.sh +++ b/files/builds/stable-branch/locale/locale.sh @@ -15,92 +15,64 @@ # ALL FUNCTIONS ARE ARRANGED HERE: # ############################################################################################################################################################### -# Load & Save the locale files into the folders! +declare -rA _LOCALES=( + [cs]="CZ" + [de]="DE" + [en]="US" + [es]="ES" + [fr]="FR" + [it]="IT" + [ja]="JP" + [ko]="KR" + [zh]="CN" +) + +# Load & Save the locale files into the folders (asynchronously)! +# Use the `wait` keyword after to block until completed. function load-locale-languages { - wget -N -P $SP_PATH/locale/cs-CZ/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/cs-CZ/locale-cs.sh - chmod +x $SP_PATH/locale/cs-CZ/locale-cs.sh - wget -N -P $SP_PATH/locale/de-DE/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/de-DE/locale-de.sh - chmod +x $SP_PATH/locale/de-DE/locale-de.sh - wget -N -P $SP_PATH/locale/en-US/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/en-US/locale-en.sh - chmod +x $SP_PATH/locale/en-US/locale-en.sh - wget -N -P $SP_PATH/locale/es-ES/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/es-ES/locale-es.sh - chmod +x $SP_PATH/locale/es-ES/locale-es.sh - wget -N -P $SP_PATH/locale/fr-FR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/fr-FR/locale-fr.sh - chmod +x $SP_PATH/locale/fr-FR/locale-fr.sh - wget -N -P $SP_PATH/locale/it-IT/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/it-IT/locale-it.sh - chmod +x $SP_PATH/locale/it-IT/locale-it.sh - wget -N -P $SP_PATH/locale/ja-JP/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ja-JP/locale-ja.sh - chmod +x $SP_PATH/locale/ja-JP/locale-ja.sh - wget -N -P $SP_PATH/locale/ko-KR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ko-KR/locale-ko.sh - chmod +x $SP_PATH/locale/ko-KR/locale-ko.sh - wget -N -P $SP_PATH/locale/zh-CN/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/zh-CN/locale-zh.sh - chmod +x $SP_PATH/locale/zh-CN/locale-zh.sh - wget -N -P $SP_PATH/locale/cs-CZ/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/cs-CZ/locale-cs.sh - chmod +x $SP_PATH/locale/cs-CZ/locale-cs.sh - wget -N -P $SP_PATH/locale/de-DE/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/de-DE/locale-de.sh - chmod +x $SP_PATH/locale/de-DE/locale-de.sh - wget -N -P $SP_PATH/locale/en-US/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/en-US/locale-en.sh - chmod +x $SP_PATH/locale/en-US/locale-en.sh - wget -N -P $SP_PATH/locale/es-ES/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/es-ES/locale-es.sh - chmod +x $SP_PATH/locale/es-ES/locale-es.sh - wget -N -P $SP_PATH/locale/fr-FR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/fr-FR/locale-fr.sh - chmod +x $SP_PATH/locale/fr-FR/locale-fr.sh - wget -N -P $SP_PATH/locale/it-IT/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/it-IT/locale-it.sh - chmod +x $SP_PATH/locale/it-IT/locale-it.sh - wget -N -P $SP_PATH/locale/ja-JP/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ja-JP/locale-ja.sh - chmod +x $SP_PATH/locale/ja-JP/locale-ja.sh - wget -N -P $SP_PATH/locale/ko-KR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ko-KR/locale-ko.sh - chmod +x $SP_PATH/locale/ko-KR/locale-ko.sh - wget -N -P $SP_PATH/locale/zh-CN/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/zh-CN/locale-zh.sh - chmod +x $SP_PATH/locale/zh-CN/locale-zh.sh + for lang in "${!_LOCALES[@]}" + do + country="${_LOCALES[$lang]}" + + ( + wget -N -P \ + "$SP_PATH/locale/$lang-$country" \ + "https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/$lang-$country/locale-$lang.sh" \ + && chmod +x "$SP_PATH/locale/$lang-$country/locale-$lang.sh" + ) & + done } ############################################################################################################################################################### -# Load & Save the translations of the licenses into the folders! +# Load & Save the translations of the licenses into the folders asynchronously! +# Use the `wait` keyword after to block until completed. function load-locale-licenses { - wget -N -P $SP_PATH/locale/cs-CZ/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/cs-CZ/license-cs.txt - wget -N -P $SP_PATH/locale/de-DE/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/de-DE/license-de.txt - wget -N -P $SP_PATH/locale/en-US/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/en-US/license-en.txt - wget -N -P $SP_PATH/locale/es-ES/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/es-ES/license-es.txt - wget -N -P $SP_PATH/locale/fr-FR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/fr-FR/license-fr.txt - wget -N -P $SP_PATH/locale/it-IT/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/it-IT/license-it.txt - wget -N -P $SP_PATH/locale/ja-JP/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ja-JP/license-ja.txt - wget -N -P $SP_PATH/locale/ko-KR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ko-KR/license-ko.txt - wget -N -P $SP_PATH/locale/zh-CN/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/zh-CN/license-zh.txt - wget -N -P $SP_PATH/locale/cs-CZ/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/cs-CZ/license-cs.txt - wget -N -P $SP_PATH/locale/de-DE/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/de-DE/license-de.txt - wget -N -P $SP_PATH/locale/en-US/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/en-US/license-en.txt - wget -N -P $SP_PATH/locale/es-ES/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/es-ES/license-es.txt - wget -N -P $SP_PATH/locale/fr-FR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/fr-FR/license-fr.txt - wget -N -P $SP_PATH/locale/it-IT/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/it-IT/license-it.txt - wget -N -P $SP_PATH/locale/ja-JP/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ja-JP/license-ja.txt - wget -N -P $SP_PATH/locale/ko-KR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ko-KR/license-ko.txt - wget -N -P $SP_PATH/locale/zh-CN/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/zh-CN/license-zh.txt + for lang in "${!_LOCALES[@]}" + do + country="${_LOCALES[$lang]}" + + wget -N -P \ + "$SP_PATH/locale/$lang-$country" \ + "https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/$lang-$country/license-$lang.txt" \ + & + done } ############################################################################################################################################################### -# Load & Save the translations of the extensions into the folders! +# Load & Save the translations of the extensions into the folders +# asynchronously! Use the `wait` keyword after to block until completed. function load-locale-extensions { - wget -N -P $SP_PATH/locale/cs-CZ/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/cs-CZ/extensions-cs.txt - wget -N -P $SP_PATH/locale/de-DE/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/de-DE/extensions-de.txt - wget -N -P $SP_PATH/locale/en-US/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/en-US/extensions-en.txt - wget -N -P $SP_PATH/locale/es-ES/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/es-ES/extensions-es.txt - wget -N -P $SP_PATH/locale/fr-FR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/fr-FR/extensions-fr.txt - wget -N -P $SP_PATH/locale/it-IT/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/it-IT/extensions-it.txt - wget -N -P $SP_PATH/locale/ja-JP/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ja-JP/extensions-ja.txt - wget -N -P $SP_PATH/locale/ko-KR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ko-KR/extensions-ko.txt - wget -N -P $SP_PATH/locale/zh-CN/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/zh-CN/extensions-zh.txt - wget -N -P $SP_PATH/locale/cs-CZ/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/cs-CZ/extensions-cs.txt - wget -N -P $SP_PATH/locale/de-DE/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/de-DE/extensions-de.txt - wget -N -P $SP_PATH/locale/en-US/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/en-US/extensions-en.txt - wget -N -P $SP_PATH/locale/es-ES/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/es-ES/extensions-es.txt - wget -N -P $SP_PATH/locale/fr-FR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/fr-FR/extensions-fr.txt - wget -N -P $SP_PATH/locale/it-IT/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/it-IT/extensions-it.txt - wget -N -P $SP_PATH/locale/ja-JP/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ja-JP/extensions-ja.txt - wget -N -P $SP_PATH/locale/ko-KR/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/ko-KR/extensions-ko.txt - wget -N -P $SP_PATH/locale/zh-CN/ https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/zh-CN/extensions-zh.txt + for lang in "${!_LOCALES[@]}" + do + country="${_LOCALES[$lang]}" + + wget -N -P \ + "$SP_PATH/locale/$lang-$country" \ + "https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux/raw/main/files/builds/stable-branch/locale/$lang-$country/extensions-$lang.txt" \ + & + done } ############################################################################################################################################################### @@ -110,3 +82,4 @@ function load-locale-extensions { load-locale-languages load-locale-licenses load-locale-extensions +wait