#!/usr/bin/env python
import glob
import os

f = open("langs.conf", "r")
special_langs = {}
for line in f.readlines():
    if line.startswith("#"):
        continue
    lang = line.strip().split("_")
    special_langs[lang[0]] = lang[1]

for po in glob.glob("*.po"):
    head = os.path.splitext(po)[0]
    try:
        po_end = "%s_%s" % (head, special_langs[head])
    except KeyError:
        if "_" in head:
            continue
        else:
            po_end = "%s_%s" % (head, head.upper())

    os.system("mv %s %s.po" % (po, po_end))

