Advertisement
Guest User

Extracting literals

a guest
Feb 19th, 2011
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.52 KB | None | 0 0
  1. #!/bin/sh
  2. BASEDIR="../"    # root of translatable sources
  3. PROJECT="myprogram"        # project name
  4. WDIR=`pwd`              # working dir
  5.  
  6.  
  7. echo "Preparing rc files"
  8. cd ${BASEDIR}
  9. # we use simple sorting to make sure the lines do not jump around too much from system to system
  10. find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list
  11. xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp
  12. # additional string for KAboutData
  13. echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> ${WDIR}/rc.cpp
  14. echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> ${WDIR}/rc.cpp
  15. cd ${WDIR}
  16. echo "Done preparing rc files"
  17.  
  18.  
  19. echo "Extracting messages"
  20. cd ${BASEDIR}
  21. # see above on sorting
  22. find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | sort > ${WDIR}/infiles.list
  23. echo "rc.cpp" >> ${WDIR}/infiles.list
  24. cd ${WDIR}
  25. xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \
  26.         -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
  27.         --files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; }
  28. echo "Done extracting messages"
  29.  
  30.  
  31. echo "Merging translations"
  32. catalogs=`find . -name '*.po'`
  33. for cat in $catalogs; do
  34.   echo $cat
  35.   msgmerge -o $cat.new $cat ${PROJECT}.pot
  36.   mv $cat.new $cat
  37. done
  38. echo "Done merging translations"
  39.  
  40.  
  41. echo "Cleaning up"
  42. cd ${WDIR}
  43. rm rcfiles.list
  44. rm infiles.list
  45. rm rc.cpp
  46. echo "Done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement