mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-06 11:40:52 -06:00
- Integrate Flask-Babel and i18n utilities; initialize in app factory - Add `preferred_language` to `User` with Alembic migration (011_add_user_preferred_language) - Add `babel.cfg` and `scripts/extract_translations.py` - Add `translations/` for en, de, fr, it, nl, fi - Update templates to use `_()` and add language picker in navbar/profile - Respect locale in routes and context processors; persist user preference - Update requirements and Docker/Docker entrypoint for Babel/gettext support - Minor copy and style adjustments across pages Migration: run `alembic upgrade head`
33 lines
913 B
Python
33 lines
913 B
Python
import os
|
|
import subprocess
|
|
|
|
|
|
def run(cmd: list[str]) -> int:
|
|
print("$", " ".join(cmd))
|
|
return subprocess.call(cmd)
|
|
|
|
|
|
def main():
|
|
# Requires Flask-Babel/Babel installed
|
|
os.makedirs('translations', exist_ok=True)
|
|
# Extract messages
|
|
run(['pybabel', 'extract', '-F', 'babel.cfg', '-o', 'messages.pot', '.'])
|
|
|
|
# Initialize languages if not already
|
|
languages = ['en', 'nl', 'de', 'fr', 'it', 'fi']
|
|
for lang in languages:
|
|
po_dir = os.path.join('translations', lang, 'LC_MESSAGES')
|
|
po_path = os.path.join(po_dir, 'messages.po')
|
|
if not os.path.exists(po_path):
|
|
run(['pybabel', 'init', '-i', 'messages.pot', '-d', 'translations', '-l', lang])
|
|
# Update catalogs
|
|
run(['pybabel', 'update', '-i', 'messages.pot', '-d', 'translations'])
|
|
# Compile
|
|
run(['pybabel', 'compile', '-d', 'translations'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|
|
|