ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

94 lines
2.2 KiB

  1. #!/bin/bash
  2. set -eu
  3. declare -A languages
  4. defaultLanguage="en-US"
  5. # Supported languages
  6. languages=(
  7. ["ar"]="ar"
  8. ["is"]="is"
  9. ["tr"]="tr-TR"
  10. ["fa"]="fa-IR"
  11. ["en"]="en-US"
  12. ["vi"]="vi-VN"
  13. ["hu"]="hu-HU"
  14. ["th"]="th-TH"
  15. ["fi"]="fi-FI"
  16. ["nl"]="nl-NL"
  17. ["gd"]="gd"
  18. ["el"]="el-GR"
  19. ["es"]="es-ES"
  20. ["oc"]="oc"
  21. ["pt"]="pt-BR"
  22. ["pt-PT"]="pt-PT"
  23. ["sv"]="sv-SE"
  24. ["pl"]="pl-PL"
  25. ["ru"]="ru-RU"
  26. ["zh-Hans"]="zh-Hans-CN"
  27. ["zh-Hant"]="zh-Hant-TW"
  28. ["fr"]="fr-FR"
  29. ["ja"]="ja-JP"
  30. ["eu"]="eu-ES"
  31. ["ca"]="ca-ES"
  32. ["gl"]="gl-ES"
  33. ["cs"]="cs-CZ"
  34. ["hr"]="hr"
  35. ["eo"]="eo"
  36. ["de"]="de-DE"
  37. ["it"]="it-IT"
  38. ["uk"]="uk-UA"
  39. ["sq"]="sq"
  40. ["tok"]="tok"
  41. ["nn"]="nn"
  42. ["nb"]="nb-NO"
  43. ["kab"]="kab"
  44. )
  45. cd client
  46. rm -rf ./dist
  47. # Don't build other languages if --light arg is provided
  48. if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); then
  49. additionalParams=""
  50. if [ ! -z ${1+x} ] && [ "$1" == "--source-map" ]; then
  51. additionalParams="--source-map=true"
  52. fi
  53. node --max_old_space_size=8192 node_modules/.bin/ng build --configuration production --output-path "dist/build" $additionalParams
  54. for key in "${!languages[@]}"; do
  55. lang=${languages[$key]}
  56. mv "dist/build/browser/$key" "dist/$lang"
  57. if [ "$lang" != "en-US" ]; then
  58. # Do not duplicate assets
  59. rm -r "./dist/$lang/assets"
  60. fi
  61. done
  62. mv "./dist/$defaultLanguage/assets" "./dist"
  63. rm -r "dist/build"
  64. cp "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
  65. else
  66. additionalParams=""
  67. if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then
  68. additionalParams="--named-chunks=true --output-hashing=none"
  69. # For Vite
  70. export ANALYZE_BUNDLE=true
  71. fi
  72. node --max_old_space_size=8192 node_modules/.bin/ng build --localize=false --output-path "dist/$defaultLanguage/" \
  73. --configuration production --stats-json $additionalParams
  74. fi
  75. cd ../ && npm run build:embed && cd client/
  76. # Copy runtime locales
  77. cp -r "./src/locale" "./dist/locale"