util/TranslationCatalogs.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 22 Apr 2016 19:49:10 +0300
changeset 1502 62eb21aab1fb
parent 817 1a3cc2065216
child 1511 91538d0c242c
permissions -rw-r--r--
fix display of ARRAY fields inside of structure data types.

Previously ARRAY fields in structures were displayed, for example,
like 'ARRAY [1..2] OF ARRAY' instead of 'ARRAY [1..2] OF INT'. Because
of this error the array type can be really edited.
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os 

import wx

# Get the default language
langid = wx.LANGUAGE_DEFAULT

# Define locale for wx
locale = wx.Locale(langid)

def GetDomain(path):
    for name in os.listdir(path):
        filepath = os.path.join(path, name)
        basename, fileext = os.path.splitext(name)
        if os.path.isdir(filepath):
            result = GetDomain(filepath)
            if result is not None:
                return result
        elif fileext == ".mo":
            return basename
    return None

def AddCatalog(locale_dir):
    if os.path.exists(locale_dir) and os.path.isdir(locale_dir):
        domain = GetDomain(locale_dir)
        if domain is not None:
            locale.AddCatalogLookupPathPrefix(locale_dir)
            locale.AddCatalog(domain)