#!/usr/bin/env python


"""
Script to compile locales

The locales will be placed in the 'locale' subdirectory of the main tree.
"""


import os
import glob


base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
for po_file in glob.glob(os.path.join(base_path, 'po/*.po')):
    locale = os.path.basename(po_file[:-3])
    mo_dir = os.path.join(base_path, 'locale', locale, 'LC_MESSAGES')
    mo_file = os.path.join(mo_dir, 'vboxgtk.mo')
    if not os.path.isdir(mo_dir): 
        os.makedirs(mo_dir)
    os.system("msgfmt %s -o %s" % (po_file, mo_file))
