12 static char *escape(
const char*
text,
char *
bf,
int len)
17 int textlen =
strlen(text);
19 if ((textlen > 0) && (text[textlen-1] ==
'\n'))
32 while (*text !=
'\0' && len > 1) {
35 else if (*text ==
'\n') {
45 else if (*text ==
'\\') {
90 static struct message *message__list;
100 self->files = file_line__new(file, lineno);
101 if (self->files ==
NULL)
104 self->msg = strdup(msg);
105 if (self->msg ==
NULL)
120 static struct message *mesage__find(
const char *
msg)
133 static int message__add_file_line(
struct message *
self,
const char *
file,
137 struct file_line *
fl = file_line__new(file, lineno);
142 fl->
next =
self->files;
149 static int message__add(
const char *msg,
char *
option,
const char *file,
154 char *escaped = escape(msg, bf,
sizeof(bf));
155 struct message *m = mesage__find(escaped);
158 rc = message__add_file_line(m, file, lineno);
160 m = message__new(escaped, option, file, lineno);
163 m->
next = message__list;
171 static void menu_build_message_list(
struct menu *
menu)
184 for (child = menu->
list; child !=
NULL; child = child->
next)
186 menu_build_message_list(child);
189 static void message__print_file_lineno(
struct message *
self)
194 if (self->option !=
NULL)
195 printf(
"# %s:00000\n", self->option);
208 static void message__print_gettext_msgid_msgstr(
struct message *
self)
210 message__print_file_lineno(
self);
213 "msgstr \"\"\n", self->msg);
216 static void menu__xgettext(
void)
218 struct message *m = message__list;
223 message__print_gettext_msgid_msgstr(m);