From d3e3cd418d841a8098249235e604a83308cf3002 Mon Sep 17 00:00:00 2001 From: Adrien CLERC Date: Mon, 4 May 2020 21:42:55 +0200 Subject: [PATCH] move choices generation in constructor to fix i18n In a class field, we don't have access to the current locale --- ihatemoney/forms.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index 5834f8e9..9e8cfe0b 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -109,13 +109,16 @@ class EditProjectForm(FlaskForm): currency_helper = CurrencyConverter() default_currency = SelectField( _("Default Currency"), - choices=[ - (currency_name, render_localized_currency(currency_name)) - for currency_name in currency_helper.get_currencies() - ], validators=[DataRequired()], ) + def __init__(self): + super().__init__() + self.default_currency.choices = [ + (currency_name, render_localized_currency(currency_name, detailed=True)) + for currency_name in self.currency_helper.get_currencies() + ] + @property def logging_preference(self): """Get the LoggingMode object corresponding to current form data."""