fix(scripts): make client build compatible with Bash 3.2 (macOS) (#7332)

* fix(scripts): make client build compatible with Bash 3.2 (macOS)

I started poking around here earlier this morning, to build and run tests and contribute something, but I quickly ran into the problem with Bash 4 requirements as I'm on MacOS. I was thinking this might pose an overly high barrier to entry for newcomers. Beautiful with the Bash 4+ associative arrays, but being able to check out the project and just run `npm run build` after the necessary Homebrew Node/npm/FFmpeg installs that's also beautiful! :)))

* refactor(scripts): use `key:locale` pairs instead of parallel arrays

Address maintainer feedback https://github.com/Chocobozzz/PeerTube/pull/7332#issuecomment-3646366574, keep the association between key and value visible by using "key:locale" pairs in a single array, with one language per line for easy scanning.

---------

Co-authored-by: ar9708 <ar9708@users.noreply.github.com>
This commit is contained in:
ar9708
2025-12-12 14:45:13 +01:00
committed by GitHub
co-authored by ar9708
parent 7d5e80c95e
commit 893afd92be
2 changed files with 43 additions and 57 deletions
+42 -42
View File
@@ -2,49 +2,48 @@
set -eu
declare -A languages
defaultLanguage="en-US"
# Supported languages
# Supported languages (key:locale pairs) - Bash 3.2 compatible for macOS
languages=(
["ar"]="ar"
["sk"]="sk-SK"
["is"]="is"
["tr"]="tr-TR"
["fa"]="fa-IR"
["en"]="en-US"
["vi"]="vi-VN"
["hu"]="hu-HU"
["th"]="th-TH"
["fi"]="fi-FI"
["nl"]="nl-NL"
["gd"]="gd"
["el"]="el-GR"
["es"]="es-ES"
["oc"]="oc"
["pt"]="pt-BR"
["pt-PT"]="pt-PT"
["sv"]="sv-SE"
["pl"]="pl-PL"
["ru"]="ru-RU"
["zh-Hans"]="zh-Hans-CN"
["zh-Hant"]="zh-Hant-TW"
["fr"]="fr-FR"
["ja"]="ja-JP"
["eu"]="eu-ES"
["ca"]="ca-ES"
["gl"]="gl-ES"
["cs"]="cs-CZ"
["hr"]="hr"
["eo"]="eo"
["de"]="de-DE"
["it"]="it-IT"
["uk"]="uk-UA"
["sq"]="sq"
["tok"]="tok"
["nn"]="nn"
["nb"]="nb-NO"
["kab"]="kab"
ar:ar
ca:ca-ES
cs:cs-CZ
de:de-DE
el:el-GR
en:en-US
eo:eo
es:es-ES
eu:eu-ES
fa:fa-IR
fi:fi-FI
fr:fr-FR
gd:gd
gl:gl-ES
hr:hr
hu:hu-HU
is:is
it:it-IT
ja:ja-JP
kab:kab
nb:nb-NO
nl:nl-NL
nn:nn
oc:oc
pl:pl-PL
pt:pt-BR
pt-PT:pt-PT
ru:ru-RU
sk:sk-SK
sq:sq
sv:sv-SE
th:th-TH
tok:tok
tr:tr-TR
uk:uk-UA
vi:vi-VN
zh-Hans:zh-Hans-CN
zh-Hant:zh-Hant-TW
)
@@ -63,8 +62,9 @@ if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); t
NODE_OPTIONS=--max_old_space_size=8192 node_modules/.bin/ng build --configuration production --output-path "dist/build" $additionalParams
for key in "${!languages[@]}"; do
lang=${languages[$key]}
for entry in "${languages[@]}"; do
key="${entry%%:*}"
lang="${entry#*:}"
mv "dist/build/browser/$key" "dist/$lang"
+1 -15
View File
@@ -485,25 +485,11 @@ On a fresh install of [FreeBSD](https://www.freebsd.org), new system or new jail
1. Add the packages:
```sh
brew install bash ffmpeg nginx postgresql openssl gcc make redis git
brew install ffmpeg nginx postgresql openssl gcc make redis git
brew install yarn # PeerTube <= v7.3 only
brew install pnpm # PeerTube >= v8.0 only
```
You may need to update your default version of bash.
**How to change your default shell**
```sh
which -a bash # Check where bash is installed
bash --version # You need a version at least as recent as 4.0
sudo vim /etc/shells # Add in this file : /usr/local/bin/bash
chsh -s /usr/local/bin/bash # To set the brew-installed bash as default bash
```
In a new shell, type `bash --version` to assert your changes took effect and
correctly modified your default bash version.
1. Run the services:
```sh