summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c112
1 files changed, 62 insertions, 50 deletions
diff --git a/src/main.c b/src/main.c
index 7a0efd5..5a20236 100644
--- a/src/main.c
+++ b/src/main.c
@@ -17,14 +17,18 @@
* along with opkg-opk. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
+
+#ifdef ENABLE_NLS
+#include <locale.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include "defs.h"
+#include "i18n.h"
#include "opk.h"
#include "ustar.h"
-#include "config.h"
-
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#else
@@ -72,46 +76,40 @@ struct option _longopts[] = {
static void
_help(const char *program_name)
{
- printf("Usage: %s OPTION... PACKAGE\n", program_name);
- puts("Options:");
+ printf(_("Usage: %s OPTION... PACKAGE\n"), program_name);
#ifdef HAVE_GETOPT_LONG
- puts(" -I, --info=CONTROL-FILE Print the named control file. If "
- "this option is");
- puts(" given multiple times, the named "
- "control files will be");
- puts(" printed in the order they appear in "
- "the package.");
- puts(" -f, --control Print the control file.");
- puts(" -c, --contents List the contents of the filesystem "
- "tree archive");
- puts(" portion of the package. It is "
- "currently produced in");
- puts(" a format similar to that generated by "
- "GNU and BusyBox");
- puts(" tar's verbose listing. User and "
- "group IDs and names");
- puts(" are not checked against those on the "
- "host system,");
- puts(" since they may differ.");
- puts(" -h, --help Show this help information and exit.");
- puts(" -V, --version Show version information and exit.");
+ puts(_("Options:\n"
+" -I, --info=CONTROL-FILE Print the named control file. If this option is\n"
+" given multiple times, the named control files will "
+ "be\n"
+" printed in the order they appear in the package.\n"
+" -f, --control Print the control file.\n"
+" -c, --contents List the contents of the filesystem tree archive\n"
+" portion of the package. It is currently produced "
+ "in\n"
+" a format similar to that generated by GNU and "
+ "BusyBox\n"
+" tar's verbose listing. User and group IDs and "
+ "names\n"
+" are not checked against those on the host system,\n"
+" since they may differ.\n"
+" -h, --help Show this help information and exit.\n"
+" -V, --version Show version information and exit."));
#else
- puts(" -I Print the named control file. If this option is given "
- "multiple times, the");
- puts(" named control files will be printed in the order they "
- "appear in the");
- puts(" package.");
- puts(" -f Print the control file.");
- puts(" -c List the contents of the filesystem tree archive portion "
- "of the package.");
- puts(" It is currently produced in a format similar to that "
- "generated by GNU and");
- puts(" BusyBox tar's verbose listing. User and group IDs and "
- "names are not");
- puts(" checked against those on the host system, since they may "
- "differ.");
- puts(" -h Show this help information and exit.");
- puts(" -V Show version information and exit.");
+ puts(_("Options:\n"
+" -I Print the named control file. If this option is given multiple times, "
+ "the\n"
+" named control files will be printed in the order they appear in the\n"
+" package.\n"
+" -f Print the control file.\n"
+" -c List the contents of the filesystem tree archive portion of the "
+ "package.\n"
+" It is currently produced in a format similar to that generated by GNU "
+ "and\n"
+" BusyBox tar's verbose listing. User and group IDs and names are not\n"
+" checked against those on the host system, since they may differ.\n"
+" -h Show this help information and exit.\n"
+" -V Show version information and exit."));
#endif
}
@@ -119,20 +117,24 @@ static void
_version(void)
{
printf("%s %s%s\n", PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_VERSION_GIT);
- printf("Copyright (C) %s %s\n", "2023", "Patrick McDermott");
- puts("License GPLv3+: GNU GPL version 3 or later "
+ /* TRANSLATORS: The "%s" conversion specifications are the copyright
+ * year(s) and copyright holder(s), respectively. */
+ printf(_("Copyright (C) %s %s\n"), "2023", "Patrick McDermott");
+ puts(_("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);
+ "law.\n"));
+ printf(_("Please report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
static void
_help_tip(const char *program_name)
{
- fprintf(stderr, "Try \"%s %s\" for more information\n", program_name,
+ /* TRANSLATORS: The "%s" conversion specifications are the program name
+ * and help option, respectively. */
+ fprintf(stderr, _("Try \"%s %s\" for more information\n"), program_name,
#ifdef HAVE_GETOPT_LONG
"--help"
#else
@@ -150,6 +152,15 @@ main(int argc, char *argv[])
int opt;
struct opkg_opk_opk *opk;
+#ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+#endif
+ textdomain(PACKAGE);
+ setlocale(LC_ALL, "");
+#endif
+
program_name = argv[0];
control_files = NULL;
list_members = 0;
@@ -185,7 +196,8 @@ main(int argc, char *argv[])
_version();
return EXIT_SUCCESS;
default:
- fprintf(stderr, "%s: Invalid option: \"%c\"\n",
+ fprintf(stderr, _("%s: Invalid option: "
+ "\"%c\"\n"),
program_name, optopt);
_help_tip(program_name);
return EXIT_FAILURE;
@@ -195,19 +207,19 @@ main(int argc, char *argv[])
argv += optind;
if (argc < 1) {
- fprintf(stderr, "%s: Missing package file operand\n",
+ fprintf(stderr, _("%s: Missing package file operand\n"),
program_name);
_help_tip(program_name);
return EXIT_FAILURE;
} else if (argc > 1) {
- fprintf(stderr, "%s: Too many package file operands\n",
+ fprintf(stderr, _("%s: Too many package file operands\n"),
program_name);
_help_tip(program_name);
return EXIT_FAILURE;
}
if (control_files == NULL && list_members == 0) {
- fprintf(stderr, "%s: At least one of -I, -f, or -c must be "
- "given\n", program_name);
+ fprintf(stderr, _("%s: At least one of -I, -f, or -c must be "
+ "given\n"), program_name);
_help_tip(program_name);
return EXIT_FAILURE;
}