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(a)sit.fraunhofer.de>
---
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