Projet

Général

Profil

0002-misc-add-pgettext-58796.patch

Lauréline Guérin, 03 mars 2022 11:13

Télécharger (1,43 ko)

Voir les différences:

Subject: [PATCH 2/4] misc: add pgettext (#58796)

 wcs/qommon/__init__.py  | 7 +++++++
 wcs/qommon/publisher.py | 2 ++
 2 files changed, 9 insertions(+)
wcs/qommon/__init__.py
52 52
    return force_str(force_text(pub.ngettext(*args)))
53 53

  
54 54

  
55
def pgettext(*args):
56
    pub = get_publisher()
57
    if pub is None:
58
        return args[1]
59
    return force_str(force_text(pub.pgettext(*args)))
60

  
61

  
55 62
def N_(x):
56 63
    return x
57 64

  
wcs/qommon/publisher.py
120 120

  
121 121
    gettext = lambda self, message: message
122 122
    ngettext = lambda self, msgid1, msgid2, n: msgid1
123
    pgettext = lambda self, context, message: message
123 124

  
124 125
    app_dir = None
125 126

  
......
364 365
        translation.activate(lang)
365 366
        self.gettext = translation.gettext
366 367
        self.ngettext = translation.ngettext
368
        self.pgettext = translation.pgettext
367 369
        if request:
368 370
            request.LANGUAGE_CODE = lang
369 371

  
370
-