Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WTForms 2.3.2 does not provide translated messages #641

Closed
zgoda opened this issue Jul 30, 2020 · 4 comments
Closed

WTForms 2.3.2 does not provide translated messages #641

zgoda opened this issue Jul 30, 2020 · 4 comments

Comments

@zgoda
Copy link

zgoda commented Jul 30, 2020

Actual Behavior

WTForms 2.3.2

Zrzut ekranu z 2020-07-30 12-05-33

Expected Behavior

WTForms 2.3.1

Zrzut ekranu z 2020-07-30 12-04-54

Environment

  • Python version: 3.7.8
  • wtforms version: 2.3.2
  • Babel version: 2.8.0

Babel is statically initialized with default locale 'pl'. Adding locales to base form's Meta has no impact.

@hynek
Copy link

hynek commented Jul 30, 2020

I'm having a probably related – and probably more severe – problem: a test suite of an untranslated code base started failing with:

../../.local/venvs/konto/lib/python3.8/site-packages/wtforms/form.py:208: in __call__
    return type.__call__(cls, *args, **kwargs)
../../.local/venvs/konto/lib/python3.8/site-packages/wtforms/form.py:268: in __init__
    super(Form, self).__init__(self._unbound_fields, meta=meta_obj, prefix=prefix)
../../.local/venvs/konto/lib/python3.8/site-packages/wtforms/form.py:43: in __init__
    translations = self._get_translations()
../../.local/venvs/konto/lib/python3.8/site-packages/wtforms/form.py:84: in _get_translations
    return self.meta.get_translations(self)
../../.local/venvs/konto/lib/python3.8/site-packages/wtforms/meta.py:108: in get_translations
    translations = self.translations_cache[locales] = i18n.get_translations(locales)
../../.local/venvs/konto/lib/python3.8/site-packages/wtforms/i18n.py:37: in get_translations
    translations = getter(languages)
../../.local/venvs/konto/lib/python3.8/site-packages/wtforms/i18n.py:25: in get_builtin_gnu_translations
    return gettext.translation('wtforms', messages_path(), languages)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

domain = 'wtforms', localedir = '/Users/hynek/.local/venvs/konto/lib/python3.8/site-packages/wtforms/locale', languages = ('de',), class_ = <class 'gettext.GNUTranslations'>, fallback = False, codeset = ['unspecified']

    def translation(domain, localedir=None, languages=None,
                    class_=None, fallback=False, codeset=_unspecified):
        if class_ is None:
            class_ = GNUTranslations
        mofiles = find(domain, localedir, languages, all=True)
        if not mofiles:
            if fallback:
                return NullTranslations()
            from errno import ENOENT
>           raise FileNotFoundError(ENOENT,
                                    'No translation file found for domain', domain)
E           FileNotFoundError: [Errno 2] No translation file found for domain: 'wtforms'

../../.pyenv/versions/3.8.5/lib/python3.8/gettext.py:588: FileNotFoundError

Downgrading to 2.3.1 fixes the problem.

@davidism
Copy link
Member

Looks like the compiled translation files were excluded from the builds for some reason. I'll make a new release shortly.

@davidism
Copy link
Member

Ah, the 2.x line doesn't have the setup.py updates that compile the catalog automatically. 3.x has some custom code to ensure it's compiled, so this shouldn't happen in the future: https://github.com/wtforms/wtforms/blob/2d4469b7e3b254ff1da65875b5c1ad7a84735fa1/setup.py#L11-L47

@davidism
Copy link
Member

Released version 2.3.3: https://pypi.org/project/WTForms/2.3.3/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants