Changes

From SME Server
Jump to navigationJump to search
2,791 bytes removed ,  10:06, 5 February 2008
m
Line 85: Line 85:  
  #!/bin/bash
 
  #!/bin/bash
 
  #
 
  #
  #SME Server Create lexocon .po  
+
  #SME Server Create lexicon .po  
 
  −
if  [ -f $1 ]
  −
then
  −
  #convert to UTF-8 while working on pootle
  −
  mv $1 $1.bak
  −
  /usr/bin/iconv -f ISO-8859-1 -t UTF-8 $1.bak > $1
   
   
 
   
  #echo "Remove CDATA and reformat problem codes in $1"
+
  #under constant change...
  perl -pi -e 's/<!\[CDATA\[/STARTCDATA/g' $1
  −
  perl -pi -e 's/\]\]>/ENDCDATA/g' $1
  −
  perl -pi -e 's/\&/AMP/g' $1
  −
  perl -pi -e 's/P\>/p\>/g' $1
  −
  perl -pi -e 's/A\>/a\>/g' $1
  −
  perl -pi -e 's/\<(br|BR)\>/breeak/g' $1
  −
  perl -pi -e 's/\<\/(font|FONT)\>//g' $1
  −
  −
  #echo "Create $1.po"
  −
  xml2po -m empty -e -o $1.po $1
  −
  −
  #echo "Replacing CDATA in $1"
  −
  perl -pi -e 's/STARTCDATA/<!\[CDATA\[/g' $1.po
  −
  perl -pi -e 's/ENDCDATA/\]\]>/g' $1.po
  −
  perl -pi -e 's/AMP/\&/g' $1.po
  −
  perl -pi -e 's/breeak/\<bXr\>/g' $1.po #wiki display error, fixme
  −
  −
  #basic testing
  −
  A=`cat $1.bak |grep '<entry>' |wc -l`
  −
  B=`cat $1.po |grep msgid |wc -l`
  −
  C=`expr $B - 1`
  −
  echo "entries $A, msgid $C"
  −
  −
  if  [ $A -ne $C ]
  −
  then
  −
    echo "Errors in formatting"
  −
    tail $1.po
  −
  fi
  −
 
  −
  #restore original
  −
  mv $1.bak $1
  −
  −
  if  [ ${#2} -gt 0 ]
  −
  then
  −
    echo "<base> entries"
  −
    cat $1 |grep base |sort
  −
  fi
  −
  −
  else
  −
  #print usage informamtion
  −
  echo "Usage: $0 LexiconFilename"
  −
  echo "Usage: $0 LexiconFilename check"
  −
fi
  −
 
  −
:I am wondering why we are using perl to replace as we can also use sed and if readability is not an issue we can do the whole CDATA tag conversin at once
  −
: <pre>sed -e 's/<!\[CDATA\[/STARTCDATA/g' -e 's/\]\]>/ENDCDATA/g' -e 's/\&>/AMP/g' < original.file > conversion.file</pre>
  −
: And back
  −
: <pre>sed -e 's/STARTCDATA/<!\[CDATA\[/g' -e 's/ENDCDATA/\]\]>/g' -e 's/AMP/\&/g' < conversion.file > new.file</pre>
  −
 
  −
::yes but there are more conversions, so it was easier to operate on the one file, efficiency isn't a concern
      
====newpomerge====
 
====newpomerge====
Line 192: Line 136:     
====newxml====
 
====newxml====
#!/bin/bash
+
  #!/bin/bash
  #  
+
  #
 
+
#SME Server Create .xml from .po
  function usage {
  −
  echo ""
  −
  echo "Create .xml from .po"
  −
  echo ""
  −
  echo "Not enough parameters provided."
  −
  echo "Usage: $0 filename (dont add .po)"
  −
  echo ""
  −
  echo "Optional: compare against original"
  −
  echo "Usage: $0 filename check"
  −
  echo ""
  −
  }
  −
  −
  #check for required parameters
  −
  if  [ ${#1} -gt 0  ]
  −
  then
  −
  −
  #echo "Remove CDATA in $1.po"
  −
  cp $1.po $1.bak
  −
  perl -pi -e 's/<!\[CDATA\[/STARTCDATA/g' $1.bak
  −
  perl -pi -e 's/\]\]>/ENDCDATA/g' $1.bak
  −
  perl -pi -e 's/\&/AMP/g' $1.bak
  −
  −
  #echo "Create xml"
  −
  xml2po -p $1.bak $1 > $1.xml
  −
  −
  #echo "Replacing CDATA"
  −
  perl -pi -e 's/STARTCDATA/<!\[CDATA\[/g' $1.xml
  −
  perl -pi -e 's/ENDCDATA/\]\]>/g' $1.xml
  −
  perl -pi -e 's/AMP/\&/g' $1.xml
  −
  −
  #this is added at line 367 xml2po, it needs to be removed or better not added
  −
  #perl -pi -e 's/\<\?xml version="1.0" encoding="utf-8"\?\>//' $1.xml
  −
  −
  #remove first line
  −
  perl -i.old -ne 'print unless 1 .. 1' $1.xml
  −
  −
  rm $1.bak $1.xml.old
  −
  −
  if  [ ${#2} -gt 0  ]
  −
  then
  −
    #echo "#diff -n $1 $1.xml"
  −
    diff -n $1 $1.xml
  −
  fi
   
   
 
   
  else
+
#under constant change...
  #print usage informamtion
  −
  usage
  −
fi
      
===yum===
 
===yum===

Navigation menu