Exemplo n.º 1
0
def dump_i18n_message_ids():
    """Dump msgids from Descriptor Field labels and descriptions
    for internationalization.
    """
    # ensure localization files are loaded (and naming.MSGIDS correctly primed)
    from bungeni.ui import feature
    feature.setup_customization_ui()
    #localization.check_reload_localization(None) #!+ AssertionError from custom roles...
    from os import path
    import bungeni.ui  # !+ simply using __file__ gives erroneous abspath!
    msgids_py_source_file_path = path.join(
        path.dirname(path.abspath(bungeni.ui.__file__)), "descriptor",
        "_dumped_msgids.py")

    print
    print "Processing UI Field i18n MSGID file: %s" % (
        msgids_py_source_file_path)
    msgids_py_source_preamble = [
        "# automatically generated: dump_i18n_message_ids",
        "from bungeni.ui.i18n import _", ""
    ]
    msgids_py_source = "\n".join(
        msgids_py_source_preamble +
        ["_(%r)" % msgid for msgid in sorted(naming.MSGIDS)])
    misc.check_overwrite_file(msgids_py_source_file_path, msgids_py_source)
Exemplo n.º 2
0
def dump_i18n_message_ids():
    """Dump msgids from Descriptor Field labels and descriptions
    for internationalization.
    """
    # ensure localization files are loaded (and naming.MSGIDS correctly primed)
    import bungeni.feature.ui
    bungeni.feature.ui.setup_customization_ui()
    #localization.forms_localization_init() #!+ AssertionError from custom roles...
    from os import path
    import bungeni.ui # !+ simply using __file__ gives erroneous abspath!
    msgids_py_source_file_path = path.join(
        path.dirname(path.abspath(bungeni.ui.__file__)), "descriptor", "_dumped_msgids.py")
    
    print
    print "Processing UI Field i18n MSGID file: %s" % (msgids_py_source_file_path)
    msgids_py_source_preamble = [
        "# automatically generated: dump_i18n_message_ids",
        "from bungeni import _", 
        ""]
    def make_message(msgid):
        """generate message with unique id if any or use string as id"""
        if isinstance(msgid, tuple):
            return """_("%s", default="%s")""" %(msgid[0], msgid[1])
        else:
            return "_(%r)" % msgid
    msgids_py_source = "\n".join(msgids_py_source_preamble + [
            make_message(msgid) for msgid in sorted(naming.MSGIDS) ])
    misc.check_overwrite_file(msgids_py_source_file_path, msgids_py_source, log_handler=LOG_HANDLER)
Exemplo n.º 3
0
def reset_localization_system_descriptors():
    print
    print "Processing localization file: %s" % (
        localization.PATH_UI_FORMS_SYSTEM)
    regenerated = "\n".join(serialize_module(localization.DESCRIPTOR_MODULE))
    misc.check_overwrite_file(
        localization.PATH_UI_FORMS_SYSTEM,
        regenerated,
        log_handler=LOG_HANDLER)
Exemplo n.º 4
0
def apply_customization_ui():
    """Called from ui.app.on_wsgi_application_created_event -- must be called
    AFTER custom types have been catalysed.
    """
    # combine config string and execute it
    zcml = ZCML_SLUG.format(ui_zcml_decls="".join([ zd for zd in UI_ZC_DECLS ]))
    # log zcml directives to a dedicated file (before executing), for easier debugging
    misc.check_overwrite_file(capi.get_path_for("workflows/.auto/ui.zcml"), 
        '<?xml version="1.0"?>\n<!-- !! AUTO-GENERATED !! DO NOT MODIFY !! -->' + zcml)
    # execute the zcml
    log.debug("Executing UI feature configuration:\n%s", zcml)
    xmlconfig.string(zcml)
Exemplo n.º 5
0
def dump_i18n_message_ids():
    """Dump msgids from Descriptor Field labels and descriptions
    for internationalization.
    """
    # ensure localization files are loaded (and naming.MSGIDS correctly primed)
    from bungeni.ui import feature
    feature.setup_customization_ui()
    localization.check_reload_localization(None)
    from os import path
    msgids_py_source_file_path = path.join(
        path.dirname(path.abspath(__file__)), "_dumped_msgids.py")
    print
    print "Processing UI Field i18n MSGID file: %s" % (msgids_py_source_file_path)
    msgids_py_source_preamble = [
        "# automatically generated: dump_i18n_message_ids",
        "from bungeni.ui.i18n import _", 
        ""]
    msgids_py_source = "\n".join(msgids_py_source_preamble + [
            "_(%r)" % msgid for msgid in sorted(naming.MSGIDS) ])
    misc.check_overwrite_file(msgids_py_source_file_path, msgids_py_source)
Exemplo n.º 6
0
def reset_localization_system_descriptors():
    print
    print "Processing localization file: %s" % (localization.PATH_UI_FORMS_SYSTEM)
    regenerated = "\n".join(serialize_module(localization.DESCRIPTOR_MODULE))
    misc.check_overwrite_file(localization.PATH_UI_FORMS_SYSTEM, regenerated)
Exemplo n.º 7
0
def zcml_check_regenerate():
    """For debug purposes; called after loading of all XML workflows (adapers.py).
    """
    misc.check_overwrite_file(
        capi.get_path_for(os.path.join("workflows/.auto/", ZCML_FILENAME)),
        ZCML_BOILERPLATE % ("\n".join(ZCML_LINES)))
Exemplo n.º 8
0
def zcml_check_regenerate():
    """For debug purposes; called after loading of all XML workflows (adapers.py).
    """
    misc.check_overwrite_file(
        capi.get_path_for(os.path.join("workflows/.auto/", ZCML_FILENAME)),
        ZCML_BOILERPLATE % ("\n".join(ZCML_LINES)))