#!/bin/bash

# Template nfo language file
template=nfo/dummy_lang.tnfo

lang_files=`ls lang/*.lng`

file=lang/english.lng

langid=`cat $file | grep '##grflangid' | cut -dx -f2`
let "tmp = 0x80 + $langid"

echo "$tmp"
use_id=`printf "%x\n" $tmp`
echo "Used ID: $use_id"

cat lang/english.lng | grep '^STR' | sed 's/\//\\\//g' | sed 's/^STR/s\/STR/g' | sed 's/ *:/\//' | sed 's/$/\/g/g' > sed.tmp

cat $template | sed s/LANGID/$use_id/g | sed -f sed.tmp > nfo/$(basename $file .lng).pnfo
