diff options
-rw-r--r-- | src/main.c | 36 | ||||
-rw-r--r-- | src/opk.c | 32 |
2 files changed, 38 insertions, 30 deletions
@@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> #include "defs.h" +#include "i18n.h" #include "opk.h" #include "ustar.h" @@ -72,9 +73,9 @@ struct option _longopts[] = { static void _help(const char *program_name) { - printf("Usage: %s OPTION... PACKAGE\n", program_name); + printf(_("Usage: %s OPTION... PACKAGE\n"), program_name); #ifdef HAVE_GETOPT_LONG - puts("Options:\n" + 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" @@ -90,9 +91,9 @@ _help(const char *program_name) " 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."); +" -V, --version Show version information and exit.")); #else - puts("Options:\n" + 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" @@ -105,7 +106,7 @@ _help(const char *program_name) " 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."); +" -V Show version information and exit.")); #endif } @@ -113,20 +114,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 @@ -179,7 +184,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; @@ -189,19 +195,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; } @@ -24,6 +24,7 @@ #include <time.h> #include "defs.h" #include "gzip.h" +#include "i18n.h" #include "opk.h" #include "ustar.h" @@ -69,7 +70,7 @@ opkg_opk_opk_init(const char *file_name) /* Open outer archive. */ opk->file = fopen(file_name, "rb"); if (opk->file == NULL) { - fprintf(stderr, "Error: Failed to open file \"%s\"\n", + fprintf(stderr, _("Error: Failed to open file \"%s\"\n"), file_name); goto error1; } @@ -77,34 +78,34 @@ opkg_opk_opk_init(const char *file_name) /* Initialize outer gzip decompressor. */ opk->outer_gzip = opkg_opk_gzip_init(&_opkg_opk_opk_file_read, opk); if (opk->outer_gzip == NULL) { - fputs("Error: Failed to initialize\n", stderr); + fputs(_("Error: Failed to initialize\n"), stderr); goto error2; } /* Initialize outer ustar unarchiver. */ opk->outer_ustar = opkg_opk_ustar_init(opk->outer_gzip); if (opk->outer_ustar == NULL) { - fputs("Error: Failed to initialize\n", stderr); + fputs(_("Error: Failed to initialize\n"), stderr); goto error3; } /* Check package version. */ if (opkg_opk_ustar_seek_one(opk->outer_ustar, "debian-binary") != OPKG_OPK_OK) { - fputs("Error: Failed to find \"debian-binary\" in archive\n", + fputs(_("Error: Failed to find \"debian-binary\" in archive\n"), stderr); goto error4; } if (opkg_opk_ustar_read(opk->outer_ustar, &opk->version_buffer, &opk->version_size) != OPKG_OPK_OK) { - fputs("Error: Failed to read \"debian-binary\" in archive\n", + fputs(_("Error: Failed to read \"debian-binary\" in archive\n"), stderr); goto error4; } if (opk->version_size < 4 || strncmp(opk->version_buffer, "2.", 2) != 0) { - fputs("Error: Unsupported package version\n", stderr); + fputs(_("Error: Unsupported package version\n"), stderr); goto error4; } @@ -133,13 +134,13 @@ _opkg_opk_opk_init_inner(struct opkg_opk_opk *opk, const char *member) while ((ret = opkg_opk_ustar_read(opk->outer_ustar, NULL, NULL)) == OPKG_OPK_OK); if (ret == OPKG_OPK_ERROR) { - fputs("Error: Failed to read archive\n", stderr); + fputs(_("Error: Failed to read archive\n"), stderr); return OPKG_OPK_ERROR; } /* Find requested inner archive. */ if (opkg_opk_ustar_seek_one(opk->outer_ustar, member) != OPKG_OPK_OK) { - fprintf(stderr, "Error: Failed to find \"%s\" in archive\n", + fprintf(stderr, _("Error: Failed to find \"%s\" in archive\n"), member); return OPKG_OPK_ERROR; } @@ -149,14 +150,14 @@ _opkg_opk_opk_init_inner(struct opkg_opk_opk *opk, const char *member) (opkg_opk_gzip_read_func *) &opkg_opk_ustar_read, opk->outer_ustar); if (opk->inner_gzip == NULL) { - fputs("Error: Failed to initialize\n", stderr); + fputs(_("Error: Failed to initialize\n"), stderr); return OPKG_OPK_ERROR; } /* Initialize inner ustar unarchiver. */ opk->inner_ustar = opkg_opk_ustar_init(opk->inner_gzip); if (opk->inner_ustar == NULL) { - fputs("Error: Failed to initialize\n", stderr); + fputs(_("Error: Failed to initialize\n"), stderr); opkg_opk_gzip_free(opk->inner_gzip); return OPKG_OPK_ERROR; } @@ -193,14 +194,15 @@ opkg_opk_opk_read_control(struct opkg_opk_opk *opk, &buffer, &size)) == OPKG_OPK_OK) { if (fwrite(buffer, 1, size, stdout) != size) { - fputs("Error: Failed to print control file\n", - stderr); + fputs(_("Error: Failed to print control file\n") + , stderr); _opkg_opk_opk_free_inner(opk); return OPKG_OPK_ERROR; } } if (ret_read == OPKG_OPK_ERROR) { - fputs("Error: Failed to read control file\n", stderr); + fputs(_("Error: Failed to read control file\n"), + stderr); _opkg_opk_opk_free_inner(opk); return OPKG_OPK_ERROR; } @@ -210,7 +212,7 @@ opkg_opk_opk_read_control(struct opkg_opk_opk *opk, } } if (ret_seek == OPKG_OPK_ERROR) { - fputs("Error: Failed to find control file\n", stderr); + fputs(_("Error: Failed to find control file\n"), stderr); _opkg_opk_opk_free_inner(opk); return OPKG_OPK_ERROR; } @@ -273,7 +275,7 @@ opkg_opk_opk_list_members(struct opkg_opk_opk *opk) } } if (ret == OPKG_OPK_ERROR) { - fputs("Error: Failed to list data files\n", stderr); + fputs(_("Error: Failed to list data files\n"), stderr); _opkg_opk_opk_free_inner(opk); return OPKG_OPK_ERROR; } |