#!/bin/sh
# Copyright (C) 2009 Osamu Aoki <osamu@debian.org>
#
# This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of
# the GNU General Public License version 2 or later.
# 
# Split PO file.
#
#    po4a-strip chunks file.po
#
#    ... output file.1.po file.2.po into chunks
#
#  Use "wc -l file.po" to get rough idea.
#
c=$1
filein=$2
m=$( wc -l <$filein )
n=$(( $m/$c ))
fileout=${filein%.po}
i=1
l=1
while read X ; do
  echo "$X" >> $fileout.$i.po
  #echo $n $l $(( $n*$i )) $i
  if [ $l -ge $(( $n*$i )) ] && [ -z "$X" ]; then
    i=$(($i+1))  
  fi
  l=$(($l+1))
done < $filein

#
#
# vim: set sts=2 ai expandtab:

