Changes

From SME Server
Jump to navigationJump to search
1,989 bytes added ,  08:33, 3 February 2008
→‎bugs: newpo newxml
Line 37: Line 37:     
===bugs===
 
===bugs===
xml2po ignores tags as CDATA, CDATA does not appear at the PO file.
+
xml2po ignores tags such as CDATA, CDATA does not appear at the PO file.
   −
The workaround is to find and replace the problem code, add more to the list if you find them
+
The workaround is to find and replace the problem code
   −
Using a sample panel yum2
+
this needs work, when creating the first po files
perl -pi -e 's/<!\[CDATA\[/STARTCDATA/g' yum2
+
:/n spaces needs to be replaced,
perl -pi -e 's/\]\]>/ENDCDATA/g' yum2
+
:br shouldn't be used
perl -pi -e 's/\&/AMP/g' yum2
     −
:don't use double quotes
+
====newpo====
:unless & is in a URL write and
+
#!/bin/bash
:delete CDATA if the tag doesn't really require it (for contribs)
+
#
 +
 +
function usage {
 +
  echo ""
 +
  echo "Create po"
 +
  echo ""
 +
  echo "Not enough parameters provided."
 +
  echo "Usage: $0 LexiconFilename"
 +
  echo ""
 +
  echo "Optional: tail end of file"
 +
  echo "Usage: $0 filename check"
 +
  echo ""
 +
}
 +
 +
#check for required parameters
 +
if  [ ${#1} -gt 0  ]
 +
then
 +
 +
  cp $1 $1.bak
 +
 +
  #echo "Remove CDATA in $1"
 +
  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/\<(b r|B R)\>/breeak/g' $1  #remove space
 +
 +
  #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/\<b r\>/g' $1.po  #remove space
 +
 +
  mv $1.bak $1
 +
 +
  if  [ ${#2} -gt 0  ]
 +
  then
 +
    #echo "#tail $1.po"
 +
    tail $1.po
 +
  fi
 +
 +
  else
 +
  #print usage informamtion
 +
  usage
 +
fi
 +
 
 +
====newxml====
 +
#!/bin/bash
 +
#
 +
 
 +
  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
 +
  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
 +
  #print usage informamtion
 +
  usage
 +
fi
    
===subversion===
 
===subversion===

Navigation menu