From: David Schleef Date: Sun, 19 Aug 2001 01:22:43 +0000 (+0000) Subject: gettext()ized X-Git-Tag: r0_7_17~40 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8b812d424c13e8950911a45f6aeb0b64192aa2e6;p=comedilib.git gettext()ized --- diff --git a/comedi_config/comedi_config.c b/comedi_config/comedi_config.c index b7a1711..0310ef6 100644 --- a/comedi_config/comedi_config.c +++ b/comedi_config/comedi_config.c @@ -38,6 +38,13 @@ #include +#ifdef I18N +#include +#define _(a) gettext(a) +#else +#define _(a) (a) +#endif + int quiet=0,verbose=0; int read_buf_size=0; @@ -61,20 +68,20 @@ struct option options[] = { void do_help(int i) { + fputs("comedi_config version " CC_VERSION "\n",stderr); fputs( -"comedi_config version " CC_VERSION "\n" -"usage: comedi_config [OPTIONS] [ ,,...]\n" +_("usage: comedi_config [OPTIONS] [ ,,...]\n" "\n" "OPTIONS:\n" -" -v --verbose\n" +" -v, --verbose\n" " verbose output\n" -" -q --quiet\n" +" -q, --quiet\n" " quiet output\n" -" -V --version\n" +" -V, --version\n" " print program version\n" -" -i --init-data \n" +" -i, --init-data \n" " Use file for driver initialization data, typically firmware code.\n" -" -r --remove\n" +" -r, --remove\n" " remove previously configured driver\n" " --read-buffer \n" " set buffer size in kilobytes used for reading\n" @@ -86,7 +93,7 @@ void do_help(int i) " indices of the board. If not specified, a board will automatically\n" " be chosen. For non-PCI boards, specifies the I/O port base\n" " address and, if applicable, specifies the IRQ. Additional\n" -" options may be useful, see the Comedi documentation for details.\n" +" options may be useful, see the Comedi documentation for details.\n") ,stderr); exit(i); } @@ -105,8 +112,12 @@ int main(int argc,char *argv[]) int remove=0; int index; + setlocale(LC_ALL, ""); + bindtextdomain("comedilib", "/home/ds/cvs/comedilib/doc"); + textdomain("comedilib"); + if(geteuid() != 0) - fprintf(stderr,"comedi_config should be run as root. Attempting to continue anyway.\n"); + fprintf(stderr,_("comedi_config should be run as root. Attempting to continue anyway.\n")); while(1){ c=getopt_long(argc, argv, "rvVqi:", options, &index); @@ -132,7 +143,7 @@ int main(int argc,char *argv[]) read_buf_size = strtol(optarg, NULL, 0); if(read_buf_size < 0) { - fprintf(stderr, "invalid buffer size\n"); + fprintf(stderr, _("invalid buffer size\n")); exit(-1); } break; @@ -140,7 +151,7 @@ int main(int argc,char *argv[]) write_buf_size = strtol(optarg, NULL, 0); if(write_buf_size < 0) { - fprintf(stderr, "invalid buffer size\n"); + fprintf(stderr, _("invalid buffer size\n")); exit(-1); } break; @@ -160,13 +171,13 @@ int main(int argc,char *argv[]) if(fd<0){ switch(errno){ case ENODEV: - fprintf(stderr,"comedi.o not loaded\n"); + fprintf(stderr,_("comedi.o not loaded\n")); break; case ENXIO: - fprintf(stderr,"device not configured\n"); + fprintf(stderr,_("device not configured\n")); break; case EPERM: - fprintf(stderr,"modprobe problem\n"); + fprintf(stderr,_("modprobe problem\n")); break; default: perror(fn); @@ -234,13 +245,13 @@ int main(int argc,char *argv[]) init_size = buf.st_size; init_data = malloc(init_size); if(init_data==NULL){ - perror("allocating initialization data\n"); + perror(_("allocating initialization data\n")); exit(1); } ret = read(init_fd,init_data,init_size); if(ret<0){ - perror("reading initialization data\n"); + perror(_("reading initialization data\n")); exit(1); } @@ -251,33 +262,33 @@ int main(int argc,char *argv[]) /* add: sanity check for device */ if(verbose){ - printf("configuring driver=%s ",it.board_name); + printf(_("configuring driver=%s "),it.board_name); for(i=0;i= 0.7.57\n"); + fprintf(stderr,_("Buffer resizing requires Comedi version >= 0.7.57\n")); exit(1); } } @@ -304,7 +315,7 @@ int main(int argc,char *argv[]) if(read_buf_size) { if(devinfo.read_subdevice){ - fprintf(stderr,"warning: no read subdevice, resize ignored\n"); + fprintf(stderr,_("warning: no read subdevice, resize ignored\n")); }else{ memset(&bc, 0, sizeof(bc)); bc.subdevice = devinfo.read_subdevice; @@ -312,12 +323,12 @@ int main(int argc,char *argv[]) bc.size = read_buf_size * 1024; if(ioctl(fd, COMEDI_BUFCONFIG, &bc) < 0) { - perror("buffer resize error"); + perror(_("buffer resize error")); exit(1); } if(verbose) { - printf("%s read buffer resized to %i kilobytes\n", + printf(_("%s read buffer resized to %i kilobytes\n"), fn, bc.size / 1024); } } @@ -325,7 +336,7 @@ int main(int argc,char *argv[]) if(write_buf_size) { if(devinfo.write_subdevice){ - fprintf(stderr,"warning: no write subdevice, resize ignored\n"); + fprintf(stderr,_("warning: no write subdevice, resize ignored\n")); }else{ memset(&bc, 0, sizeof(bc)); bc.subdevice = devinfo.write_subdevice; @@ -333,12 +344,12 @@ int main(int argc,char *argv[]) bc.size = write_buf_size * 1024; if(ioctl(fd, COMEDI_BUFCONFIG, &bc) < 0) { - perror("buffer resize error"); + perror(_("buffer resize error")); exit(1); } if(verbose) { - printf("%s write buffer resized to %i kilobytes\n", + printf(_("%s write buffer resized to %i kilobytes\n"), fn, bc.size / 1024); } }