Exemplo n.º 1
0
def initialize(app):
    '''
    Initializes extension after environment is initialized.
    '''
    # ensure website config value ends with "/"
    if not app.config.website[-1] == "/":
        app.config.website += "/"

    # initialize other components
    metadata.initialize(app)
    filing.initialize(app)

    # localization
    languages = [app.config.language] if app.config.language else None

    locale_dir = ""
    try:
        from pkg_resources import resource_filename
    except ImportError:
        resource_filename = None

    if resource_filename is not None:
        try:
            locale_dir = resource_filename(__name__, "/locale")
        except NotImplementedError:
            # resource_filename doesn't work with non-egg zip files
            pass

    app.t = gettext.translation(
        "tinkerer",
        locale_dir,
        languages=languages,
        fallback=True)
    app.t.install()

    # initialize localized strings
    uistr.UIStr(app)

    # override for "Home"
    if app.config.first_page_title:
        uistr.UIStr.HOME = app.config.first_page_title
Exemplo n.º 2
0
def initialize(app):
    '''
    Initializes extension after environment is initialized.
    '''
    # ensure website config value ends with "/"
    if not app.config.website[-1] == "/":
        app.config.website += "/"

    # initialize other components
    metadata.initialize(app)
    filing.initialize(app)

    # localization
    languages = [app.config.language] if app.config.language else None

    locale_dir = ""
    try:
        from pkg_resources import resource_filename
    except ImportError:
        resource_filename = None

    if resource_filename is not None:
        try:
            locale_dir = resource_filename(__name__, "/locale")
        except NotImplementedError:
            # resource_filename doesn't work with non-egg zip files
            pass

    app.t = gettext.translation("tinkerer",
                                locale_dir,
                                languages=languages,
                                fallback=True)
    app.t.install()

    # initialize localized strings
    uistr.UIStr(app)

    # override for "Home"
    if app.config.first_page_title:
        uistr.UIStr.HOME = app.config.first_page_title