summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2023-10-06 09:00:18 (EDT)
committer P. J. McDermott <pj@pehjota.net>2023-10-06 11:33:29 (EDT)
commit20377a29d1f274802fce5c728d1a5d7f5a7e8c2a (patch)
treeeb7748ced4f23471f07fdb0c16a56f32e8a91176 /src
parent4c487f3f0a377f15636a3041a0dda9b04d851c77 (diff)
downloadatsign-20377a29d1f274802fce5c728d1a5d7f5a7e8c2a.zip
atsign-20377a29d1f274802fce5c728d1a5d7f5a7e8c2a.tar.gz
atsign-20377a29d1f274802fce5c728d1a5d7f5a7e8c2a.tar.bz2
datetime, main: Translate strings
Diffstat (limited to 'src')
-rw-r--r--src/datetime.c13
-rw-r--r--src/main.c35
2 files changed, 25 insertions, 23 deletions
diff --git a/src/datetime.c b/src/datetime.c
index 0bba344..72f0219 100644
--- a/src/datetime.c
+++ b/src/datetime.c
@@ -32,6 +32,7 @@
#include <time.h>
#include "datetime.h"
#include "formats.h"
+#include "i18n.h"
static void
_datetime_buf_cpy_p(char *dst, const char *src)
@@ -164,7 +165,7 @@ datetime_parse(struct tm *now_tm, const char *input,
}
fmt_buf = calloc(fmt_len + 1, sizeof(*fmt_buf));
if (fmt_buf == NULL) {
- fprintf(stderr, "Failed to allocate buffer: %s\n",
+ fprintf(stderr, _("Failed to allocate buffer: %s\n"),
strerror(errno));
return -1;
}
@@ -249,7 +250,7 @@ datetime_parse(struct tm *now_tm, const char *input,
free(fmt_buf);
return 0;
} else {
- fputs("Unknown date format\n", stderr);
+ fputs(_("Unknown date format\n"), stderr);
free(fmt_buf);
return -1;
}
@@ -294,13 +295,13 @@ _datetime_strftime(const char *fmts[], const struct tm *tm, char **out,
*buf_sz = strlen(fmts[0]) + 1;
*buf = calloc(*buf_sz, sizeof(**buf));
if (*buf == NULL) {
- fprintf(stderr, "Failed to allocate buffer: %s\n",
+ fprintf(stderr, _("Failed to allocate buffer: %s\n"),
strerror(errno));
return -1;
}
*out = calloc(*buf_sz, sizeof(**out));
if (*out == NULL) {
- fprintf(stderr, "Failed to allocate buffer: %s\n",
+ fprintf(stderr, _("Failed to allocate buffer: %s\n"),
strerror(errno));
return -1;
}
@@ -320,7 +321,7 @@ _datetime_strftime(const char *fmts[], const struct tm *tm, char **out,
++*buf_sz;
*buf = realloc(*buf, *buf_sz * sizeof(**buf));
if (*buf == NULL) {
- fprintf(stderr, "Failed to allocate buffer: %s\n",
+ fprintf(stderr, _("Failed to allocate buffer: %s\n"),
strerror(errno));
return -1;
}
@@ -329,7 +330,7 @@ _datetime_strftime(const char *fmts[], const struct tm *tm, char **out,
if (resized > 0) {
*out = realloc(*out, *buf_sz * sizeof(**out));
if (*out == NULL) {
- fprintf(stderr, "Failed to allocate buffer: %s\n",
+ fprintf(stderr, _("Failed to allocate buffer: %s\n"),
strerror(errno));
return -1;
}
diff --git a/src/main.c b/src/main.c
index 51a8a58..ce02c1f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,6 +26,7 @@
#include <unistd.h>
#include "config.h"
#include "datetime.h"
+#include "i18n.h"
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
#include <getopt.h>
@@ -59,7 +60,7 @@ static const struct option LONGOPTS_[] = {
static void
_print_usage(FILE *stream, const char *program_name)
{
- fprintf(stream, "Usage: %s [date]time\n", program_name);
+ fprintf(stream, _("Usage: %s [date]time\n"), program_name);
}
static void
@@ -111,44 +112,44 @@ _list_formats(const struct tm *tm)
char *buf;
size_t i;
- puts("Time formats:");
+ puts(_("Time formats:"));
i = 0;
while (datetime_strftime_time(tm, &out, &buf_sz, &buf, &i) > 0) {
if (out[0] == '\0') {
continue;
}
- printf(" * %s\n", out);
+ printf(_(" * %s\n"), out);
}
- puts("Date formats:");
+ puts(_("Date formats:"));
i = 0;
while (datetime_strftime_date(tm, &out, &buf_sz, &buf, &i) > 0) {
if (out[0] == '\0') {
continue;
}
- printf(" * %s\n", out);
+ printf(_(" * %s\n"), out);
}
- puts("Additional formats:");
+ puts(_("Additional formats:"));
i = 0;
while (datetime_strftime_misc(tm, &out, &buf_sz, &buf, &i) > 0) {
if (out[0] == '\0') {
continue;
}
- printf(" * %s\n", out);
+ printf(_(" * %s\n"), out);
}
}
static void
_print_version(void)
{
- printf("@ (atsign) %s%s\n", PACKAGE_VERSION, PACKAGE_VERSION_GIT);
- puts("Copyright (C) 2021, 2022 P. J. McDermott\n"
+ printf(_("@ (atsign) %s%s\n"), PACKAGE_VERSION, PACKAGE_VERSION_GIT);
+ puts(_("Copyright (C) 2021, 2022 P. J. McDermott\n"
"License GPLv3+: GNU GPL version 3 or later "
"<http://gnu.org/licenses/gpl.html>.\n"
"This is free software: you are free to change and redistribute it.\n"
- "There is NO WARRANTY, to the extent permitted by law.\n");
- printf("Please report bugs to <%s>.\n", PACKAGE_BUGREPORT);
+ "There is NO WARRANTY, to the extent permitted by law.\n"));
+ printf(_("Please report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
static char *
@@ -167,7 +168,7 @@ _concat_args(int argc, char * const argv[])
buf = calloc(buf_l, sizeof(*buf));
if (buf == NULL) {
- fprintf(stderr, "Failed to allocate buffer: %s\n",
+ fprintf(stderr, _("Failed to allocate buffer: %s\n"),
strerror(errno));
return NULL;
}
@@ -243,11 +244,11 @@ main(int argc, char * const argv[])
default:
_print_usage(stderr, argv[0]);
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
- fprintf(stderr, "Try '%s --help' for more "
- "information.\n", argv[0]);
+ fprintf(stderr, _("Try '%s --help' for more "
+ "information.\n"), argv[0]);
#else
- fprintf(stderr, "Try '%s -h' for more "
- "information.\n", argv[0]);
+ fprintf(stderr, _("Try '%s -h' for more "
+ "information.\n"), argv[0]);
#endif
return EXIT_FAILURE;
}
@@ -287,7 +288,7 @@ main(int argc, char * const argv[])
now = time(NULL);
dif = difftime(arg, now);
if (dif >= 1000 * 24 * 60 * 60) {
- fputs("Date too far in the future\n", stderr);
+ fputs(_("Date too far in the future\n"), stderr);
return EXIT_FAILURE;
}