Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
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.

73 lines
2.2 KiB

11 years ago
9 years ago
11 years ago
11 years ago
9 years ago
9 years ago
11 years ago
9 years ago
9 years ago
9 years ago
  1. #!/bin/bash
  2. FULLPATH=$(dirname $(readlink -f "$0"))
  3. ADDONMODE=
  4. ADDONNAME=
  5. if [ "$1" == "--addon" -o "$1" == "-a" ]
  6. then
  7. ADDONMODE=1
  8. if [ -z $2 ]; then echo -e "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
  9. ADDONNAME=$2
  10. if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi
  11. fi
  12. if [ $ADDONMODE ]
  13. then
  14. cd "$FULLPATH/../addon/$ADDONNAME"
  15. mkdir -p "$FULLPATH/../addon/$ADDONNAME/lang/C"
  16. OUTFILE="$FULLPATH/../addon/$ADDONNAME/lang/C/messages.po"
  17. FINDSTARTDIR="."
  18. FINDOPTS=
  19. else
  20. cd "$FULLPATH/../view/en/"
  21. OUTFILE="$FULLPATH/messages.po"
  22. FINDSTARTDIR="../../"
  23. # skip addon folder
  24. FINDOPTS="-wholename */addon -prune -o"
  25. fi
  26. F9KVERSION=$(sed -n "s/.*'FRIENDICA_VERSION'.*'\([0-9.]*\)'.*/\1/p" ../../boot.php);
  27. echo "Friendica version $F9KVERSION"
  28. KEYWORDS="-k -kt -ktt:1,2"
  29. echo "extract strings to $OUTFILE.."
  30. rm "$OUTFILE"; touch "$OUTFILE"
  31. for f in $(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f)
  32. do
  33. if [ ! -d "$f" ]
  34. then
  35. xgettext $KEYWORDS -j -o "$OUTFILE" --from-code=UTF-8 "$f"
  36. sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
  37. fi
  38. done
  39. echo "setup base info.."
  40. if [ $ADDONMODE ]
  41. then
  42. sed -i "s/SOME DESCRIPTIVE TITLE./ADDON $ADDONNAME/g" "$OUTFILE"
  43. sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER//g" "$OUTFILE"
  44. sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.//g" "$OUTFILE"
  45. sed -i "s/PACKAGE VERSION//g" "$OUTFILE"
  46. sed -i "s/PACKAGE/Friendica $ADDONNAME addon/g" "$OUTFILE"
  47. sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
  48. sed -i "s/^\"Plural-Forms.*$//g" "$OUTFILE"
  49. else
  50. sed -i "s/SOME DESCRIPTIVE TITLE./FRIENDICA Distributed Social Network/g" "$OUTFILE"
  51. sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2010, 2011, 2012, 2013 the Friendica Project/g" "$OUTFILE"
  52. sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Mike Macgirvin, 2010/g" "$OUTFILE"
  53. sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE"
  54. sed -i "s/PACKAGE/Friendica/g" "$OUTFILE"
  55. sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
  56. sed -i "s/^\"Plural-Forms.*$//g" "$OUTFILE"
  57. fi
  58. if [ "" != "$1" -a "$ADDONMODE" == "" ]
  59. then
  60. UPDATEFILE="$(readlink -f ${FULLPATH}/$1)"
  61. echo "merging new strings to $UPDATEFILE.."
  62. msgmerge -U $OUTFILE $UPDATEFILE
  63. fi
  64. echo "done."