FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow object methods to be used as extraction-keywords · Issue #774 · python-babel/babel · GitHub

Repository navigation

Allow object methods to be used as extraction-keywords #774

Open

Description

I'm having trouble getting certain strings to attach that are inside non-default-keyword member functions.

My code has a level of encapsulation to it, where I sometimes store the gettext function inside the class as a method, like so:

_ = gettext(...)
class Foobar:
  def __init__(self, translator):
     self.i18n = translator
   def send(self):
    return self.i18n("Hello World")
  f = Foobar(translator=_)
  print(f.send())

I've added the i18n function to setup.cfg:

[extract_messages]
...
keywords = _ i18n
...

I've also tried adding "self.i18n", and Foobar.i18n to keywords, but this failed to extract the string as well.

I can go through and manually wrap every single string with a "pure" N_() function, but the code has many strings and that would be highly verbose.

Activity

  1. embray commented on Oct 3, 2024

    I had a similar issue. I have a quick fix for it I'll post as a PR. (now #1136)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL