mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Implement i18n stuff
This commit is contained in:
parent
0c232b6cb5
commit
c4ba8534c5
2 changed files with 19 additions and 15 deletions
|
@ -155,6 +155,15 @@
|
||||||
"diagnosis_no_apps": "No installed application",
|
"diagnosis_no_apps": "No installed application",
|
||||||
"dpkg_is_broken": "You cannot do this right now because dpkg/APT (the system package managers) seems to be in a broken state… You can try to solve this issue by connecting through SSH and running `sudo dpkg --configure -a`.",
|
"dpkg_is_broken": "You cannot do this right now because dpkg/APT (the system package managers) seems to be in a broken state… You can try to solve this issue by connecting through SSH and running `sudo dpkg --configure -a`.",
|
||||||
"dpkg_lock_not_available": "This command can't be ran right now because another program seems to be using the lock of dpkg (the system package manager)",
|
"dpkg_lock_not_available": "This command can't be ran right now because another program seems to be using the lock of dpkg (the system package manager)",
|
||||||
|
"diagnosis_display_tip_web": "You can go to the Diagnosis section (in the home screen) to see the issues found.",
|
||||||
|
"diagnosis_display_tip_cli": "You can run 'yunohost diagnosis show --issues' to display the issues found.",
|
||||||
|
"diagnosis_failed_for_category": "Diagnosis failed for category '{category}' : {error}",
|
||||||
|
"diagnosis_cache_still_valid": "(Cache still valid for {category} diagnosis. Not re-diagnosing yet!)",
|
||||||
|
"diagnosis_cant_run_because_of_dep": "Can't run diagnosis for {category} while there are important issues related to {dep}.",
|
||||||
|
"diagnosis_found_issues": "Found {errors} significant issue(s) related to {category}!",
|
||||||
|
"diagnosis_found_warnings": "Found {warnings} item(s) that could be improved for {category}.",
|
||||||
|
"diagnosis_everything_ok": "Everything looks good for {category}!",
|
||||||
|
"diagnosis_failed": "Failed to fetch diagnosis result for category '{category}' : {error}",
|
||||||
"diagnosis_ip_connected_ipv4": "The server is connected to the Internet through IPv4 !",
|
"diagnosis_ip_connected_ipv4": "The server is connected to the Internet through IPv4 !",
|
||||||
"diagnosis_ip_no_ipv4": "The server does not have a working IPv4.",
|
"diagnosis_ip_no_ipv4": "The server does not have a working IPv4.",
|
||||||
"diagnosis_ip_connected_ipv6": "The server is connected to the Internet through IPv6 !",
|
"diagnosis_ip_connected_ipv6": "The server is connected to the Internet through IPv6 !",
|
||||||
|
|
|
@ -64,7 +64,7 @@ def diagnosis_show(categories=[], issues=False, full=False, share=False):
|
||||||
try:
|
try:
|
||||||
report = Diagnoser.get_cached_report(category)
|
report = Diagnoser.get_cached_report(category)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to fetch diagnosis result for category '%s' : %s" % (category, str(e))) # FIXME : i18n
|
logger.error(m18n.n("diagnosis_failed", category=category, error=str(e)))
|
||||||
else:
|
else:
|
||||||
if not full:
|
if not full:
|
||||||
del report["timestamp"]
|
del report["timestamp"]
|
||||||
|
@ -136,7 +136,7 @@ def diagnosis_run(categories=[], force=False):
|
||||||
try:
|
try:
|
||||||
code, report = hook_exec(path, args={"force": force}, env=None)
|
code, report = hook_exec(path, args={"force": force}, env=None)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Diagnosis failed for category '%s' : %s" % (category, str(e)), exc_info=True) # FIXME : i18n
|
logger.error(m18n.n("diagnosis_failed_for_category", category=category, error=str(e)), exc_info=True)
|
||||||
else:
|
else:
|
||||||
diagnosed_categories.append(category)
|
diagnosed_categories.append(category)
|
||||||
if report != {}:
|
if report != {}:
|
||||||
|
@ -144,11 +144,9 @@ def diagnosis_run(categories=[], force=False):
|
||||||
|
|
||||||
if issues:
|
if issues:
|
||||||
if msettings.get("interface") == "api":
|
if msettings.get("interface") == "api":
|
||||||
# FIXME: i18n
|
logger.info(m18n.n("diagnosis_display_tip_web"))
|
||||||
logger.info("You can go to the Diagnosis section (in the home screen) to see the issues found.")
|
|
||||||
else:
|
else:
|
||||||
# FIXME: i18n
|
logger.info(m18n.n("diagnosis_display_tip_cli"))
|
||||||
logger.info("You can run 'yunohost diagnosis show --issues' to display the issues found.")
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -163,6 +161,7 @@ class Diagnoser():
|
||||||
|
|
||||||
def __init__(self, args, env, loggers):
|
def __init__(self, args, env, loggers):
|
||||||
|
|
||||||
|
# FIXME ? That stuff with custom loggers is weird ... (mainly inherited from the bash hooks, idk)
|
||||||
self.logger_debug, self.logger_warning, self.logger_info = loggers
|
self.logger_debug, self.logger_warning, self.logger_info = loggers
|
||||||
self.env = env
|
self.env = env
|
||||||
self.args = args or {}
|
self.args = args or {}
|
||||||
|
@ -184,16 +183,14 @@ class Diagnoser():
|
||||||
|
|
||||||
if not self.args.get("force", False) and self.cached_time_ago() < self.cache_duration:
|
if not self.args.get("force", False) and self.cached_time_ago() < self.cache_duration:
|
||||||
self.logger_debug("Cache still valid : %s" % self.cache_file)
|
self.logger_debug("Cache still valid : %s" % self.cache_file)
|
||||||
# FIXME : i18n
|
logger.info(m18n.n("diagnosis_cache_still_valid", category=self.description))
|
||||||
logger.info("(Cache still valid for %s diagnosis. Not re-diagnosing yet!)" % self.description)
|
|
||||||
return 0, {}
|
return 0, {}
|
||||||
|
|
||||||
for dependency in self.dependencies:
|
for dependency in self.dependencies:
|
||||||
dep_report = Diagnoser.get_cached_report(dependency)
|
dep_report = Diagnoser.get_cached_report(dependency)
|
||||||
dep_errors = [item for item in dep_report["items"] if item["status"] == "ERROR"]
|
dep_errors = [item for item in dep_report["items"] if item["status"] == "ERROR"]
|
||||||
if dep_errors:
|
if dep_errors:
|
||||||
# FIXME : i18n
|
logger.error(m18n.n("diagnosis_cant_run_because_of_dep", category=self.description, dep=Diagnoser.get_description(dependency)))
|
||||||
logger.error("Can't run diagnosis for %s while there are important issues related to %s." % (self.description, Diagnoser.get_description(dependency)))
|
|
||||||
return 1, {}
|
return 1, {}
|
||||||
|
|
||||||
self.logger_debug("Running diagnostic for %s" % self.id_)
|
self.logger_debug("Running diagnostic for %s" % self.id_)
|
||||||
|
@ -204,7 +201,6 @@ class Diagnoser():
|
||||||
"cached_for": self.cache_duration,
|
"cached_for": self.cache_duration,
|
||||||
"items": items}
|
"items": items}
|
||||||
|
|
||||||
# TODO / FIXME : should handle the case where we only did a partial diagnosis
|
|
||||||
self.logger_debug("Updating cache %s" % self.cache_file)
|
self.logger_debug("Updating cache %s" % self.cache_file)
|
||||||
self.write_cache(new_report)
|
self.write_cache(new_report)
|
||||||
Diagnoser.i18n(new_report)
|
Diagnoser.i18n(new_report)
|
||||||
|
@ -212,13 +208,12 @@ class Diagnoser():
|
||||||
errors = [item for item in new_report["items"] if item["status"] == "ERROR"]
|
errors = [item for item in new_report["items"] if item["status"] == "ERROR"]
|
||||||
warnings = [item for item in new_report["items"] if item["status"] == "WARNING"]
|
warnings = [item for item in new_report["items"] if item["status"] == "WARNING"]
|
||||||
|
|
||||||
# FIXME : i18n
|
|
||||||
if errors:
|
if errors:
|
||||||
logger.error("Found %s significant issue(s) related to %s!" % (len(errors), new_report["description"]))
|
logger.error(m18n.n("diagnosis_found_issues", errors=len(errors), category=new_report["description"]))
|
||||||
elif warnings:
|
elif warnings:
|
||||||
logger.warning("Found %s item(s) that could be improved for %s." % (len(warnings), new_report["description"]))
|
logger.warning(m18n.n("diagnosis_found_warnings", warnings=len(warnings), category=new_report["description"]))
|
||||||
else:
|
else:
|
||||||
logger.success("Everything looks good for %s!" % new_report["description"])
|
logger.success(m18n.n("diagnosis_everything_ok", category=new_report["description"]))
|
||||||
|
|
||||||
return 0, new_report
|
return 0, new_report
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue