コード例 #1
0
def test_set_no_directory():
    """
    explicitly (for coverage) set no global localisation directory
    """
    ptrans.init_localisation(None)
コード例 #2
0
def test_set_no_directory():
    """
    explicitly (for coverage) set no global localisation directory
    """
    ptrans.init_localisation(None)
コード例 #3
0
import xmltodict
from configparser import SafeConfigParser
from flask import Flask, request, render_template, make_response, redirect, abort
#~ from settings import *
from flaskext.markdown import Markdown
from flask_ptrans import ptrans

def local_path(*path_elements):
    return os.path.abspath(os.path.join(__file__, "..", *path_elements))

conf = SafeConfigParser()
conf.read('config.ini')
DEBUG = conf.get('general', 'debug')

app = Flask(__name__)
ptrans.init_localisation(local_path("lang"))
app.jinja_env.add_extension('flask_ptrans.ptrans.ptrans')
Markdown(app)


""" Default context """
context = {
    'server': conf.get('general', 'server'),
    'domain': conf.get('general', 'domain'),
    'ttl': conf.get('general', 'ttl'),
    'disable_pop': conf.get('general', 'disable_pop'),
    'imap': {
        'authentication': conf.get('imap', 'authentication'),
        'host':conf.get('imap', 'host'),
        'port':conf.get('imap', 'port'),
        'spa': conf.get('imap', 'spa'),
コード例 #4
0
"""

from __future__ import print_function, absolute_import, unicode_literals

import os
from flask import Flask, render_template, request
from flask_ptrans import ptrans


def local_path(*path_elements):
    return os.path.abspath(os.path.join(__file__, "..", *path_elements))


# create the Flask application
app = Flask(__name__)
ptrans.init_localisation(
    local_path("localisation"))  # say where the localisation files are
app.jinja_env.add_extension(
    'flask_ptrans.ptrans.ptrans')  # add ptrans extension

RENDER_COUNTER = 0


@app.route("/")
def index_page():
    locale = request.args.get('locale')
    if not locale:
        locale = ptrans.best_locale()
    global RENDER_COUNTER
    RENDER_COUNTER += 1
    return render_template('index.html',
                           locale=locale,