Skip to content

Commit 21c798c

Browse files
committed
Refactor language parameter mapping in install_from_release.sh
1 parent 03ae339 commit 21c798c

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

scripts/install_from_release.sh

+34-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,42 @@ fi
1212

1313
# Map the language parameter to the corresponding scenarios file
1414
# If no parameter, download the scenarios from IE
15-
if [ "$LANG" = "" ]; then
15+
MAIN_LANG_PREFIX="$(echo "$LANG" | head -c2 | tr '[:upper:]' '[:lower:]')"
16+
LANG_ARRAY_1=("de" "es" "fr" "it" "nl" "pt")
17+
LANG_ARRAY_2=("cs" "hu" "id" "ja" "ko" "pl" "pt" "ru" "sv" "tr")
18+
19+
if [ "$MAIN_LANG_PREFIX" = "" ] || [ "$MAIN_LANG_PREFIX" = "en" ]; then
1620
SCENARIOS="https://github.com/Azure/InnovationEngine/releases/download/$RELEASE/scenarios.zip"
17-
# Otherwise, download the scenarios from Microsoft Docs in the appropriate langauge
18-
elif [ "$LANG" = "en-us" ]; then
19-
SCENARIOS='https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/scenarios.zip'
21+
elif [ "$MAIN_LANG_PREFIX" = "pt" ]; then
22+
if [ "$LANG" = 'pt-pt' ]; then
23+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
24+
elif [ "$LANG" = 'pt-br' ]; then
25+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-br-scenarios.zip"
26+
fi
27+
elif [ "$MAIN_LANG_PREFIX" = "zh" ]; then
28+
if [ "$LANG" = "zh-cn" ]; then
29+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
30+
elif [ "$LANG" = "zh-tw" ]; then
31+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-tw-scenarios.zip"
32+
else
33+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
34+
fi
35+
elif [[ ${LANG_ARRAY_1[@]} =~ $MAIN_LANG_PREFIX ]]; then
36+
# for any other language that we do not have a specific scenarios file for, we will use the generic one
37+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip"
38+
elif [[ ${LANG_ARRAY_2[@]} =~ $MAIN_LANG_PREFIX ]]; then
39+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip"
40+
if [ "$MAIN_LANG_PREFIX" = "cs" ]; then
41+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-cz-scenarios.zip"
42+
elif [ "$MAIN_LANG_PREFIX" = "ja" ]; then
43+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-jp-scenarios.zip"
44+
elif [ "$MAIN_LANG_PREFIX" = "ko" ]; then
45+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-kr-scenarios.zip"
46+
elif [ "$MAIN_LANG_PREFIX" = "sv" ]; then
47+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-se-scenarios.zip"
48+
fi
2049
else
21-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$LANG-scenarios.zip"
50+
SCENARIOS="https://github.com/Azure/InnovationEngine/releases/download/$RELEASE/scenarios.zip"
2251
fi
2352

2453
# Download the binary

0 commit comments

Comments
 (0)