[PATCH] Be more clever and verbose about localization-initialization.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently libvirt fails with an uninformative error message if no translations are found.

Fixes:
* If bindtextdomain fails due to missing language files, fall back to locale C.
* If textdomain still fails, report the exact error without translation attempt.

https://bugzilla.redhat.com/show_bug.cgi?id=1016158

Signed-off-by: Andreas Fuchs <andreas.fuchs@xxxxxxxxxxxxxxxxx>
---
 daemon/libvirtd.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 99c0342..490acbf 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1132,9 +1132,17 @@ int main(int argc, char **argv) {
     };
 
     if (setlocale(LC_ALL, "") == NULL ||
-        bindtextdomain(PACKAGE, LOCALEDIR) == NULL ||
-        textdomain(PACKAGE) == NULL ||
-        virInitialize() < 0) {
+            bindtextdomain(PACKAGE, LOCALEDIR) == NULL ||
+            textdomain(PACKAGE) == NULL) {
+        VIR_WARN("Cannot find localization information. Falling back to non-localized messages.");
+        if (setlocale(LC_ALL, "C") == NULL ||
+                textdomain(PACKAGE) == NULL) {
+            fprintf(stderr, "%s: localization initialization failed\n", argv[0]);
+            exit(EXIT_FAILURE);
+        }
+    }
+        
+    if (virInitialize() < 0) {
         fprintf(stderr, _("%s: initialization failed\n"), argv[0]);
         exit(EXIT_FAILURE);
     }
-- 
1.7.10.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]