mirror of
https://codeberg.org/catask-org/catask.git
synced 2025-04-19 13:23:41 -05:00
babel
This commit is contained in:
parent
5ceb96492b
commit
eca33dcbdd
1 changed files with 22 additions and 2 deletions
24
app.py
24
app.py
|
@ -1,17 +1,18 @@
|
|||
from flask import Flask, Blueprint, jsonify, request, abort, render_template, flash, session, redirect, url_for
|
||||
from flask_babel import Babel, _, refresh
|
||||
from flask_compress import Compress
|
||||
from dotenv import load_dotenv
|
||||
from mysql.connector import errorcode
|
||||
from functools import wraps
|
||||
from werkzeug.utils import secure_filename
|
||||
from pathlib import Path
|
||||
import unicodedata
|
||||
import threading
|
||||
import requests
|
||||
import secrets
|
||||
import shutil
|
||||
import zipfile
|
||||
import tarfile
|
||||
import mysql.connector
|
||||
import psycopg
|
||||
import urllib
|
||||
import functions as func
|
||||
import os
|
||||
|
@ -31,6 +32,25 @@ app.config.update(cfg)
|
|||
# compress to improve page load speed
|
||||
Compress(app)
|
||||
|
||||
app.config['BABEL_DEFAULT_LOCALE'] = 'en'
|
||||
app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'locales'
|
||||
# refreshing locale
|
||||
refresh()
|
||||
|
||||
# update this once more languages are supported
|
||||
app.config['available_languages'] = {
|
||||
"en_US": _("English (US)"),
|
||||
"ru_RU": _("Russian")
|
||||
}
|
||||
|
||||
def getLocale():
|
||||
if not session.get('language'):
|
||||
app.config.update(cfg)
|
||||
session['language'] = cfg['languages']['default']
|
||||
return session.get('language')
|
||||
|
||||
babel = Babel(app, locale_selector=getLocale)
|
||||
|
||||
# -- blueprints --
|
||||
api_bp = Blueprint('api', const.appName)
|
||||
admin_bp = Blueprint('admin', const.appName)
|
||||
|
|
Loading…
Add table
Reference in a new issue