Exemplo n.º 1
0
def compile_app_i18n(name):
    print 'Compile locales for', name
    module = import_module(name)
    base_path = op.normpath( op.dirname( module.__file__) )
    i18n_path = op.join( base_path, 'i18n')
    for l in Babel.locales:
        subprocess.call(['pybabel', 'compile', '-d', i18n_path, '-l', l])
Exemplo n.º 2
0
    def __init__(self, apps, env_class):
        db_name = getattr(env_class.settings, 'MONGO_DB')
        env_class.mongo_connection = pymongo.Connection()[db_name]
        #env_class.mongo_connection.add_son_manipulator(NamespaceInjector())

        # Try loading models from app's models.py
        for app, config in apps.iteritems():
            app_models = app + '.models'
            try:
                mod = import_module(app_models)
            except ImportError:
                pass
Exemplo n.º 3
0
def update_app_i18n(name):
    print 'Update locales for', name
    module = import_module(name)
    base_path = op.normpath( op.dirname( module.__file__) )
    i18n_path = op.join( base_path, 'i18n')
    tmp_pot = op.join('/tmp/', name)

    subprocess.call(['pybabel', 'extract', '-o', tmp_pot,
                '-k', 'lazy_gettext', '-k', '_', base_path])
    for l in Babel.locales:
        if op.isdir(op.join(i18n_path, l)):
            operation = 'update'
        else:
            operation = 'init'
        subprocess.call(['pybabel', operation, '-d', i18n_path, '-i', tmp_pot, '-l', l])