コード例 #1
0
ファイル: forms.py プロジェクト: wesleyrossini/banco-de-dados
class ExtendedRegisterForm(RegisterForm):
    all_locales = [('en', 'English')]
    for x in babel.list_translations():
        all_locales.append((x.language, x.display_name))

    email = StringField(lazy_gettext('E-Mail'),
                        validators=[DataRequired(), Email()])
    password = PasswordField(
        lazy_gettext('Password'),
        validators=[DataRequired(),
                    EqualTo("password_confirm")])
    password_confirm = PasswordField(
        lazy_gettext('Retype password'),
        validators=[DataRequired(), EqualTo("password")])
    locale = SelectField(lazy_gettext('Language'), choices=all_locales)
    submit = None
コード例 #2
0
def get_locale():
    translations = [
        str(translation) for translation in babel.list_translations()
    ]
    return request.accept_languages.best_match(translations)
コード例 #3
0
ファイル: views.py プロジェクト: NiklasMM/fobiweapp
def get_locale():
    translations = [
        str(translation) for translation in babel.list_translations()
    ]
    return request.accept_languages.best_match(translations)