Skip to content

Instantly share code, notes, and snippets.

View lapause's full-sized avatar

Pierre Guillaume lapause

View GitHub Profile
@lapause
lapause / example.py
Created June 9, 2015 19:05
Quick and dirty click exceptions handling for translation with gettext
import re
import click
# (1) My gettext helpers are _() and _n(), replace them by yours if necessary.
# (2) I've used the exact same messages in translations, you can adapt them.
def translate_click_exception(e):
"""
Analyse a click exception, translate its message using gettext
and re-raise it in current language.