File: propogate-params.sh

package info (click to toggle)
xml-resume-library 1.5.1-9
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,516 kB
  • ctags: 424
  • sloc: xml: 867; makefile: 126; sh: 47
file content (47 lines) | stat: -rw-r--r-- 1,634 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

SOURCE=us.xsl

# propogate-translations.sh
# By Mark Miller, though he is not proud of it.
#
# This is a quick and VERY DIRTY way to add any new params defined
# in us.xsl (or $SOURCE) to the rest of the country.xsl stylesheets
# with a \"TRANSLATION NEEDED\" message.  It also checks for outdated 
# params existing in other country.xsl files but not in $SOURCE
#
# IMPORTANT: After running this script, you must manually edit each 
# .xsl file and make sure that all the xsl:param tags are INSIDE the
# <xsl:stylesheet> tags.  This script does NOT do that for you.
#
# WARNING: This script is by no means fool-proof, and only included
# to make life slightly easier for developers.  Please manually edit
# each .xsl file after running to be sure that the script has not
# screwed anything up. "

echo "======== Checking Files for outdated params..."
for country in `ls -1 *.xsl`; do 
  for param in `grep '<xsl:param' $country | \
   		perl -p -e 's/.*name=\"(.*)\"\>.*\<\/xsl:param\>/$1/g`; 
  do
    exists=`grep -c $param $SOURCE`
    if [ "0" = $exists ]; then 
      echo "Param $param in file $country does not exist in $SOURCE."
    fi
  done
done  

echo "======== Adding params in $SOURCE to other files as necessary..."
for country in `ls -1 *.xsl`; do 
  for param in `grep '<xsl:param' $SOURCE | \
   		perl -p -e 's/.*name=\"(.*)\"\>.*\<\/xsl:param\>/$1/g`; 
  do
    translated=`grep -c $param $country`
    if [ "0" = $translated ]; 
    then 
      echo "Adding param $param to $country"
      echo "  <xsl:param name=\"$param\">TRANSLATION NEEDED</xsl:param>" >> $country
    fi
  done
done
echo "Done."