00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef lint
00025 static const char rcsid[] = "@(#) $Id: gmo2msg.c,v 1.1.1.1 2005/10/21 19:00:00 marcel Exp $";
00026 #endif
00027
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <unistd.h>
00031 #include <stdio.h>
00032 #include <libintl.h>
00033
00034 #define DOMAIN "libelf"
00035
00036 static const char *msgs[] = {
00037 #define __err__(a,b) b,
00038 #include <errors.h>
00039 #undef __err__
00040 };
00041
00042 int
00043 main(int argc, char **argv) {
00044 char buf[1024], *lang, *progname, *s;
00045 unsigned i;
00046
00047 if (*argv && (progname = strrchr(argv[0], '/'))) {
00048 progname++;
00049 }
00050 else if (!(progname = *argv)) {
00051 progname = "gmo2msg";
00052 }
00053
00054 if (!(lang = getenv("LANGUAGE"))
00055 && !(lang = getenv("LC_ALL"))
00056 && !(lang = getenv("LC_MESSAGES"))
00057 && !(lang = getenv("LANG"))) {
00058 fprintf(stderr, "LANG variable not set.\n");
00059 exit(1);
00060 }
00061
00062
00063
00064
00065 getcwd(buf, sizeof(buf));
00066 bindtextdomain(DOMAIN, buf);
00067 sprintf(buf, "%s.gmo", lang);
00068 unlink(DOMAIN ".mo"); symlink(buf, DOMAIN ".mo");
00069 unlink("LC_MESSAGES"); symlink(".", "LC_MESSAGES");
00070 unlink(lang); symlink(".", lang);
00071 printf("$set 1 Automatically created from %s by %s\n", buf, progname);
00072
00073
00074
00075
00076
00077
00078 textdomain(DOMAIN);
00079 if ((s = gettext("")) && (s = strdup(s))) {
00080 s = strtok(s, "\n");
00081 while (s) {
00082 printf("$ %s\n", s);
00083 s = strtok(NULL, "\n");
00084 }
00085 }
00086 for (i = 0; i < sizeof(msgs)/sizeof(*msgs); i++) {
00087 s = gettext(msgs[i]);
00088 if (s != msgs[i] && strcmp(s, msgs[i])) {
00089 printf("$ \n$ Original message: %s\n", msgs[i]);
00090 printf("%u %s\n", i + 1, s);
00091 }
00092 }
00093
00094
00095
00096
00097 unlink(DOMAIN ".mo");
00098 unlink("LC_MESSAGES");
00099 unlink(lang);
00100 exit(0);
00101 }