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

mypy rejects _ from gettext.gettext.install() #1293

Closed
cfm opened this issue Sep 1, 2021 · 1 comment
Closed

mypy rejects _ from gettext.gettext.install() #1293

cfm opened this issue Sep 1, 2021 · 1 comment
Assignees
Labels
bug Something isn't working i18n

Comments

@cfm
Copy link
Member

cfm commented Sep 1, 2021

This is a tracking ticket for the problem first identified in #1282 (comment), because it is out of scope of both the original ticket #1266 and its implementation in #1282.

There exists a triangular incompatibility among:

  1. application-wide gettext configuration;
  2. working locale fallback in securedrop_client.app.configure_locale_and_language(); and
  3. mypy's fixed behavior with built-ins.

As currently implemented, #1282 can satisfy at most two of these three requirements at any given time:

Approach (1) (2) (3) Notes
Original implementation: gettext.gettext.install() + from gettext import gettext as _ from gettext import gettext as _ in other modules effectively ignores the locale configured and translation loaded by gettext.gettext.install() in securedrop_client.app.
Implementation as of 4dd4d13: gettext.gettext.install() python/mypy#8727
Implementation with GNU gettext API gettext.[bind]textdomain will take $LANG from environment; does not support fallback configuration in configure_locale_and_language().
@cfm cfm added bug Something isn't working i18n labels Sep 1, 2021
@cfm cfm self-assigned this Sep 1, 2021
@cfm
Copy link
Member Author

cfm commented Sep 1, 2021

For the purposes of #1282, I will propose there a switch to the GNU gettext API. This will come at the cost of a feature that isn't actually implemented anyway: being able to switch languages within securedrop-client dynamically, regardless of the $LANG in the environment. It won't break the fallback gettext does automatically to the default locale (en) if the specified $LANG is not available.

cfm added a commit that referenced this issue Sep 1, 2021
…text API

Closes #1293 by using gettext.[bind]textdomain(), which will allow

    from gettext import gettext as _

to use the globally-configured locale without running afoul of mypy.

This reverts commit 4dd4d13.
cfm added a commit that referenced this issue Sep 1, 2021
…text API

Closes #1293 by using gettext.[bind]textdomain(), which will allow

    from gettext import gettext as _

to use the globally-configured locale without running afoul of mypy.

This reverts commit 4dd4d13.
cfm added a commit that referenced this issue Sep 2, 2021
…text API

Closes #1293 by using gettext.[bind]textdomain(), which will allow

    from gettext import gettext as _

to use the globally-configured locale without running afoul of mypy.

This reverts commit 4dd4d13.
cfm added a commit that referenced this issue Sep 2, 2021
…text API

Fixes #1293 by using gettext.[bind]textdomain(), which will allow

    from gettext import gettext as _

to use the globally-configured locale without running afoul of mypy.

This reverts commit 4dd4d13.
cfm added a commit that referenced this issue Sep 2, 2021
…text API

Fixes #1293 by using gettext.[bind]textdomain(), which will allow

    from gettext import gettext as _

to use the globally-configured locale without running afoul of mypy.

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

No branches or pull requests

1 participant