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

Translation activation does not work because of missing .mo files #211

Closed
facundobatista opened this issue Jun 5, 2021 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@facundobatista
Copy link

facundobatista commented Jun 5, 2021

What did you do?

Activated the translations.

What did you expect to happen?

Activation succeed, for later humanization in a specific language to work.

What actually happened?

>>> humanize.i18n.activate("es_ES")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/facundo/temp/testhum/lib/python3.8/site-packages/humanize/i18n.py", line 58, in activate
    translation = gettext_module.translation("humanize", path, [locale])
  File "/usr/lib/python3.8/gettext.py", line 603, in translation
    raise FileNotFoundError(ENOENT,
FileNotFoundError: [Errno 2] No translation file found for domain: 'humanize'

What versions are you using?

  • OS: Ubuntu 20.10
  • Python: 3.8.6
  • Humanize: 3.7.0

Please include code that reproduces the issue:

$ virtualenv testhum
created virtual environment CPython3.8.6.final.0-64 in 193ms
  creator CPython3Posix(dest=/home/facundo/temp/testhum, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/facundo/.local/share/virtualenv)
    added seed packages: pip==20.1.1, pkg_resources==0.0.0, setuptools==44.0.0, wheel==0.34.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
$ source testhum/bin/activate
(testhum) $ pip install humanize
Collecting humanize
  Using cached humanize-3.7.0-py3-none-any.whl (48 kB)
Requirement already satisfied: setuptools in ./testhum/lib/python3.8/site-packages (from humanize) (44.0.0)
Installing collected packages: humanize
Successfully installed humanize-3.7.0
(testhum) $ python
Python 3.8.6 (default, May 27 2021, 13:28:02) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import humanize
>>> humanize.__file__
'/home/facundo/temp/testhum/lib/python3.8/site-packages/humanize/__init__.py'
>>> humanize.i18n.activate("es_ES")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/facundo/temp/testhum/lib/python3.8/site-packages/humanize/i18n.py", line 58, in activate
    translation = gettext_module.translation("humanize", path, [locale])
  File "/usr/lib/python3.8/gettext.py", line 603, in translation
    raise FileNotFoundError(ENOENT,
FileNotFoundError: [Errno 2] No translation file found for domain: 'humanize'

The exception happens in gettext because it's not finding the .mo files, this is the beginning of the gettext function that is called by humanize:

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)

That code searches for the .mo files, and as it doesn't find them, it raises the exception.

And the .mo files are not found because they are not there:

(testhum) $ ll testhum/lib/python3.8/site-packages/humanize/locale/
total 80
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 ca_ES
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 de_DE
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 es_ES
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 fa_IR
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 fi_FI
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 fr_FR
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 id_ID
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 it_IT
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 ja_JP
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 ko_KR
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 nl_NL
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 pl_PL
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 pt_BR
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 pt_PT
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 ru_RU
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 sk_SK
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 tr_TR
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 uk_UA
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 vi_VI
drwxrwxr-x 3 facundo facundo 4096 jun  5 12:01 zh_CN
(testhum) $ ll testhum/lib/python3.8/site-packages/humanize/locale/es_ES/
total 4
drwxrwxr-x 2 facundo facundo 4096 jun  5 12:01 LC_MESSAGES
(testhum) $ ll testhum/lib/python3.8/site-packages/humanize/locale/es_ES/LC_MESSAGES/
total 8
-rw-rw-r-- 1 facundo facundo 6594 jun  5 12:01 humanize.po
@hugovk
Copy link
Collaborator

hugovk commented Jun 6, 2021

Thanks for the report, I'll see what went wrong and release a fix, but in the meantime you can use the previous 3.6.0 release.

@hugovk
Copy link
Collaborator

hugovk commented Jun 6, 2021

Okay, so I had missed a step from release checklist. I've updated the checklist to make this less likely next time, and released 3.7.1.

The longer term solution will be to automate deploys, which will make it easier and quicker to deploy as well. I'll need to ask for admin permissions for this repo to do that.

Thanks again!

@hugovk hugovk closed this as completed Jun 6, 2021
@facundobatista
Copy link
Author

Thank you very much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants