add German language translation data #95

This commit is contained in:
rimu 2024-03-17 20:33:29 +13:00
parent a121b316d5
commit fed38857f8
5 changed files with 650 additions and 710 deletions

View file

@ -19,6 +19,13 @@ from sqlalchemy_searchable import make_searchable
from config import Config
def get_locale():
try:
return request.accept_languages.best_match(current_app.config['LANGUAGES'])
except:
return 'en'
db = SQLAlchemy() # engine_options={'pool_size': 5, 'max_overflow': 10} # session_options={"autoflush": False}
migrate = Migrate()
login = LoginManager()
@ -27,7 +34,7 @@ login.login_message = _l('Please log in to access this page.')
mail = Mail()
bootstrap = Bootstrap5()
moment = Moment()
babel = Babel()
babel = Babel(locale_selector=get_locale)
cache = Cache()
celery = Celery(__name__, broker=Config.CELERY_BROKER_URL)
@ -130,11 +137,4 @@ def create_app(config_class=Config):
return app
def get_locale():
try:
return request.accept_languages.best_match(current_app.config['LANGUAGES'])
except:
return 'en_US'
from app import models

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@ class Config(object):
RECAPTCHA_PUBLIC_KEY = os.environ.get("RECAPTCHA_PUBLIC_KEY")
RECAPTCHA_PRIVATE_KEY = os.environ.get("RECAPTCHA_PRIVATE_KEY")
MODE = os.environ.get('MODE') or 'development'
LANGUAGES = ['en']
LANGUAGES = ['de', 'en']
FULL_AP_CONTEXT = bool(int(os.environ.get('FULL_AP_CONTEXT', 0)))
CACHE_TYPE = os.environ.get('CACHE_TYPE') or 'FileSystemCache'
CACHE_REDIS_URL = os.environ.get('CACHE_REDIS_URL') or 'redis://localhost:6379/1'

View file

@ -5,5 +5,6 @@ sudo systemctl stop celery.service
git pull
source venv/bin/activate
flask db upgrade
flask translate compile
sudo systemctl start celery.service
sudo systemctl restart pyfedi.service

View file

@ -16,3 +16,18 @@ python profile_app.py
instead of
flask run
translations:
See https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xiii-i18n-and-l10n-2018
to add a new language which can be worked on:
pybabel init -i messages.pot -d app/translations -l <language code>
after changes to the files in app/translations/* are mode, they need to be compiled
pybabel compile -d app/translations