bigbluebutton-Github/bigbluebutton-html5/transifex.sh
Ramón Souza 0105373cee
Applies changes needed to serve locale files as static content (#11234)
* moving locales folder to /public and applying changes needed to serve locales as static files

* better dev/prod check

* transifex pull script changes to match new locales directory + ignore locales with less than 100 lines

* fix local/prod locales path

* merge fallback messages

* applies new locale changes to legacy client

`bbb-html5.nginx` file content should also be changed to the following:

```
location /html5client/locales {
  alias /usr/share/meteor/bundle/programs/web.browser/app/locales;
}

location /html5client/compatibility {
  alias /usr/share/meteor/bundle/programs/web.browser/app/compatibility;
}

location /html5client/resources {
  alias /usr/share/meteor/bundle/programs/web.browser/app/resources;
}

location /html5client/svgs {
  alias /usr/share/meteor/bundle/programs/web.browser/app/svgs;
}

location /html5client/fonts {
  alias /usr/share/meteor/bundle/programs/web.browser/app/fonts;
}

location /html5client {
  # proxy_pass http://127.0.0.1:4100; # use for development
  proxy_pass http://poolhtml5servers; # use for production
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
}
```
2021-03-11 06:42:41 -05:00

82 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
#colors
RED='\033[0;31m'
GREEN='\033[1;32m'
NC='\033[0m'
SOURCE_LANGUAGE="en"
LOCALES_DIRECTORY="./public/locales"
PULL_SOURCE=false
if [[ ! -e $LOCALES_DIRECTORY ]]; then
echo -e "Directory ${RED}$LOCALES_DIRECTORY${NC} does not exist, creating"
mkdir $LOCALES_DIRECTORY
PULL_SOURCE=true
fi
if [ "$#" = 0 ]
then
echo -e "${RED}ERR${NC}: Usage = ${GREEN}./transifex.sh pt_BR de ${NC}or ${GREEN}./transifex all${NC}"
else
read -p "Enter Transifex Username: " USER
read -p "password: " -s PW
echo -e "\n----------------------------------\nchecking project info\n----------------------------------"
PROJECT_INFO=$( curl -L --user "$USER":"$PW" -X GET https://www.transifex.com/api/2/project/bigbluebutton-v23-html5-client/languages/ )
if [ "$PROJECT_INFO" == "Authorization Required" ]
then
echo -e "${RED}Err${NC} : $PROJECT_INFO"
else
echo -e "Project Information Found :${GREEN}${NC}"
if [ "$PROJECT_INFO" == "Forbidden" ]
then
echo -e "${RED}Err${NC}: Invalid User Permissions"
else
for ARG in "$@"
do
if [ "$ARG" == "all" ]
then
AVAILABLE_TRANSLATIONS=$( echo "$PROJECT_INFO" | grep 'language_code' | cut -d':' -f2 | tr -d '[",]' )
echo "$AVAILABLE_TRANSLATIONS" | while read l
do
LOCALE=$( echo "$l" | tr -d '[:space:]' )
if [ "$LOCALE" == "$SOURCE_LANGUAGE" ] && [ "$PULL_SOURCE" == false ]; then
continue # only pull source file if locales folder did not exist
fi
TRANSLATION=$(curl -L --user "$USER":"$PW" -X GET "https://www.transifex.com/api/2/project/bigbluebutton-v23-html5-client/resource/enjson/translation/$LOCALE/?mode=onlytranslated&file")
NO_EMPTY_STRINGS=$(echo "$TRANSLATION" | sed '/: *\"\"/D' | sed '/}$/D')
if [ $(echo "$NO_EMPTY_STRINGS" | wc -l) -lt 100 ]
then
echo -e "${RED}WARN:${NC} translation file $LOCALE.json contains less than 100 lines\n${RED}WARN:${NC} $LOCALE.json not created"
continue
else
NO_TRAILING_COMMA=$(echo "$NO_EMPTY_STRINGS" | sed '$ s/,$//')
echo "$NO_TRAILING_COMMA" > "$LOCALES_DIRECTORY/$LOCALE".json
echo -e "\n}\n" >> "$LOCALES_DIRECTORY/$LOCALE".json
echo -e "Added translation file $LOCALE.json : ${GREEN}${NC}"
fi
done
else
TRANSLATION=$(curl -L --user "$USER":"$PW" -X GET "https://www.transifex.com/api/2/project/bigbluebutton-v23-html5-client/resource/enjson/translation/$ARG/?mode=onlytranslated&file")
if [ "$TRANSLATION" == "Not Found" ]
then
echo -e "${RED}Err${NC}: Translations not found for locale ->${RED}$ARG${NC}<-"
else
NO_EMPTY_STRINGS=$(echo "$TRANSLATION" | sed '/: *\"\"/D' | sed '/}$/D')
if [ $(echo "$NO_EMPTY_STRINGS" | wc -l) -lt 100 ]
then
echo -e "${RED}WARN:${NC} translation file $ARG.json contains less than 100 lines\n${RED}WARN:${NC} $ARG.json not created"
else
NO_TRAILING_COMMA=$(echo "$NO_EMPTY_STRINGS" | sed '$ s/,//')
echo "$NO_TRAILING_COMMA" > "$LOCALES_DIRECTORY/$ARG".json
echo -e "\n}\n" >> "$LOCALES_DIRECTORY/$ARG".json
echo -e "Added translation file $ARG.json :${GREEN}${NC}"
fi
fi
fi
done
fi
fi
fi