Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
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.

filenames.sh 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. inc_filenames=true
  3. [ -z "$inc_languages" ] && . "$basedir/build/languages.sh"
  4. list_langs(){
  5. # list all languages a file exists in by globbing up
  6. # the shortname (i.e. file path with file ending omitted)
  7. # output is readily formated for inclusion
  8. # in xml stream
  9. shortname="$1"
  10. langfilter=$(
  11. echo "$shortname".[a-z][a-z].xhtml \
  12. | sed -r 's;[^ ]+.([a-z]{2}).xhtml;\1;g;s; ;|;g'
  13. )
  14. languages |egrep "^($langfilter) " \
  15. | sed -r 's:^([a-z]{2}) (.+)$:<tr id="\1">\2</tr>:g'
  16. }
  17. get_language(){
  18. # extract language indicator from a given file name
  19. echo "$(echo "$1" |sed -r 's:^.*\.([a-z]{2})\.[^\.]+$:\1:')";
  20. }
  21. get_shortname(){
  22. # get shortened version of a given file name
  23. # required for internal processing
  24. #echo "$(echo "$1" | sed -r 's:\.[a-z]{2}.xhtml$::')";
  25. echo "${1%.??.xhtml}"
  26. }
  27. get_processor(){
  28. # find the xslt script which is responsible for processing
  29. # a given xhtml file.
  30. # expects the shortname of the file as input (i.e. the
  31. # the file path without language and file endings)
  32. shortname="$1"
  33. if [ -f "${shortname}.xsl" ]; then
  34. echo "${shortname}.xsl"
  35. else
  36. location="${shortname%/*}"
  37. until [ -f "$location/default.xsl" -o "$location" = . -o "$location" = / ]; do
  38. location="${location%/*}"
  39. done
  40. echo "$location/default.xsl"
  41. fi
  42. }