--- trunk/installer-simple/generate-po.sh 2014/01/06 12:24:58 2356 +++ trunk/installer-simple/generate-po.sh 2014/01/06 12:26:01 2357 @@ -12,6 +12,7 @@ echo "Known methods:" echo " --create-pot - creates pot file from script" echo " --append-pot - appends current pot file with script" + echo " --unique-pot - remove duplicates from pot file" echo " --generate - generates pot and po files" echo " --compile - compiles mo files" echo @@ -39,6 +40,30 @@ bash --dump-po-strings "${script}" >> "${pot}" } +unique_pot() +{ + local pot + + install -d locale + pot="locale/${domain}.pot" + if [ ! -f "${pot}" ] + then + echo "Error: ${pot} missing - run --create-pot or --append-pot" + exit 1 + fi + + # remove duplicate messages + msguniq --unique --no-wrap --sort-by-file --output-file="${pot}.fixed" "${pot}" + if [[ $? = 0 ]] + then + rm "${pot}" + mv "${pot}.fixed" "${pot}" + else + echo "Error: msguniq failed" + exit 1 + fi +} + generate_po() { local lang @@ -103,6 +128,7 @@ case ${method} in --create-pot) create_pot ;; --append-pot) append_pot ;; + --unique-pot) unique_pot ;; --generate) generate_po ;; --compile) generate_mo ;; *) usage ;;