i18n-extract.tcl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env tclsh
  2. #
  3. # Extract translations from source codes into a translation template (pot file).
  4. #
  5. # Copyright 2015-2017 OpenIndex.de.
  6. # Distributed under the MIT License.
  7. # See accompanying LICENSE.txt file or at http://opensource.org/licenses/MIT
  8. #
  9. # initialization
  10. source [file join [file normalize [file dirname $argv0]] init.tcl]
  11. puts ""
  12. puts "========================================================================="
  13. puts " $PROJECT $VERSION: extract translations"
  14. puts "========================================================================="
  15. puts ""
  16. if {$XGETTEXT == "" || ![file isfile $XGETTEXT] || ![file executable $XGETTEXT]} {
  17. puts "ERROR: Can't find the xgettext application!"
  18. exit 1
  19. }
  20. puts "recreate $I18N_POT"
  21. if {[file exists $I18N_POT]} {
  22. file delete $I18N_POT
  23. }
  24. touch $I18N_POT
  25. cd $SRC_APP_DIR
  26. foreach tcl [glob -nocomplain -directory $SRC_APP_DIR -type f "*.tcl"] {
  27. puts "process $tcl"
  28. set f [file tail $tcl]
  29. if { [catch {exec $XGETTEXT -j -c -o [file nativename $I18N_POT] -L Tcl -k_ --copyright-holder=$AUTHOR_NAME --msgid-bugs-address=$AUTHOR_EMAIL $f} result] } {
  30. puts "ERROR: Can't extract translation!"
  31. puts "from: $tcl"
  32. puts $::errorInfo
  33. }
  34. }