summaryrefslogtreecommitdiff
path: root/src/main-utils.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-12-21 14:36:00 +0100
committerThomas Haller <thaller@redhat.com>2018-04-13 10:11:16 +0200
commit9a675ba82ac0a22c81d5492595098af76bf39915 (patch)
treeef5e4991934f3aa4419f41ed6607b1bc9fe3e525 /src/main-utils.c
parent684bf311502a0579d841bb55137f42368ae0cc6b (diff)
downloadNetworkManager-th/various-cleanup.tar.gz
core: don't localize strings for daemonth/various-cleanup
NetworkManager deamon does not run in the context of the (client) user, hence it usually has no explicit locale set. Even if a admin configures a locale for system daemons, it is not necessarily the right locale in the client context. Getting localization of strings right would be important. For example, when a request fails, the error message should be in the language of the client. However, that is a lot of work to get right. Either the client has to provide a localization context (so the server can generated messages in the right language), or the client is given a method to localize messages (e.g. by not relying on generating the message by the server, but by generating an error code that can be looked up). It's complicated, but just translating strings server side doesn't help. Probably we should build libnm-core.a twice, once with l10n for libnm's use case, and once without for the server. The problem that the server doesn't know the l10n context is especially bad for the name of the generated default-wired-connection, which is something like "Wired Connection 1". See also related bug bgo#666516.
Diffstat (limited to 'src/main-utils.c')
-rw-r--r--src/main-utils.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main-utils.c b/src/main-utils.c
index 0f79053607..7133531ea2 100644
--- a/src/main-utils.c
+++ b/src/main-utils.c
@@ -28,10 +28,11 @@
#include <unistd.h>
#include <sys/stat.h>
#include <locale.h>
-
#include <glib/gstdio.h>
#include <glib-unix.h>
+#include <glib/gi18n.h>
+
#include "main-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-config.h"
@@ -96,18 +97,18 @@ nm_main_utils_write_pidfile (const char *pidfile)
gboolean success = FALSE;
if ((fd = open (pidfile, O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, 00644)) < 0) {
- fprintf (stderr, _("Opening %s failed: %s\n"), pidfile, strerror (errno));
+ fprintf (stderr, "Opening %s failed: %s\n", pidfile, strerror (errno));
return FALSE;
}
g_snprintf (pid, sizeof (pid), "%d", getpid ());
if (write (fd, pid, strlen (pid)) < 0)
- fprintf (stderr, _("Writing to %s failed: %s\n"), pidfile, strerror (errno));
+ fprintf (stderr, "Writing to %s failed: %s\n", pidfile, strerror (errno));
else
success = TRUE;
if (nm_close (fd))
- fprintf (stderr, _("Closing %s failed: %s\n"), pidfile, strerror (errno));
+ fprintf (stderr, "Closing %s failed: %s\n", pidfile, strerror (errno));
return success;
}
@@ -145,7 +146,7 @@ nm_main_utils_ensure_rundir ()
/* Setup runtime directory */
if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) {
errsv = errno;
- fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, g_strerror (errsv));
+ fprintf (stderr, "Cannot create '%s': %s", NMRUNDIR, g_strerror (errsv));
exit (1);
}
@@ -156,7 +157,7 @@ nm_main_utils_ensure_rundir ()
if (g_mkdir (NM_CONFIG_DEVICE_STATE_DIR, 0755) != 0) {
errsv = errno;
if (errsv != EEXIST) {
- fprintf (stderr, _("Cannot create '%s': %s"), NM_CONFIG_DEVICE_STATE_DIR, g_strerror (errsv));
+ fprintf (stderr, "Cannot create '%s': %s", NM_CONFIG_DEVICE_STATE_DIR, g_strerror (errsv));
exit (1);
}
}
@@ -209,7 +210,7 @@ nm_main_utils_ensure_not_running_pidfile (const char *pidfile)
if (strcmp (process_name, prgname) == 0) {
/* Check that the process exists */
if (kill (pid, 0) == 0) {
- fprintf (stderr, _("%s is already running (pid %ld)\n"), prgname, pid);
+ fprintf (stderr, "%s is already running (pid %ld)\n", prgname, pid);
exit (1);
}
}
@@ -219,7 +220,7 @@ void
nm_main_utils_ensure_root ()
{
if (getuid () != 0) {
- fprintf (stderr, _("You must be root to run %s!\n"), g_get_prgname () ?: "");
+ fprintf (stderr, "You must be root to run %s!\n", g_get_prgname () ?: "");
exit (1);
}
}
@@ -283,7 +284,7 @@ nm_main_utils_early_setup (const char *progname,
success = g_option_context_parse (opt_ctx, argc, argv, &error);
if (!success) {
- fprintf (stderr, _("%s. Please use --help to see a list of valid options.\n"),
+ fprintf (stderr, "%s. Please use --help to see a list of valid options.\n",
error->message);
g_clear_error (&error);
}