From 715d15f91de0b7c62e30ad11a788a488286d1a84 Mon Sep 17 00:00:00 2001 From: Gustavo Emanuel Farias Rosa Date: Tue, 12 Apr 2022 17:59:15 -0300 Subject: [PATCH 1/5] implementing fall back to lenguage in Intl --- react-native/app/translations/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/react-native/app/translations/index.ts b/react-native/app/translations/index.ts index b22fce0..a1164f5 100644 --- a/react-native/app/translations/index.ts +++ b/react-native/app/translations/index.ts @@ -2,10 +2,12 @@ import i18next from 'i18next' import RNLanguages from 'react-native-languages'; import resources from './resources'; -export const initTranslation = ()=>{ +export const initTranslation = ()=>{ + console.log(RNLanguages.language) i18next.init({ compatibilityJSON: 'v3', lng: RNLanguages.language, - resources: resources + resources: resources, + fallbackLng: 'en-US', }) } \ No newline at end of file From 64cbfd02690f47ff868309d29a4542987f823be3 Mon Sep 17 00:00:00 2001 From: Gustavo Emanuel Farias Rosa Date: Tue, 12 Apr 2022 18:08:41 -0300 Subject: [PATCH 2/5] remove console log --- react-native/app/translations/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/react-native/app/translations/index.ts b/react-native/app/translations/index.ts index a1164f5..c554eb4 100644 --- a/react-native/app/translations/index.ts +++ b/react-native/app/translations/index.ts @@ -2,8 +2,7 @@ import i18next from 'i18next' import RNLanguages from 'react-native-languages'; import resources from './resources'; -export const initTranslation = ()=>{ - console.log(RNLanguages.language) +export const initTranslation = ()=>{ i18next.init({ compatibilityJSON: 'v3', lng: RNLanguages.language, From 0592ff2c3be5c5652dc8eef89d687fb74c7b1cc8 Mon Sep 17 00:00:00 2001 From: Ramon Souza Date: Wed, 13 Apr 2022 11:31:17 -0300 Subject: [PATCH 3/5] add transifex script --- react-native/app/translations/transifex.sh | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100755 react-native/app/translations/transifex.sh diff --git a/react-native/app/translations/transifex.sh b/react-native/app/translations/transifex.sh new file mode 100755 index 0000000..9bbee8d --- /dev/null +++ b/react-native/app/translations/transifex.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +#colors +RED='\033[0;31m' +GREEN='\033[1;32m' +NC='\033[0m' +SOURCE_LANGUAGE="en" +LOCALES_DIRECTORY="./resources/" +PULL_SOURCE=true + +if [[ ! -e $LOCALES_DIRECTORY ]]; then + echo -e "Directory ${RED}$LOCALES_DIRECTORY${NC} does not exist, creating" + mkdir $LOCALES_DIRECTORY +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-v25-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-v25-html5-client/resource/enjson/translation/$LOCALE/?mode=onlytranslated&file") + MOBILE_APP_STRINGS=$(echo "$TRANSLATION" | grep "mobileApp.") + NO_EMPTY_STRINGS=$(echo "$MOBILE_APP_STRINGS" | sed '/: *\"\"/D' | sed '/}$/D') + if [ $(echo "$NO_EMPTY_STRINGS" | wc -l) -lt 5 ] + then + echo -e "${RED}WARN:${NC} translation file $LOCALE.json contains less than 5 lines\n${RED}WARN:${NC} $LOCALE.json not created" + continue + else + NO_TRAILING_COMMA=$(echo "$NO_EMPTY_STRINGS" | sed '$ s/,$//') + echo "export default {" > "$LOCALES_DIRECTORY/$LOCALE".ts + echo -e "$NO_TRAILING_COMMA" >> "$LOCALES_DIRECTORY/$LOCALE".ts + echo -e "}" >> "$LOCALES_DIRECTORY/$LOCALE".ts + echo -e "Added translation file $LOCALE.ts :${GREEN} ✓${NC}" + fi + done + else + TRANSLATION=$(curl -L --user "$USER":"$PW" -X GET "https://www.transifex.com/api/2/project/bigbluebutton-v25-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 + MOBILE_APP_STRINGS=$(echo "$TRANSLATION" | grep "mobileApp.") + NO_EMPTY_STRINGS=$(echo "$MOBILE_APP_STRINGS" | sed '/: *\"\"/D' | sed '/}$/D') + if [ $(echo "$NO_EMPTY_STRINGS" | wc -l) -lt 5 ] + then + echo -e "${RED}WARN:${NC} translation file $ARG.json contains less than 5 lines\n${RED}WARN:${NC} $ARG.json not created" + else + NO_TRAILING_COMMA=$(echo "$NO_EMPTY_STRINGS" | sed '$ s/,//') + echo "export default {" > "$LOCALES_DIRECTORY/$ARG".ts + echo -e "$NO_TRAILING_COMMA" >> "$LOCALES_DIRECTORY/$ARG".ts + echo -e "}" >> "$LOCALES_DIRECTORY/$ARG".ts + echo -e "Added translation file $ARG.ts :${GREEN} ✓${NC}" + fi + fi + fi + done + fi + fi +fi + +#create index.ts file +TAB="\\t"; + +if [ -f "$LOCALES_DIRECTORY/index.ts" ] ; then + rm "$LOCALES_DIRECTORY/index.ts" +fi + +for entry in "$LOCALES_DIRECTORY"/* +do + FILE=$(echo "$entry" | rev | cut -d'/' -f 1 | rev | cut -d'.' -f 1) + TRANSLATION=$(echo "$FILE" | sed 's/_//') + echo -e "import $TRANSLATION from \"./$FILE\";" >> "$LOCALES_DIRECTORY/index.ts" +done + +echo -e "\\nexport default {" >> "$LOCALES_DIRECTORY/index.ts" + +for entry in "$LOCALES_DIRECTORY"/* +do + if [ "$entry" != "$LOCALES_DIRECTORY/index.ts" ] + then + FILE=$(echo "$entry" | rev | cut -d'/' -f 1 | rev | cut -d'.' -f 1 | tr _ -) + TRANSLATION=$(echo "$FILE" | sed 's/-//') + echo -e $TAB"'$FILE': {" >> "$LOCALES_DIRECTORY/index.ts" + echo -e $TAB$TAB"translation: $TRANSLATION\\n$TAB}," >> "$LOCALES_DIRECTORY/index.ts" +fi +done + +echo -e "}" >> "$LOCALES_DIRECTORY/index.ts" From c36a8a35512bd37816e5e6b55a0b8766eb7bccb7 Mon Sep 17 00:00:00 2001 From: Ramon Souza Date: Wed, 13 Apr 2022 11:52:38 -0300 Subject: [PATCH 4/5] move transifex file to project root --- .../transifex.sh => get-transifex-translations.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename react-native/app/translations/transifex.sh => get-transifex-translations.sh (94%) diff --git a/react-native/app/translations/transifex.sh b/get-transifex-translations.sh similarity index 94% rename from react-native/app/translations/transifex.sh rename to get-transifex-translations.sh index 9bbee8d..cb08df3 100755 --- a/react-native/app/translations/transifex.sh +++ b/get-transifex-translations.sh @@ -5,17 +5,17 @@ RED='\033[0;31m' GREEN='\033[1;32m' NC='\033[0m' SOURCE_LANGUAGE="en" -LOCALES_DIRECTORY="./resources/" +LOCALES_DIRECTORY="./react-native/app/translations/resources/" PULL_SOURCE=true if [[ ! -e $LOCALES_DIRECTORY ]]; then echo -e "Directory ${RED}$LOCALES_DIRECTORY${NC} does not exist, creating" - mkdir $LOCALES_DIRECTORY + mkdir -p $LOCALES_DIRECTORY fi if [ "$#" = 0 ] then - echo -e "${RED}ERR${NC}: Usage = ${GREEN}./transifex.sh pt_BR de ${NC}or ${GREEN}./transifex all${NC}" + echo -e "${RED}ERR${NC}: Usage = ${GREEN}./get-transifex-translations.sh pt_BR de ${NC}or ${GREEN}./get-transifex-translations all${NC}" else read -p "Enter Transifex Username: " USER read -p "password: " -s PW From 5532776532129778aae3bc351e690a943577c24b Mon Sep 17 00:00:00 2001 From: Tiago Jacobs Date: Wed, 13 Apr 2022 11:56:56 -0300 Subject: [PATCH 5/5] Refactor translation keys --- react-native/app/translations/resources/en-US.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/react-native/app/translations/resources/en-US.ts b/react-native/app/translations/resources/en-US.ts index 04b798c..51bf7ed 100644 --- a/react-native/app/translations/resources/en-US.ts +++ b/react-native/app/translations/resources/en-US.ts @@ -1,5 +1,6 @@ export default { - "mobileApp.portals.list.empty.label": "Add your first portal.", + "mobileApp.portals.list.empty.addFirstPortal.label": "Add your first portal using the button above,", + "mobileApp.portals.list.empty.orUseOurDemoServer.label": "or use our demo server.", "mobileApp.portals.list.add.button.label": "Add portal", "mobileApp.portals.fields.name.label": "Portal Name", "mobileApp.portals.fields.name.placeholder": "BigBlueButton demo", @@ -7,7 +8,7 @@ export default { "mobileApp.portals.fields.url.placeholder": "https://demo.bigbluebutton.org", "mobileApp.portals.addPortalPopup.confirm.button.label": "Save", "mobileApp.portals.drawerNavigation.button.label": "Portals", - "mobileApp.portals.addPortalPopup.validation.emptyFilds": "Empty Fields", + "mobileApp.portals.addPortalPopup.validation.emptyFields": "Empty Fields", "mobileApp.portals.addPortalPopup.validation.portalNameAlreadyExists": "Name already in use", "mobileApp.portals.addPortalPopup.validation.urlInvalid": "Error trying to load the page - check URL and network connection" }