diff --git a/freecad/gears/translations/Gear_zh-TW.ts b/freecad/gears/translations/Gear_zh-TW.ts index 6172621..b52f3d1 100644 --- a/freecad/gears/translations/Gear_zh-TW.ts +++ b/freecad/gears/translations/Gear_zh-TW.ts @@ -1,6 +1,6 @@ - + App::Property diff --git a/freecad/gears/translations/update_translation.sh b/freecad/gears/translations/update_translation.sh index 0f9a997..7e880d7 100755 --- a/freecad/gears/translations/update_translation.sh +++ b/freecad/gears/translations/update_translation.sh @@ -4,15 +4,15 @@ # # Create, update and release translation files. # -# Supported locales on FreeCAD <2024-09-12, FreeCADGui.supportedLocales(), total=43>: +# Supported locales on FreeCAD <2024-11-30, FreeCADGui.supportedLocales(), total=44>: # {'English': 'en', 'Afrikaans': 'af', 'Arabic': 'ar', 'Basque': 'eu', 'Belarusian': 'be', # 'Bulgarian': 'bg', 'Catalan': 'ca', 'Chinese Simplified': 'zh-CN', -# 'Chinese Traditional': 'zh-TW', 'Croatian': 'hr', 'Czech': 'cs', 'Dutch': 'nl', -# 'Filipino': 'fil', 'Finnish': 'fi', 'French': 'fr', 'Galician': 'gl', 'Georgian': 'ka', -# 'German': 'de', 'Greek': 'el', 'Hungarian': 'hu', 'Indonesian': 'id', 'Italian': 'it', -# 'Japanese': 'ja', 'Kabyle': 'kab', 'Korean': 'ko', 'Lithuanian': 'lt', 'Norwegian': 'no', -# 'Polish': 'pl', 'Portuguese': 'pt-PT', 'Portuguese, Brazilian': 'pt-BR', 'Romanian': 'ro', -# 'Russian': 'ru', 'Serbian': 'sr', 'Serbian, Latin': 'sr-CS', 'Slovak': 'sk', +# 'Chinese Traditional': 'zh-TW', 'Croatian': 'hr', 'Czech': 'cs', 'Danish': 'da', +# 'Dutch': 'nl', 'Filipino': 'fil', 'Finnish': 'fi', 'French': 'fr', 'Galician': 'gl', +# 'Georgian': 'ka', 'German': 'de', 'Greek': 'el', 'Hungarian': 'hu', 'Indonesian': 'id', +# 'Italian': 'it', 'Japanese': 'ja', 'Kabyle': 'kab', 'Korean': 'ko', 'Lithuanian': 'lt', +# 'Norwegian': 'no', 'Polish': 'pl', 'Portuguese': 'pt-PT', 'Portuguese, Brazilian': 'pt-BR', +# 'Romanian': 'ro', 'Russian': 'ru', 'Serbian': 'sr', 'Serbian, Latin': 'sr-CS', 'Slovak': 'sk', # 'Slovenian': 'sl', 'Spanish': 'es-ES', 'Spanish, Argentina': 'es-AR', 'Swedish': 'sv-SE', # 'Turkish': 'tr', 'Ukrainian': 'uk', 'Valencian': 'val-ES', 'Vietnamese': 'vi'} # @@ -48,10 +48,10 @@ supported_locales=( "en" "af" "ar" "eu" "be" "bg" "ca" "zh-CN" "zh-TW" "hr" - "cs" "nl" "fil" "fi" "fr" "gl" "ka" "de" "el" "hu" - "id" "it" "ja" "kab" "ko" "lt" "no" "pl" "pt-PT" "pt-BR" - "ro" "ru" "sr" "sr-CS" "sk" "sl" "es-ES" "es-AR" "sv-SE" "tr" - "uk" "val-ES" "vi" + "cs" "da" "nl" "fil" "fi" "fr" "gl" "ka" "de" "el" + "hu" "id" "it" "ja" "kab" "ko" "lt" "no" "pl" "pt-PT" + "pt-BR" "ro" "ru" "sr" "sr-CS" "sk" "sl" "es-ES" "es-AR" "sv-SE" + "tr" "uk" "val-ES" "vi" ) is_locale_supported() { @@ -66,7 +66,7 @@ update_locale() { local locale="$1" local u=${locale:+_} # Conditional underscore - # NOTE: Execute the right commands depending on: + # NOTE: Execute the right command depending on: # - if it's a locale file or the main, agnostic one [ ! -f "${WB}${u}${locale}.ts" ] && action="Creating" || action="Updating" echo -e "\033[1;34m\n\t<<< ${action} '${WB}${u}${locale}.ts' file >>>\n\033[m" @@ -78,16 +78,38 @@ update_locale() { fi } +normalize_crowdin_files() { + # Rename files which locales are different on FreeCAD and delete not supported locales + crowdin_fixes=(af-ZA ar-SA be-BY bg-BG ca-ES cs-CZ da-DK de-DE el-GR eu-ES fi-FI + fil-PH fr-FR gl-ES hr-HR hu-HU it-IT ja-JP ka-GE kab-KAB ko-KR lt-LT nl-NL + no-NO pl-PL ro-RO ru-RU sk-SK sl-SI sr-SP tr-TR uk-UA vi-VN) + + crowdin_deletes=(az-AZ bn-BD br-FR bs-BA en en-GB en-US eo-UY es-CO es-VE et-EE fa-IR he-IL + hi-IN hy-AM id-ID kaa lv-LV mk-MK ms-MY sat-IN si-LK ta-IN te-IN th-TH ur-PK xav yo-NG) + + for pattern in "${crowdin_fixes[@]}"; do + find . -type f -name "*_${pattern}\.*" | while read -r file; do + new_name=${file//-*./.} + mv -v "$file" "$new_name" + done + done + + for pattern in "${crowdin_deletes[@]}"; do + find . -type f -name "*_${pattern}\.*" -delete + done +} + help() { echo -e "\nDescription:" echo -e "\tCreate, update and release translation files." echo -e "\nUsage:" echo -e "\t./update_translation.sh [-R] [-U] [-r ] [-u ]" echo -e "\nFlags:" - echo -e " -R\n\tRelease all locales" - echo -e " -U\n\tUpdate main translation file (locale agnostic)" + echo -e " -R\n\tRelease all translations (qm files)" + echo -e " -U\n\tUpdate all translations (ts files)" echo -e " -r \n\tRelease the specified locale" echo -e " -u \n\tUpdate strings for the specified locale" + echo -e " -N\n\tNormalize CrowdIn filenames" } # Main function ------------------------------------------------------------------------------------ @@ -98,8 +120,8 @@ LRELEASE=/usr/lib/qt6/bin/lrelease # from Qt6 # LRELEASE=lrelease # from Qt5 WB="Gear" -# Enforce underscore on locales -sed -i '3s/-/_/' ${WB}*.ts +sed -i '3s/-/_/' ${WB}*.ts # Enforce underscore on locales +sed -i '3s/\"en\"/\"en_US\"/g' ${WB}*.ts # Use en_US if [ $# -eq 1 ]; then if [ "$1" == "-R" ]; then @@ -109,8 +131,13 @@ if [ $# -eq 1 ]; then echo done elif [ "$1" == "-U" ]; then - # Update main file (agnostic) - update_locale + for locale in "${supported_locales[@]}"; do + update_locale "$locale" + done + elif [ "$1" == "-u" ]; then + update_locale # Update main file (agnostic) + elif [ "$1" == "-N" ]; then + normalize_crowdin_files else help fi @@ -128,7 +155,7 @@ elif [ $# -eq 2 ]; then else echo "Verify your language code. Case sensitive." echo "If it's correct, ask a maintainer to add support for your language on FreeCAD." - echo -e "Supported locales, '\033[1;34mFreeCADGui.supportedLocales()\033[m': \033[1;33m" + echo -e "\nSupported locales, '\033[1;34mFreeCADGui.supportedLocales()\033[m': \033[1;33m" for locale in $(printf "%s\n" "${supported_locales[@]}" | sort); do echo -n "$locale " done