translation-update.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. # This script performs the following:
  3. # - Generate configuration file for po4a (can be configured in CONFIGFILE)
  4. # - Generate POT file from pages/<DIRECTORY>/*.md
  5. # - Update PO files in i18n directory with POT file
  6. # - Generate localized pages.XX/<DIRECTORY>/*.md (where XX is the language code)
  7. # - Remove unneeded new lines from generated pages
  8. # Name of the po4a configuration file
  9. CONFIGFILE='po4a.conf'
  10. # List of supported languages
  11. LANGS=(fr)
  12. # Check if po4a is installed
  13. if [ -z "$(command -v po4a)" ]; then
  14. echo 'It seems that po4a is not installed on your system.'
  15. echo 'Please install po4a to use this script.'
  16. exit 1
  17. fi
  18. # Generate po4a.conf file with list of TLDR pages
  19. echo 'Generating configuration file for po4a…'
  20. {
  21. echo '# WARNING: this file is generated with translation-update.sh'
  22. echo '# DO NOT modify this file manually!'
  23. echo "[po4a_langs] ${LANGS[*]}"
  24. # shellcheck disable=SC2016
  25. echo '[po4a_paths] i18n/templates/freshrss.pot $lang:i18n/freshrss.$lang.po'
  26. } >$CONFIGFILE
  27. for FILE in $(cd en && tree -f -i | grep ".md" | grep -v "admins"); do
  28. echo "[type: text] en/$FILE \$lang:\$lang/$FILE opt:\"-o markdown\" opt:\"-M utf-8\"" >>$CONFIGFILE
  29. done
  30. # Generate POT file, PO files, and pages.XX pages
  31. echo 'Generating POT file and translated pages…'
  32. po4a -k 0 --msgid-bugs-address 'https://github.com/FreshRSS/FreshRSS/issues' $CONFIGFILE