import-po 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh -e
  2. # Update po files using launchpad-export.tar.gz
  3. WORK_DIR=launchpad-work
  4. INPUT_TGZ=$1
  5. PO_DIR=po
  6. if [ -z "$INPUT_TGZ" ]; then
  7. echo "Usage: import-po /path/to/launchpad-export.tar.gz"
  8. echo "Specify input launchpad-export.tar.gz file"
  9. exit 1
  10. fi
  11. if [ ! -e "$INPUT_TGZ" ]; then
  12. echo "Input file $INPUT_TGZ does not exist"
  13. exit 1
  14. fi
  15. if [ -e "$WORK_DIR" ]; then
  16. rm -rf "$WORK_DIR"
  17. fi
  18. mkdir "$WORK_DIR"
  19. echo "Extracting po files from the archive..."
  20. tar -x -C "$WORK_DIR" -f "$INPUT_TGZ"
  21. echo "Renaming po files..."
  22. # The directory structure of launchpad-export.tar.gz is a bit
  23. # strange. It even contains absolute file path. We first gather all
  24. # files in top level directory.
  25. mv "$WORK_DIR"/aria2/*.po "$WORK_DIR"
  26. echo -n "en@quot en@boldquot" > "$PO_DIR"/LINGUAS
  27. for file in "$WORK_DIR"/*.po; do
  28. # First remove useless '\r' in messages
  29. sed -i -e 's/\\r//' "$file"
  30. bn=`basename "$file"`
  31. bn=${bn#aria2-}
  32. dst="$PO_DIR"/"$bn"
  33. # copy file to po directory
  34. echo "Moving \`$file' to \`$dst'..."
  35. mv "$file" "$dst"
  36. # Upate LINGUAS here too.
  37. echo -n " ${bn%.po}" >> "$PO_DIR"/LINGUAS
  38. done
  39. rm -rf "$WORK_DIR"
  40. cd "$PO_DIR"
  41. make update-po