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 @staticmethod
def get_description(id_): def get_description(id_):
key = "diagnosis_description_" + id_ key = "diagnosis_description_" + id_
descr = m18n.n(key)
# If no description available, fallback to id # 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 @staticmethod
def i18n(report, force_remove_html_tags=False): 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 no description was there, try to get it from the .json locales
if not description: if not description:
translation_key = "service_description_%s" % service
description = m18n.n(translation_key)
# If descrption is still equal to the translation key, translation_key = "service_description_%s" % service
# that mean that we don't have a translation for this string if m18n.key_exists(translation_key):
# that's the only way to test for that for now description = m18n.key_exists(translation_key)
# if we don't have it, uses the one provided by systemd else:
if description == translation_key:
description = str(raw_status.get("Description", "")) description = str(raw_status.get("Description", ""))
output = { output = {