-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from senaite/patient-wo-mrn-listing
Display "Not defined" in listing for patients without MRN set
- Loading branch information
Showing
3 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of SENAITE.PATIENT. | ||
# | ||
# SENAITE.PATIENT is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License as published by the Free | ||
# Software Foundation, version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Copyright 2020-2022 by it's authors. | ||
# Some rights reserved, see README and LICENSE. | ||
|
||
from bika.lims import api | ||
|
||
|
||
def translate(msgid, **kwargs): | ||
"""Translate any zope i18n msgid returned from MessageFactory | ||
""" | ||
msgid = api.safe_unicode(msgid) | ||
|
||
# XX: If the msgid is from type `Message`, Zope's i18n translate tool gives | ||
# priority `Message.domain` over the domain passed through kwargs | ||
domain = kwargs.pop("domain", "senaite.patient") | ||
params = { | ||
"domain": getattr(msgid, "domain", domain), | ||
"context": api.get_request(), | ||
} | ||
params.update(kwargs) | ||
|
||
ts = api.get_tool("translation_service") | ||
return ts.translate(msgid, **params) |