Fix cases where we want to test if translation exists for a key

This commit is contained in:
Alexandre Aubin 2021-02-28 17:00:48 +01:00
parent 2ab330a0e2
commit 4131ddb070
2 changed files with 5 additions and 9 deletions

View file

@ -449,9 +449,8 @@ class Diagnoser():
@staticmethod
def get_description(id_):
key = "diagnosis_description_" + id_
descr = m18n.n(key)
# If no description available, fallback to id
return descr if descr != key else id_
return m18n.n(key) if m18n.key_exists(key) else id_
@staticmethod
def i18n(report, force_remove_html_tags=False):

View file

@ -352,14 +352,11 @@ def _get_and_format_service_status(service, infos):
# If no description was there, try to get it from the .json locales
if not description:
translation_key = "service_description_%s" % service
description = m18n.n(translation_key)
# If descrption is still equal to the translation key,
# that mean that we don't have a translation for this string
# that's the only way to test for that for now
# if we don't have it, uses the one provided by systemd
if description == translation_key:
translation_key = "service_description_%s" % service
if m18n.key_exists(translation_key):
description = m18n.key_exists(translation_key)
else:
description = str(raw_status.get("Description", ""))
output = {