def create_so_catalog(locales, domain): """ Creates a message catalog based on list of locales from existing GNU message catalog """ TG_Message.dropTable(ifExists=True) TG_Domain.dropTable(ifExists=True) TG_Domain.createTable(ifNotExists=True) TG_Message.createTable(ifNotExists=True) localedir = turbogears.config.get("i18n.locale_dir", "locales") try: domain = TG_Domain.byName(domain) return except SQLObjectNotFound: domain = TG_Domain(name=domain) for locale in locales: translations = translation(domain=domain.name, localedir=localedir, languages=[locale]) catalog = translations._catalog for k, v in catalog.items(): TG_Message(domain=domain, locale=locale, name=k, text=v)
def create_so_catalog(locales, domain): """ Creates a message catalog based on list of locales from existing GNU message catalog """ TG_Message.dropTable(ifExists=True) TG_Domain.dropTable(ifExists=True) TG_Domain.createTable(ifNotExists=True) TG_Message.createTable(ifNotExists=True) localedir = turbogears.config.get("i18n.locale_dir", "locales") try: domain = TG_Domain.byName(domain) return except SQLObjectNotFound: domain = TG_Domain(name=domain) for locale in locales: translations = translation( domain=domain.name, localedir=localedir, languages=[locale]) catalog = translations._catalog for k, v in catalog.items(): TG_Message(domain=domain, locale=locale, name=k, text=v)
def create_so_catalog_tables(): """create the tables if needed """ TG_Message.dropTable(ifExists=True) TG_Domain.dropTable(ifExists=True) TG_Domain.createTable(ifNotExists=True) TG_Message.createTable(ifNotExists=True)