make translate.sh more robust
This commit is contained in:
		
							parent
							
								
									3b93b14e29
								
							
						
					
					
						commit
						f260da3594
					
				
					 1 changed files with 22 additions and 17 deletions
				
			
		
							
								
								
									
										37
									
								
								setup.sh
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								setup.sh
									
										
									
									
									
								
							| 
						 | 
					@ -885,29 +885,34 @@ set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd "$(dirname "$0")/steam-gift-manager"
 | 
					cd "$(dirname "$0")/steam-gift-manager"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare -A locales=(
 | 
					declare -a locales=("de" "en")
 | 
				
			||||||
  ["de"]="de"
 | 
					 | 
				
			||||||
  ["en"]="en"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# create POT-file
 | 
					docker-compose run --rm steam-manager pybabel extract -F babel.cfg -o translations/messages.pot .
 | 
				
			||||||
docker-compose exec steam-manager pybabel extract -F babel.cfg -o translations/messages.pot .
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Check for each language and initialize if necessary
 | 
					for lang in "${locales[@]}"; do
 | 
				
			||||||
for lang in "${!locales[@]}"; do
 | 
					  po_path="translations/${lang}/LC_MESSAGES/messages.po"
 | 
				
			||||||
  if [ ! -f "translations/${locales[$lang]}/LC_MESSAGES/messages.po" ]; then
 | 
					  
 | 
				
			||||||
    docker-compose exec steam-manager pybabel init \
 | 
					  if [ -f "$po_path" ]; then
 | 
				
			||||||
 | 
					    encoding=$(file -i "$po_path" | grep -Po 'charset=\K.+')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if [[ "$encoding" != "utf-8" ]]; then
 | 
				
			||||||
 | 
					      echo "Konvertiere $po_path von $encoding nach UTF-8"
 | 
				
			||||||
 | 
					      iconv -f "$encoding" -t UTF-8 "$po_path" > "$po_path.utf8"
 | 
				
			||||||
 | 
					      mv "$po_path.utf8" "$po_path"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  docker-compose run --rm steam-manager pybabel update \
 | 
				
			||||||
    -i translations/messages.pot \
 | 
					    -i translations/messages.pot \
 | 
				
			||||||
    -d translations \
 | 
					    -d translations \
 | 
				
			||||||
      -l "${locales[$lang]}"
 | 
					    -l "$lang" \
 | 
				
			||||||
  fi
 | 
					    --previous
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Update and compile translations
 | 
					docker-compose run --rm steam-manager pybabel compile -d translations
 | 
				
			||||||
docker-compose exec steam-manager pybabel update -i translations/messages.pot -d translations
 | 
					
 | 
				
			||||||
docker-compose exec steam-manager pybabel compile -d translations
 | 
					echo "✅ Setup and/or update translations done! YOLO"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "✅ Translations updated!"
 | 
					 | 
				
			||||||
SCRIPT_END
 | 
					SCRIPT_END
 | 
				
			||||||
chmod +x ../translate.sh
 | 
					chmod +x ../translate.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue