diff -rupN linux-2.6.24/Makefile linux-2.6.24-i18n/Makefile --- linux-2.6.24/Makefile 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/Makefile 2008-01-25 13:19:28.000000000 +0100 @@ -1084,6 +1084,7 @@ endif # CONFIG_MODULES # Directories & files removed with 'make clean' CLEAN_DIRS += $(MODVERDIR) +CLEAN_DIRS += .locale CLEAN_FILES += vmlinux System.map \ .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map diff -rupN linux-2.6.24/scripts/kconfig/conf.c linux-2.6.24-i18n/scripts/kconfig/conf.c --- linux-2.6.24/scripts/kconfig/conf.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/conf.c 2008-01-25 13:19:28.000000000 +0100 @@ -40,7 +40,7 @@ static char nohelp_text[] = N_("Sorry, n static const char *get_help(struct menu *menu) { if (menu_has_help(menu)) - return menu_get_help(menu); + return _(menu_get_help(menu)); else return nohelp_text; } @@ -78,7 +78,7 @@ static int conf_askvalue(struct symbol * tristate val; if (!sym_has_value(sym)) - printf("(NEW) "); + printf(_("(NEW) ")); line[0] = '\n'; line[1] = 0; @@ -183,7 +183,7 @@ int conf_string(struct menu *menu) const char *def; while (1) { - printf("%*s%s ", indent - 1, "", menu->prompt->text); + printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); printf("(%s) ", sym->name); def = sym_get_string_value(sym); if (sym_get_string_value(sym)) @@ -216,7 +216,7 @@ static int conf_sym(struct menu *menu) tristate oldval, newval; while (1) { - printf("%*s%s ", indent - 1, "", menu->prompt->text); + printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); if (sym->name) printf("(%s) ", sym->name); type = sym_get_type(sym); @@ -306,7 +306,7 @@ static int conf_choice(struct menu *menu case no: return 1; case mod: - printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); return 0; case yes: break; @@ -316,7 +316,7 @@ static int conf_choice(struct menu *menu while (1) { int cnt, def; - printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); + printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); def_sym = sym_get_choice_value(sym); cnt = def = 0; line[0] = 0; @@ -324,7 +324,7 @@ static int conf_choice(struct menu *menu if (!menu_is_visible(child)) continue; if (!child->sym) { - printf("%*c %s\n", indent, '*', menu_get_prompt(child)); + printf("%*c %s\n", indent, '*', _(menu_get_prompt(child))); continue; } cnt++; @@ -333,14 +333,14 @@ static int conf_choice(struct menu *menu printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); - printf(" %d. %s", cnt, menu_get_prompt(child)); + printf(" %d. %s", cnt, _(menu_get_prompt(child))); if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) - printf(" (NEW)"); + printf(_(" (NEW)")); printf("\n"); } - printf("%*schoice", indent - 1, ""); + printf(_("%*schoice"), indent - 1, ""); if (cnt == 1) { printf("[1]: 1\n"); goto conf_childs; @@ -433,7 +433,7 @@ static void conf(struct menu *menu) if (prompt) printf("%*c\n%*c %s\n%*c\n", indent, '*', - indent, '*', prompt, + indent, '*', _(prompt), indent, '*'); default: ; @@ -499,6 +499,10 @@ int main(int ac, char **av) const char *name; struct stat tmpstat; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (ac > i && av[i][0] == '-') { switch (av[i++][1]) { case 'o': @@ -535,7 +539,7 @@ int main(int ac, char **av) break; case 'h': case '?': - fprintf(stderr, "See README for usage info\n"); + fprintf(stderr, _("See README for usage info\n")); exit(0); } } @@ -551,9 +555,9 @@ int main(int ac, char **av) if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { - printf("***\n" + printf(_("***\n" "*** Can't find default configuration \"%s\"!\n" - "***\n", defconfig_file); + "***\n"), defconfig_file); exit(1); } break; diff -rupN linux-2.6.24/scripts/kconfig/gconf.c linux-2.6.24-i18n/scripts/kconfig/gconf.c --- linux-2.6.24/scripts/kconfig/gconf.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/gconf.c 2008-01-25 13:19:28.000000000 +0100 @@ -457,14 +457,18 @@ static void text_insert_help(struct menu { GtkTextBuffer *buffer; GtkTextIter start, end; - const char *prompt = menu_get_prompt(menu); + const char *prompt = _(menu_get_prompt(menu)); gchar *name; const char *help; - help = _(menu_get_help(menu)); + help = menu_get_help(menu); + + /* Gettextize if the help text not empty */ + if ((help != 0) && (help[0] != 0)) + help = _(help); if (menu->sym && menu->sym->name) - name = g_strdup_printf(_(menu->sym->name)); + name = g_strdup_printf(menu->sym->name); else name = g_strdup(""); @@ -1171,7 +1175,7 @@ static gchar **fill_row(struct menu *men bzero(row, sizeof(row)); row[COL_OPTION] = - g_strdup_printf("%s %s", menu_get_prompt(menu), + g_strdup_printf("%s %s", _(menu_get_prompt(menu)), sym && sym_has_value(sym) ? "(NEW)" : ""); if (show_all && !menu_is_visible(menu)) @@ -1221,7 +1225,7 @@ static gchar **fill_row(struct menu *men if (def_menu) row[COL_VALUE] = - g_strdup(menu_get_prompt(def_menu)); + g_strdup(_(menu_get_prompt(def_menu))); } if (sym->flags & SYMBOL_CHOICEVAL) row[COL_BTNRAD] = GINT_TO_POINTER(TRUE); diff -rupN linux-2.6.24/scripts/kconfig/lex.zconf.c_shipped linux-2.6.24-i18n/scripts/kconfig/lex.zconf.c_shipped --- linux-2.6.24/scripts/kconfig/lex.zconf.c_shipped 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lex.zconf.c_shipped 2008-01-25 13:19:28.000000000 +0100 @@ -1275,6 +1275,11 @@ YY_RULE_SETUP case 32: YY_RULE_SETUP { + while (zconfleng) { + if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t')) + break; + zconfleng--; + } append_string(zconftext, zconfleng); if (!first_ts) first_ts = last_ts; diff -rupN linux-2.6.24/scripts/kconfig/lkc.h linux-2.6.24-i18n/scripts/kconfig/lkc.h --- linux-2.6.24/scripts/kconfig/lkc.h 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lkc.h 2008-01-25 13:19:28.000000000 +0100 @@ -32,7 +32,7 @@ extern "C" { #define SRCTREE "srctree" #define PACKAGE "linux" -#define LOCALEDIR "/usr/share/locale" +#define LOCALEDIR ".locale" #define _(text) gettext(text) #define N_(text) (text) diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/checklist.c linux-2.6.24-i18n/scripts/kconfig/lxdialog/checklist.c --- linux-2.6.24/scripts/kconfig/lxdialog/checklist.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/checklist.c 2008-01-25 13:19:28.000000000 +0100 @@ -44,9 +44,9 @@ static void print_item(WINDOW * win, int wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); - mvwaddch(win, choice, item_x, item_str()[0]); + mvwaddnwstr(win, choice, item_x, &item_str()[0], 1); wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); - waddstr(win, (char *)item_str() + 1); + waddwstr(win, &item_str()[1]); if (selected) { wmove(win, choice, check_x + 1); wrefresh(win); @@ -97,8 +97,8 @@ static void print_buttons(WINDOW * dialo int x = width / 2 - 11; int y = height - 2; - print_button(dialog, "Select", y, x, selected == 0); - print_button(dialog, " Help ", y, x + 14, selected == 1); + print_button(dialog, gettext("Select"), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); wmove(dialog, y, x + 1 + 14 * selected); wrefresh(dialog); @@ -112,8 +112,9 @@ int dialog_checklist(const char *title, int width, int list_height) { int i, x, y, box_x, box_y; - int key = 0, button = 0, choice = 0, scroll = 0, max_choice; + int button = 0, choice = 0, scroll = 0, max_choice; WINDOW *dialog, *list; + wint_t key = 0; /* which item to highlight */ item_foreach() { @@ -173,7 +174,7 @@ do_resize: /* Find length of longest item in order to center checklist */ check_x = 0; item_foreach() - check_x = MAX(check_x, strlen(item_str()) + 4); + check_x = MAX(check_x, MIN(list_width, wcslen(item_str()) + 4)); check_x = (list_width - check_x) / 2; item_x = check_x + 4; @@ -199,11 +200,11 @@ do_resize: doupdate(); while (key != KEY_ESC) { - key = wgetch(dialog); + wget_wch(dialog, &key); for (i = 0; i < max_choice; i++) { item_set(i + scroll); - if (toupper(key) == toupper(item_str()[0])) + if (towupper(key) == towupper(item_str()[0])) break; } diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/check-lxdialog.sh linux-2.6.24-i18n/scripts/kconfig/lxdialog/check-lxdialog.sh --- linux-2.6.24/scripts/kconfig/lxdialog/check-lxdialog.sh 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/check-lxdialog.sh 2008-01-25 13:19:28.000000000 +0100 @@ -19,14 +19,12 @@ ldflags() # Where is ncurses.h? ccflags() { - if [ -f /usr/include/ncurses/ncurses.h ]; then - echo '-I/usr/include/ncurses -DCURSES_LOC=""' - elif [ -f /usr/include/ncurses/curses.h ]; then - echo '-I/usr/include/ncurses -DCURSES_LOC=""' - elif [ -f /usr/include/ncurses.h ]; then - echo '-DCURSES_LOC=""' + if [ -f /usr/include/ncursesw/curses.h ]; then + echo '-DCURSES_LOC=""' + elif [ -f /usr/include/ncursesw/ncurses.h ]; then + echo '-DCURSES_LOC=""' else - echo '-DCURSES_LOC=""' + exit 1 fi } @@ -38,11 +36,11 @@ trap "rm -f $tmp" 0 1 2 3 15 check() { echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null if [ $? != 0 ]; then - echo " *** Unable to find the ncurses libraries." 1>&2 - echo " *** make menuconfig require the ncurses libraries" 1>&2 - echo " *** " 1>&2 - echo " *** Install ncurses (ncurses-devel) and try again" 1>&2 - echo " *** " 1>&2 + echo " *** Unable to find the ncursesw libraries." 1>&2 + echo " *** make menuconfig require the ncursesw libraries" 1>&2 + echo " *** " 1>&2 + echo " *** Install wide ncurses (ncursesw-devel) and try again" 1>&2 + echo " *** " 1>&2 exit 1 fi } diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/dialog.h linux-2.6.24-i18n/scripts/kconfig/lxdialog/dialog.h --- linux-2.6.24/scripts/kconfig/lxdialog/dialog.h 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/dialog.h 2008-01-25 13:19:28.000000000 +0100 @@ -26,6 +26,21 @@ #include #include +#ifndef KBUILD_NO_NLS +# include +#else +# define gettext(Msgid) ((const char *) (Msgid)) +#endif + +/* Wide character support for lxdialog */ +#define _XOPEN_SOURCE_EXTENDED +#include +#include + +wchar_t* str2wcs (const char *mbs); +int stradd2wcs (wchar_t *wcs, const char *mbs, size_t n); +int wcsadd2str (char *mbs, const wchar_t *wcs, size_t n); + #ifdef __sun__ #define CURS_MACROS #endif @@ -157,7 +172,7 @@ char item_tag(void); /* item list manipulation for lxdialog use */ #define MAXITEMSTR 200 struct dialog_item { - char str[MAXITEMSTR]; /* promtp displayed */ + wchar_t str[MAXITEMSTR]; /* prompt displayed */ char tag; void *data; /* pointer to menu item - used by menubox+checklist */ int selected; /* Set to 1 by dialog_*() function if selected. */ @@ -176,7 +191,7 @@ extern struct dialog_list *item_head; int item_count(void); void item_set(int n); int item_n(void); -const char *item_str(void); +const wchar_t *item_str(void); int item_is_selected(void); int item_is_tag(char tag); #define item_foreach() \ @@ -200,7 +215,7 @@ void draw_box(WINDOW * win, int y, int x chtype border); void draw_shadow(WINDOW * win, int y, int x, int height, int width); -int first_alpha(const char *string, const char *exempt); +int first_alpha(const wchar_t *string, const char *exempt); int dialog_yesno(const char *title, const char *prompt, int height, int width); int dialog_msgbox(const char *title, const char *prompt, int height, int width, int pause); @@ -223,3 +238,9 @@ int dialog_inputbox(const char *title, c * -- uppercase chars are used to invoke the button (M_EVENT + 'O') */ #define M_EVENT (KEY_MAX+1) + +/* Wide char helpers */ +wchar_t* str2wcs (const char *mbs); +int stradd2wcs (wchar_t *wcs, const char *mbs, size_t n); +int wcsadd2str (char *mbs, const wchar_t *wcs, size_t n); + diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/inputbox.c linux-2.6.24-i18n/scripts/kconfig/lxdialog/inputbox.c --- linux-2.6.24/scripts/kconfig/lxdialog/inputbox.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/inputbox.c 2008-01-25 13:19:28.000000000 +0100 @@ -31,8 +31,8 @@ static void print_buttons(WINDOW * dialo int x = width / 2 - 11; int y = height - 2; - print_button(dialog, " Ok ", y, x, selected == 0); - print_button(dialog, " Help ", y, x + 14, selected == 1); + print_button(dialog, gettext(" Ok "), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); wmove(dialog, y, x + 1 + 14 * selected); wrefresh(dialog); @@ -45,14 +45,16 @@ int dialog_inputbox(const char *title, c const char *init) { int i, x, y, box_y, box_x, box_width; - int input_x = 0, scroll = 0, key = 0, button = -1; - char *instr = dialog_input_result; + int input_x = 0, scroll = 0, button = -1; + wchar_t instr[MAX_LEN + 1]; + wint_t key = 0; + wchar_t showkey; WINDOW *dialog; if (!init) instr[0] = '\0'; else - strcpy(instr, init); + stradd2wcs(instr, init, MAX_LEN + 1); do_resize: if (getmaxy(stdscr) <= (height - 2)) @@ -97,15 +99,15 @@ do_resize: wmove(dialog, box_y, box_x); wattrset(dialog, dlg.inputbox.atr); - input_x = strlen(instr); + input_x = wcslen(instr); if (input_x >= box_width) { scroll = input_x - box_width + 1; input_x = box_width - 1; for (i = 0; i < box_width - 1; i++) - waddch(dialog, instr[scroll + i]); + waddnwstr(dialog, &instr[scroll + i], 1); } else { - waddstr(dialog, instr); + waddwstr(dialog, instr); } wmove(dialog, box_y, box_x + input_x); @@ -113,7 +115,7 @@ do_resize: wrefresh(dialog); while (key != KEY_ESC) { - key = wgetch(dialog); + wget_wch(dialog, &key); if (button == -1) { /* Input box selected */ switch (key) { @@ -133,10 +135,10 @@ do_resize: scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); wmove(dialog, box_y, box_x); for (i = 0; i < box_width; i++) - waddch(dialog, - instr[scroll + input_x + i] ? - instr[scroll + input_x + i] : ' '); - input_x = strlen(instr) - scroll; + instr[scroll + input_x + i] ? + waddnwstr(dialog, &instr[scroll + input_x + i], 1) : + waddch(dialog, ' '); + input_x = wcslen(instr) - scroll; } else input_x--; instr[scroll + input_x] = '\0'; @@ -146,7 +148,7 @@ do_resize: } continue; default: - if (key < 0x100 && isprint(key)) { + if (iswprint(key)) { if (scroll + input_x < MAX_LEN) { wattrset(dialog, dlg.inputbox.atr); instr[scroll + input_x] = key; @@ -155,10 +157,11 @@ do_resize: scroll++; wmove(dialog, box_y, box_x); for (i = 0; i < box_width - 1; i++) - waddch(dialog, instr [scroll + i]); + waddnwstr(dialog, &instr[scroll + i], 1); } else { wmove(dialog, box_y, input_x++ + box_x); - waddch(dialog, key); + showkey = key; + waddnwstr(dialog, &showkey, 1); } wrefresh(dialog); } else @@ -170,10 +173,12 @@ do_resize: switch (key) { case 'O': case 'o': + wcsadd2str(dialog_input_result, instr, MAX_LEN + 1); delwin(dialog); return 0; case 'H': case 'h': + wcsadd2str(dialog_input_result, instr, MAX_LEN + 1); delwin(dialog); return 1; case KEY_UP: @@ -217,6 +222,7 @@ do_resize: break; case ' ': case '\n': + wcsadd2str(dialog_input_result, instr, MAX_LEN + 1); delwin(dialog); return (button == -1 ? 0 : button); case 'X': diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/menubox.c linux-2.6.24-i18n/scripts/kconfig/lxdialog/menubox.c --- linux-2.6.24/scripts/kconfig/lxdialog/menubox.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/menubox.c 2008-01-25 13:19:28.000000000 +0100 @@ -63,13 +63,13 @@ static int menu_width, item_x; /* * Print menu item */ -static void do_print_item(WINDOW * win, const char *item, int line_y, +static void do_print_item(WINDOW * win, const wchar_t *item, int line_y, int selected, int hotkey) { int j; - char *menu_item = malloc(menu_width + 1); + wchar_t *menu_item = malloc((menu_width + 1) * sizeof(wchar_t)); - strncpy(menu_item, item, menu_width - item_x); + wcsncpy(menu_item, item, menu_width - item_x); menu_item[menu_width - item_x] = '\0'; j = first_alpha(menu_item, "YyNnMmHh"); @@ -86,11 +86,11 @@ static void do_print_item(WINDOW * win, wclrtoeol(win); #endif wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); - mvwaddstr(win, line_y, item_x, menu_item); + mvwaddwstr(win, line_y, item_x, menu_item); if (hotkey) { wattrset(win, selected ? dlg.tag_key_selected.atr : dlg.tag_key.atr); - mvwaddch(win, line_y, item_x + j, menu_item[j]); + mvwaddnwstr(win, line_y, item_x + j, &menu_item[j], 1); } if (selected) { wmove(win, line_y, item_x + 1); @@ -157,9 +157,9 @@ static void print_buttons(WINDOW * win, int x = width / 2 - 16; int y = height - 2; - print_button(win, "Select", y, x, selected == 0); - print_button(win, " Exit ", y, x + 12, selected == 1); - print_button(win, " Help ", y, x + 24, selected == 2); + print_button(win, gettext("Select"), y, x, selected == 0); + print_button(win, gettext(" Exit "), y, x + 12, selected == 1); + print_button(win, gettext(" Help "), y, x + 24, selected == 2); wmove(win, y, x + 1 + 12 * selected); wrefresh(win); @@ -184,9 +184,10 @@ int dialog_menu(const char *title, const { int i, j, x, y, box_x, box_y; int height, width, menu_height; - int key = 0, button = 0, scroll = 0, choice = 0; + int button = 0, scroll = 0, choice = 0; int first_item = 0, max_choice; WINDOW *dialog, *menu; + wint_t key = 0; do_resize: height = getmaxy(stdscr); @@ -278,25 +279,25 @@ do_resize: wrefresh(menu); while (key != KEY_ESC) { - key = wgetch(menu); + wget_wch(menu, &key); - if (key < 256 && isalpha(key)) - key = tolower(key); + if (key < 256 && iswalpha(key)) + key = towlower(key); - if (strchr("ynmh", key)) + if (strchr("ynmh", (int)key)) i = max_choice; else { for (i = choice + 1; i < max_choice; i++) { item_set(scroll + i); j = first_alpha(item_str(), "YyNnMmHh"); - if (key == tolower(item_str()[j])) + if (key == towlower(item_str()[j])) break; } if (i == max_choice) for (i = 0; i < max_choice; i++) { item_set(scroll + i); j = first_alpha(item_str(), "YyNnMmHh"); - if (key == tolower(item_str()[j])) + if (key == towlower(item_str()[j])) break; } } diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/textbox.c linux-2.6.24-i18n/scripts/kconfig/lxdialog/textbox.c --- linux-2.6.24/scripts/kconfig/lxdialog/textbox.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/textbox.c 2008-01-25 13:19:28.000000000 +0100 @@ -24,13 +24,13 @@ static void back_lines(int n); static void print_page(WINDOW * win, int height, int width); static void print_line(WINDOW * win, int row, int width); -static char *get_line(void); +static wchar_t *get_line(void); static void print_position(WINDOW * win); static int hscroll; static int begin_reached, end_reached, page_length; -static const char *buf; -static const char *page; +static wchar_t *buf; +static const wchar_t *page; /* * refresh window content @@ -51,16 +51,17 @@ static void refresh_text_box(WINDOW *dia int dialog_textbox(const char *title, const char *tbuf, int initial_height, int initial_width) { - int i, x, y, cur_x, cur_y, key = 0; + int i, x, y, cur_x, cur_y; int height, width, boxh, boxw; int passed_end; WINDOW *dialog, *box; + wint_t key = 0; begin_reached = 1; end_reached = 0; page_length = 0; hscroll = 0; - buf = tbuf; + buf = str2wcs(tbuf); page = buf; /* page is pointer to start of page to be displayed */ do_resize: @@ -114,7 +115,7 @@ do_resize: print_title(dialog, title, width); - print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); + print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE); wnoutrefresh(dialog); getyx(dialog, cur_y, cur_x); /* Save cursor position */ @@ -123,7 +124,7 @@ do_resize: refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); while ((key != KEY_ESC) && (key != '\n')) { - key = wgetch(dialog); + wget_wch(dialog, &key); switch (key) { case 'E': /* Exit */ case 'e': @@ -146,7 +147,7 @@ do_resize: end_reached = 1; /* point to last char in buf */ - page = buf + strlen(buf); + page = &buf[wcslen(buf)]; back_lines(boxh); refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); @@ -321,13 +322,13 @@ static void print_page(WINDOW * win, int static void print_line(WINDOW * win, int row, int width) { int y, x; - char *line; + wchar_t *line; line = get_line(); - line += MIN(strlen(line), hscroll); /* Scroll horizontally */ + line += MIN(wcslen(line), hscroll) * sizeof(wchar_t); /* Scroll horizontally */ wmove(win, row, 0); /* move cursor to correct line */ waddch(win, ' '); - waddnstr(win, line, MIN(strlen(line), width - 2)); + waddnwstr(win, line, MIN(wcslen(line), width - 2)); getyx(win, y, x); /* Clear 'residue' of previous line */ @@ -337,9 +338,9 @@ static void print_line(WINDOW * win, int for (i = 0; i < width - x; i++) waddch(win, ' '); } -#else +#else /* OLD_NCURSES */ wclrtoeol(win); -#endif +#endif /* OLD_NCURSES */ } /* @@ -347,10 +348,10 @@ static void print_line(WINDOW * win, int * 'page' should point to start of current line before calling, and will be * updated to point to start of next line. */ -static char *get_line(void) +static wchar_t *get_line(void) { int i = 0; - static char line[MAX_LEN + 1]; + static wchar_t line[MAX_LEN + 1]; end_reached = 0; while (*page != '\n') { @@ -385,7 +386,7 @@ static void print_position(WINDOW * win) wattrset(win, dlg.position_indicator.atr); wbkgdset(win, dlg.position_indicator.atr & A_COLOR); - percent = (page - buf) * 100 / strlen(buf); + percent = (page - buf) * 100 / wcslen(buf); wmove(win, getmaxy(win) - 3, getmaxx(win) - 9); wprintw(win, "(%3d%%)", percent); } diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/util.c linux-2.6.24-i18n/scripts/kconfig/lxdialog/util.c --- linux-2.6.24/scripts/kconfig/lxdialog/util.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/util.c 2008-01-25 13:19:28.000000000 +0100 @@ -299,12 +299,15 @@ void end_dialog(void) **/ void print_title(WINDOW *dialog, const char *title, int width) { + wchar_t *wtitle; if (title) { - int tlen = MIN(width - 2, strlen(title)); + wtitle = str2wcs(title); + int tlen = MIN(width - 2, wcslen(wtitle)); wattrset(dialog, dlg.title.atr); mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); - mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); + mvwaddnwstr(dialog, 0, (width - tlen) / 2, wtitle, tlen); waddch(dialog, ' '); + free(wtitle); } } @@ -318,11 +321,11 @@ void print_autowrap(WINDOW * win, const { int newl, cur_x, cur_y; int i, prompt_len, room, wlen; - char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + wchar_t tempstr[MAX_LEN + 1], *word, *sp, *sp2; - strcpy(tempstr, prompt); + stradd2wcs(tempstr, prompt, MAX_LEN + 1); - prompt_len = strlen(tempstr); + prompt_len = wcslen(tempstr); /* * Remove newlines @@ -334,14 +337,14 @@ void print_autowrap(WINDOW * win, const if (prompt_len <= width - x * 2) { /* If prompt is short */ wmove(win, y, (width - prompt_len) / 2); - waddstr(win, tempstr); + waddwstr(win, tempstr); } else { cur_x = x; cur_y = y; newl = 1; word = tempstr; while (word && *word) { - sp = strchr(word, ' '); + sp = wcschr(word, ' '); if (sp) *sp++ = 0; @@ -349,17 +352,17 @@ void print_autowrap(WINDOW * win, const or it is the first word of a new sentence, and it is short, and the next word does not fit. */ room = width - cur_x; - wlen = strlen(word); + wlen = wcslen(word); if (wlen > room || (newl && wlen < 4 && sp - && wlen + 1 + strlen(sp) > room - && (!(sp2 = strchr(sp, ' ')) + && wlen + 1 + wcslen(sp) > room + && (!(sp2 = wcschr(sp, ' ')) || wlen + 1 + (sp2 - sp) > room))) { cur_y++; cur_x = x; } wmove(win, cur_y, cur_x); - waddstr(win, word); + waddwstr(win, word); getyx(win, cur_y, cur_x); cur_x++; if (sp && *sp == ' ') { @@ -379,6 +382,7 @@ void print_autowrap(WINDOW * win, const void print_button(WINDOW * win, const char *label, int y, int x, int selected) { int i, temp; + wchar_t *wlabel; wmove(win, y, x); wattrset(win, selected ? dlg.button_active.atr @@ -386,20 +390,22 @@ void print_button(WINDOW * win, const ch waddstr(win, "<"); temp = strspn(label, " "); label += temp; + wlabel = str2wcs(label); wattrset(win, selected ? dlg.button_label_active.atr : dlg.button_label_inactive.atr); for (i = 0; i < temp; i++) waddch(win, ' '); wattrset(win, selected ? dlg.button_key_active.atr : dlg.button_key_inactive.atr); - waddch(win, label[0]); + waddch(win, wlabel[0]); wattrset(win, selected ? dlg.button_label_active.atr : dlg.button_label_inactive.atr); - waddstr(win, (char *)label + 1); + waddwstr(win, &wlabel[1]); wattrset(win, selected ? dlg.button_active.atr : dlg.button_inactive.atr); waddstr(win, ">"); wmove(win, y, x + temp + 1); + free(wlabel); } /* @@ -461,19 +467,19 @@ void draw_shadow(WINDOW * win, int y, in /* * Return the position of the first alphabetic character in a string. */ -int first_alpha(const char *string, const char *exempt) +int first_alpha(const wchar_t *string, const char *exempt) { int i, in_paren = 0, c; - for (i = 0; i < strlen(string); i++) { - c = tolower(string[i]); + for (i = 0; i < wcslen(string); i++) { + c = towlower(string[i]); if (strchr("<[(", c)) ++in_paren; if (strchr(">])", c) && in_paren > 0) --in_paren; - if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) + if ((!in_paren) && iswalpha(c) && strchr(exempt, c) == 0) return i; } @@ -538,6 +544,8 @@ void item_reset(void) void item_make(const char *fmt, ...) { va_list ap; + char *tempstr; + size_t n; struct dialog_list *p = malloc(sizeof(*p)); if (item_head) @@ -548,21 +556,28 @@ void item_make(const char *fmt, ...) memset(p, 0, sizeof(*p)); va_start(ap, fmt); - vsnprintf(item_cur->node.str, sizeof(item_cur->node.str), fmt, ap); + n = sizeof(item_cur->node.str) / sizeof(wchar_t); + tempstr = malloc(n + 1); + vsnprintf(tempstr, n, fmt, ap); + stradd2wcs(item_cur->node.str, tempstr, n); + free(tempstr); va_end(ap); } void item_add_str(const char *fmt, ...) { va_list ap; + char *tempstr; size_t avail; - avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str); + avail = sizeof(item_cur->node.str) / sizeof(wchar_t) - wcslen(item_cur->node.str); va_start(ap, fmt); - vsnprintf(item_cur->node.str + strlen(item_cur->node.str), - avail, fmt, ap); - item_cur->node.str[sizeof(item_cur->node.str) - 1] = '\0'; + tempstr = malloc(avail); + vsnprintf(tempstr, avail, fmt, ap); + stradd2wcs(&item_cur->node.str[wcslen(item_cur->node.str)], tempstr, avail); + free(tempstr); + item_cur->node.str[sizeof(item_cur->node.str) / sizeof(wchar_t) - 1] = '\0'; va_end(ap); } @@ -629,7 +644,7 @@ int item_n(void) return 0; } -const char *item_str(void) +const wchar_t *item_str(void) { return item_cur->node.str; } @@ -643,3 +658,57 @@ int item_is_tag(char tag) { return (item_cur->node.tag == tag); } + +/* Return the wide char version of multibyte character */ +wchar_t* str2wcs (const char *mbs) +{ + wchar_t *wcs; + size_t n; + + if (mbs) { + n = (2 + strlen(mbs)) * sizeof(wchar_t); + wcs = (wchar_t*) malloc (n); + if (stradd2wcs(wcs, mbs, n) != 0) { + free (wcs); + wcs = 0; + } + } + else + wcs = 0; + + return wcs; +} + +/* Copy a multibyte string into the allocated widechar string */ +int stradd2wcs (wchar_t *wcs, const char *mbs, size_t n) +{ + mbstate_t state; + const char *mbsptr; + + if (mbs) { + memset (&state, 0, sizeof(state)); + mbsptr = mbs; + if (mbsrtowcs (wcs, &mbsptr, n, &state) < 0) + return -1; + return 0; + } + + return -1; +} + +/* Copy a widechar string into the allocated multibyte string */ +int wcsadd2str (char *mbs, const wchar_t *wcs, size_t n) +{ + mbstate_t state; + const wchar_t *wcsptr; + + if (wcs) { + memset (&state, 0, sizeof(state)); + wcsptr = wcs; + if (wcsrtombs (mbs, &wcsptr, n, &state) < 0) + return -1; + return 0; + } + + return -1; +} diff -rupN linux-2.6.24/scripts/kconfig/lxdialog/yesno.c linux-2.6.24-i18n/scripts/kconfig/lxdialog/yesno.c --- linux-2.6.24/scripts/kconfig/lxdialog/yesno.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/lxdialog/yesno.c 2008-01-25 13:19:28.000000000 +0100 @@ -29,8 +29,8 @@ static void print_buttons(WINDOW * dialo int x = width / 2 - 10; int y = height - 2; - print_button(dialog, " Yes ", y, x, selected == 0); - print_button(dialog, " No ", y, x + 13, selected == 1); + print_button(dialog, gettext(" Yes "), y, x, selected == 0); + print_button(dialog, gettext(" No "), y, x + 13, selected == 1); wmove(dialog, y, x + 1 + 13 * selected); wrefresh(dialog); @@ -41,8 +41,9 @@ static void print_buttons(WINDOW * dialo */ int dialog_yesno(const char *title, const char *prompt, int height, int width) { - int i, x, y, key = 0, button = 0; + int i, x, y, button = 0; WINDOW *dialog; + wint_t key = 0; do_resize: if (getmaxy(stdscr) < (height + 4)) @@ -76,7 +77,7 @@ do_resize: print_buttons(dialog, height, width, 0); while (key != KEY_ESC) { - key = wgetch(dialog); + wget_wch(dialog, &key); switch (key) { case 'Y': case 'y': diff -rupN linux-2.6.24/scripts/kconfig/Makefile linux-2.6.24-i18n/scripts/kconfig/Makefile --- linux-2.6.24/scripts/kconfig/Makefile 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/Makefile 2008-01-25 13:19:28.000000000 +0100 @@ -6,16 +6,16 @@ PHONY += oldconfig xconfig gconfig menuc Kconfig := arch/$(SRCARCH)/Kconfig -xconfig: $(obj)/qconf +xconfig: $(obj)/qconf set_locale $< $(Kconfig) -gconfig: $(obj)/gconf +gconfig: $(obj)/gconf set_locale $< $(Kconfig) -menuconfig: $(obj)/mconf +menuconfig: $(obj)/mconf set_locale $< $(Kconfig) -config: $(obj)/conf +config: $(obj)/conf set_locale $< $(Kconfig) oldconfig: $(obj)/conf @@ -24,22 +24,35 @@ oldconfig: $(obj)/conf silentoldconfig: $(obj)/conf $< -s $(Kconfig) -# Create new linux.po file +# Set custom source space locale environment +set_locale: + $(Q)sh $(obj)/set_locale.sh + +# Create new linux.pot file # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files -# The symlink is used to repair a deficiency in arch/um -update-po-config: $(obj)/kxgettext - xgettext --default-domain=linux \ +# The symlinks are used to repair a deficiency in arch/um and arch/cris +update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h + $(Q)echo " GEN config" + $(Q)xgettext --default-domain=linux \ --add-comments --keyword=_ --keyword=N_ \ --from-code=UTF-8 \ --files-from=scripts/kconfig/POTFILES.in \ --output $(obj)/config.pot $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch - (for i in `ls arch/`; \ - do \ - $(obj)/kxgettext arch/$$i/Kconfig; \ - done ) >> $(obj)/config.pot - msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ + $(Q)ln -fs arch-v10 arch/cris/arch + $(Q)(for i in `ls arch/`; \ + do \ + echo " GEN $$i"; \ + $(obj)/kxgettext arch/$$i/Kconfig \ + >> $(obj)/config.pot; \ + done ) + $(Q)rm -f arch/cris/arch + $(Q)ln -fs arch-v32 arch/cris/arch + $(Q)echo " GEN cris(v32)" + $(Q)$(obj)/kxgettext arch/cris/Kconfig >> $(obj)/config.pot + $(Q)rm -f arch/um/Kconfig.arch + $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ --output $(obj)/linux.pot $(Q)rm -f arch/um/Kconfig.arch $(Q)rm -f $(obj)/config.pot @@ -142,8 +155,9 @@ gconf-objs := gconf.o kconfig_load.o zco endif clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ - .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c + .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h clean-files += mconf qconf gconf +clean-files += config.pot linux.pot # Add environment specific flags HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) @@ -248,6 +262,9 @@ $(obj)/%.moc: $(src)/%.h $(obj)/lkc_defs.h: $(src)/lkc_proto.h sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' +# Extract gconf menu items for I18N support +$(obj)/gconf.glade.h: $(obj)/gconf.glade + intltool-extract --type=gettext/glade $(obj)/gconf.glade ### # The following requires flex/bison/gperf @@ -274,3 +291,4 @@ lex.%.c: %.l cp $@ $@_shipped endif + diff -rupN linux-2.6.24/scripts/kconfig/mconf.c linux-2.6.24-i18n/scripts/kconfig/mconf.c --- linux-2.6.24/scripts/kconfig/mconf.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/mconf.c 2008-01-25 13:19:28.000000000 +0100 @@ -330,11 +330,11 @@ static void get_prompt_str(struct gstr * int i, j; struct menu *submenu[8], *menu; - str_printf(r, "Prompt: %s\n", prop->text); - str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, + str_printf(r, _("Prompt: %s\n"), _(prop->text)); + str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, prop->menu->lineno); if (!expr_is_yes(prop->visible.expr)) { - str_append(r, " Depends on: "); + str_append(r, _(" Depends on: ")); expr_gstr_print(prop->visible.expr, r); str_append(r, "\n"); } @@ -342,13 +342,13 @@ static void get_prompt_str(struct gstr * for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) submenu[i++] = menu; if (i > 0) { - str_printf(r, " Location:\n"); + str_printf(r, _(" Location:\n")); for (j = 4; --i >= 0; j += 2) { menu = submenu[i]; - str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); + str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu))); if (menu->sym) { str_printf(r, " (%s [=%s])", menu->sym->name ? - menu->sym->name : "", + menu->sym->name : _(""), sym_get_string_value(menu->sym)); } str_append(r, "\n"); @@ -378,7 +378,7 @@ static void get_symbol_str(struct gstr * if (hit) str_append(r, "\n"); if (sym->rev_dep.expr) { - str_append(r, " Selected by: "); + str_append(r, _(" Selected by: ")); expr_gstr_print(sym->rev_dep.expr, r); str_append(r, "\n"); } @@ -394,7 +394,7 @@ static struct gstr get_relations_str(str for (i = 0; sym_arr && (sym = sym_arr[i]); i++) get_symbol_str(&res, sym); if (!i) - str_append(&res, "No matches found.\n"); + str_append(&res, _("No matches found.\n")); return res; } @@ -474,6 +474,7 @@ static void build_conf(struct menu *menu switch (prop->type) { case P_MENU: child_count++; + prompt = _(prompt); if (single_menu_mode) { item_make("%s%*c%s", menu->data ? "-->" : "++>", @@ -489,7 +490,7 @@ static void build_conf(struct menu *menu case P_COMMENT: if (prompt) { child_count++; - item_make(" %*c*** %s ***", indent + 1, ' ', prompt); + item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt)); item_set_tag(':'); item_set_data(menu); } @@ -497,7 +498,7 @@ static void build_conf(struct menu *menu default: if (prompt) { child_count++; - item_make("---%*c%s", indent + 1, ' ', prompt); + item_make("---%*c%s", indent + 1, ' ', _(prompt)); item_set_tag(':'); item_set_data(menu); } @@ -541,10 +542,10 @@ static void build_conf(struct menu *menu item_set_data(menu); } - item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); if (val == yes) { if (def_menu) { - item_add_str(" (%s)", menu_get_prompt(def_menu)); + item_add_str(" (%s)", _(menu_get_prompt(def_menu))); item_add_str(" --->"); if (def_menu->list) { indent += 2; @@ -556,7 +557,7 @@ static void build_conf(struct menu *menu } } else { if (menu == current_menu) { - item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); item_set_tag(':'); item_set_data(menu); goto conf_childs; @@ -599,17 +600,17 @@ static void build_conf(struct menu *menu tmp = indent - tmp + 4; if (tmp < 0) tmp = 0; - item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu), + item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)), (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); + "" : _(" (NEW)")); item_set_tag('s'); item_set_data(menu); goto conf_childs; } } - item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), + item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)), (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); + "" : _(" (NEW)")); if (menu->prompt->type == P_MENU) { item_add_str(" --->"); return; @@ -647,7 +648,7 @@ static void conf(struct menu *menu) item_set_tag('S'); } dialog_clear(); - res = dialog_menu(prompt ? prompt : _("Main Menu"), + res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), _(menu_instructions), active_menu, &s_scroll); if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) @@ -694,7 +695,7 @@ static void conf(struct menu *menu) if (sym) show_help(submenu); else - show_helptext("README", _(mconf_readme)); + show_helptext(_("README"), _(mconf_readme)); break; case 3: if (item_is_tag('t')) { @@ -752,13 +753,13 @@ static void show_help(struct menu *menu) str_append(&help, nohelp_text); } get_symbol_str(&help, sym); - show_helptext(menu_get_prompt(menu), str_get(&help)); + show_helptext(_(menu_get_prompt(menu)), str_get(&help)); str_free(&help); } static void conf_choice(struct menu *menu) { - const char *prompt = menu_get_prompt(menu); + const char *prompt = _(menu_get_prompt(menu)); struct menu *child; struct symbol *active; @@ -772,7 +773,7 @@ static void conf_choice(struct menu *men for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; - item_make("%s", menu_get_prompt(child)); + item_make("%s", _(menu_get_prompt(child))); item_set_data(child); if (child->sym == active) item_set_selected(1); @@ -780,7 +781,7 @@ static void conf_choice(struct menu *men item_set_tag('X'); } dialog_clear(); - res = dialog_checklist(prompt ? prompt : _("Main Menu"), + res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), _(radiolist_instructions), 15, 70, 6); selected = item_activate_selected(); @@ -826,10 +827,10 @@ static void conf_string(struct menu *men heading = _(inputbox_instructions_string); break; default: - heading = "Internal mconf error!"; + heading = _("Internal mconf error!"); } dialog_clear(); - res = dialog_inputbox(prompt ? prompt : _("Main Menu"), + res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"), heading, 10, 75, sym_get_string_value(menu->sym)); switch (res) { diff -rupN linux-2.6.24/scripts/kconfig/menu.c linux-2.6.24-i18n/scripts/kconfig/menu.c --- linux-2.6.24/scripts/kconfig/menu.c 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/menu.c 2008-01-25 13:19:28.000000000 +0100 @@ -394,9 +394,9 @@ bool menu_is_visible(struct menu *menu) const char *menu_get_prompt(struct menu *menu) { if (menu->prompt) - return _(menu->prompt->text); + return menu->prompt->text; else if (menu->sym) - return _(menu->sym->name); + return menu->sym->name; return NULL; } diff -rupN linux-2.6.24/scripts/kconfig/POTFILES.in linux-2.6.24-i18n/scripts/kconfig/POTFILES.in --- linux-2.6.24/scripts/kconfig/POTFILES.in 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/POTFILES.in 2008-01-25 13:19:28.000000000 +0100 @@ -1,5 +1,12 @@ +scripts/kconfig/lxdialog/checklist.c +scripts/kconfig/lxdialog/inputbox.c +scripts/kconfig/lxdialog/menubox.c +scripts/kconfig/lxdialog/textbox.c +scripts/kconfig/lxdialog/util.c +scripts/kconfig/lxdialog/yesno.c scripts/kconfig/mconf.c scripts/kconfig/conf.c scripts/kconfig/confdata.c scripts/kconfig/gconf.c +scripts/kconfig/gconf.glade.h scripts/kconfig/qconf.cc diff -rupN linux-2.6.24/scripts/kconfig/qconf.cc linux-2.6.24-i18n/scripts/kconfig/qconf.cc --- linux-2.6.24/scripts/kconfig/qconf.cc 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/qconf.cc 2008-01-25 13:19:28.000000000 +0100 @@ -114,7 +114,7 @@ void ConfigItem::updateMenu(void) sym = menu->sym; prop = menu->prompt; - prompt = QString::fromLocal8Bit(menu_get_prompt(menu)); + prompt = _(menu_get_prompt(menu)); if (prop) switch (prop->type) { case P_MENU: @@ -208,7 +208,7 @@ void ConfigItem::updateMenu(void) break; } if (!sym_has_value(sym) && visible) - prompt += " (NEW)"; + prompt += _(" (NEW)"); set_prompt: setText(promptColIdx, prompt); } @@ -346,7 +346,7 @@ ConfigList::ConfigList(ConfigView* p, co for (i = 0; i < colNr; i++) colMap[i] = colRevMap[i] = -1; - addColumn(promptColIdx, "Option"); + addColumn(promptColIdx, _("Option")); reinit(); } @@ -360,14 +360,14 @@ void ConfigList::reinit(void) removeColumn(nameColIdx); if (showName) - addColumn(nameColIdx, "Name"); + addColumn(nameColIdx, _("Name")); if (showRange) { addColumn(noColIdx, "N"); addColumn(modColIdx, "M"); addColumn(yesColIdx, "Y"); } if (showData) - addColumn(dataColIdx, "Value"); + addColumn(dataColIdx, _("Value")); updateListAll(); } @@ -803,7 +803,7 @@ void ConfigList::contextMenuEvent(QConte QAction *action; headerPopup = new QPopupMenu(this); - action = new QAction(NULL, "Show Name", 0, this); + action = new QAction(NULL, _("Show Name"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowName(bool))); @@ -811,7 +811,7 @@ void ConfigList::contextMenuEvent(QConte action, SLOT(setOn(bool))); action->setOn(showName); action->addTo(headerPopup); - action = new QAction(NULL, "Show Range", 0, this); + action = new QAction(NULL, _("Show Range"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowRange(bool))); @@ -819,7 +819,7 @@ void ConfigList::contextMenuEvent(QConte action, SLOT(setOn(bool))); action->setOn(showRange); action->addTo(headerPopup); - action = new QAction(NULL, "Show Data", 0, this); + action = new QAction(NULL, _("Show Data"), 0, this); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowData(bool))); @@ -1041,7 +1041,12 @@ void ConfigInfoView::menuInfo(void) if (showDebug()) debug = debug_info(sym); - help = print_filter(_(menu_get_help(menu))); + help = menu_get_help(menu); + /* Gettextize if the help text not empty */ + if (help.isEmpty()) + help = print_filter(menu_get_help(menu)); + else + help = print_filter(_(menu_get_help(menu))); } else if (menu->prompt) { head += ""; head += print_filter(_(menu->prompt->text)); @@ -1167,7 +1172,7 @@ void ConfigInfoView::expr_print_help(voi QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) { QPopupMenu* popup = Parent::createPopupMenu(pos); - QAction* action = new QAction(NULL,"Show Debug Info", 0, popup); + QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup); action->setToggleAction(TRUE); connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); @@ -1189,11 +1194,11 @@ ConfigSearchWindow::ConfigSearchWindow(C QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6); QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6); - layout2->addWidget(new QLabel("Find:", this)); + layout2->addWidget(new QLabel(_("Find:"), this)); editField = new QLineEdit(this); connect(editField, SIGNAL(returnPressed()), SLOT(search())); layout2->addWidget(editField); - searchButton = new QPushButton("Search", this); + searchButton = new QPushButton(_("Search"), this); searchButton->setAutoDefault(FALSE); connect(searchButton, SIGNAL(clicked()), SLOT(search())); layout2->addWidget(searchButton); @@ -1313,58 +1318,58 @@ ConfigMainWindow::ConfigMainWindow(void) menu = menuBar(); toolBar = new QToolBar("Tools", this); - backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); + backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this); connect(backAction, SIGNAL(activated()), SLOT(goBack())); backAction->setEnabled(FALSE); - QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); + QAction *quitAction = new QAction("Quit", _("&Quit"), CTRL+Key_Q, this); connect(quitAction, SIGNAL(activated()), SLOT(close())); - QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); + QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), CTRL+Key_L, this); connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); - saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); + saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), CTRL+Key_S, this); connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); conf_set_changed_callback(conf_changed); // Set saveAction's initial state conf_changed(); - QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); + QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this); connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); - QAction *searchAction = new QAction("Find", "&Find", CTRL+Key_F, this); + QAction *searchAction = new QAction("Find", _("&Find"), CTRL+Key_F, this); connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); - QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); + QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this); connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); - QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); + QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this); connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); - QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); + QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this); connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); - QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); + QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this); showNameAction->setToggleAction(TRUE); connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); showNameAction->setOn(configView->showName()); - QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); + QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this); showRangeAction->setToggleAction(TRUE); connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); showRangeAction->setOn(configList->showRange); - QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); + QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this); showDataAction->setToggleAction(TRUE); connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); showDataAction->setOn(configList->showData); - QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); + QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this); showAllAction->setToggleAction(TRUE); connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool))); connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool))); showAllAction->setOn(configList->showAll); - QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); + QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); showDebugAction->setToggleAction(TRUE); connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); showDebugAction->setOn(helpText->showDebug()); - QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); + QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this); connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); - QAction *showAboutAction = new QAction(NULL, "About", 0, this); + QAction *showAboutAction = new QAction(NULL, _("About"), 0, this); connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); // init tool bar @@ -1379,7 +1384,7 @@ ConfigMainWindow::ConfigMainWindow(void) // create config menu QPopupMenu* config = new QPopupMenu(this); - menu->insertItem("&File", config); + menu->insertItem(_("&File"), config); loadAction->addTo(config); saveAction->addTo(config); saveAsAction->addTo(config); @@ -1388,12 +1393,12 @@ ConfigMainWindow::ConfigMainWindow(void) // create edit menu QPopupMenu* editMenu = new QPopupMenu(this); - menu->insertItem("&Edit", editMenu); + menu->insertItem(_("&Edit"), editMenu); searchAction->addTo(editMenu); // create options menu QPopupMenu* optionMenu = new QPopupMenu(this); - menu->insertItem("&Option", optionMenu); + menu->insertItem(_("&Option"), optionMenu); showNameAction->addTo(optionMenu); showRangeAction->addTo(optionMenu); showDataAction->addTo(optionMenu); @@ -1404,7 +1409,7 @@ ConfigMainWindow::ConfigMainWindow(void) // create help menu QPopupMenu* helpMenu = new QPopupMenu(this); menu->insertSeparator(); - menu->insertItem("&Help", helpMenu); + menu->insertItem(_("&Help"), helpMenu); showIntroAction->addTo(helpMenu); showAboutAction->addTo(helpMenu); @@ -1452,14 +1457,14 @@ void ConfigMainWindow::loadConfig(void) if (s.isNull()) return; if (conf_read(QFile::encodeName(s))) - QMessageBox::information(this, "qconf", "Unable to load configuration!"); + QMessageBox::information(this, "qconf", _("Unable to load configuration!")); ConfigView::updateListAll(); } void ConfigMainWindow::saveConfig(void) { if (conf_write(NULL)) - QMessageBox::information(this, "qconf", "Unable to save configuration!"); + QMessageBox::information(this, "qconf", _("Unable to save configuration!")); } void ConfigMainWindow::saveConfigAs(void) @@ -1468,7 +1473,7 @@ void ConfigMainWindow::saveConfigAs(void if (s.isNull()) return; if (conf_write(QFile::encodeName(s))) - QMessageBox::information(this, "qconf", "Unable to save configuration!"); + QMessageBox::information(this, "qconf", _("Unable to save configuration!")); } void ConfigMainWindow::searchConfig(void) @@ -1612,11 +1617,11 @@ void ConfigMainWindow::closeEvent(QClose e->accept(); return; } - QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, + QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); - mb.setButtonText(QMessageBox::Yes, "&Save Changes"); - mb.setButtonText(QMessageBox::No, "&Discard Changes"); - mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); + mb.setButtonText(QMessageBox::Yes, _("&Save Changes")); + mb.setButtonText(QMessageBox::No, _("&Discard Changes")); + mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); switch (mb.exec()) { case QMessageBox::Yes: conf_write(NULL); @@ -1631,7 +1636,7 @@ void ConfigMainWindow::closeEvent(QClose void ConfigMainWindow::showIntro(void) { - static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" + static const QString str = _("Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" "For each option, a blank box indicates the feature is disabled, a check\n" "indicates it is enabled, and a dot indicates that it is to be compiled\n" "as a module. Clicking on the box will cycle through the three states.\n\n" @@ -1641,15 +1646,15 @@ void ConfigMainWindow::showIntro(void) "options must be enabled to support the option you are interested in, you can\n" "still view the help of a grayed-out option.\n\n" "Toggling Show Debug Info under the Options menu will show the dependencies,\n" - "which you can then match by examining other options.\n\n"; + "which you can then match by examining other options.\n\n"); QMessageBox::information(this, "qconf", str); } void ConfigMainWindow::showAbout(void) { - static char str[] = "qconf is Copyright (C) 2002 Roman Zippel .\n\n" - "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; + static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel .\n\n" + "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"); QMessageBox::information(this, "qconf", str); } @@ -1707,7 +1712,7 @@ static const char *progname; static void usage(void) { - printf("%s \n", progname); + printf(_("%s \n"), progname); exit(0); } diff -rupN linux-2.6.24/scripts/kconfig/set_locale.sh linux-2.6.24-i18n/scripts/kconfig/set_locale.sh --- linux-2.6.24/scripts/kconfig/set_locale.sh 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/set_locale.sh 2008-01-25 13:19:28.000000000 +0100 @@ -0,0 +1,95 @@ +#!/bin/sh + +# +# This script detects language and compiles the language binary files +# + +PODIR=scripts/kconfig/po/ + +# Check the $PODIR directory +if [ ! -d $PODIR ] +then + exit 0 +fi + +# Set language code +if test "x$LANG" == "x" +then + if test "x$LC_ALL" == "x" + then + exit 0 + else + MYLC=$LC_ALL + fi +else + MYLC=$LANG +fi + +# If don't need the translation +if test "x$MYLC" == "xC" +then + exit 0 +fi + +MYLCTEST=$(echo $MYLC|cut -b 1-5) + +# Find Kconfig's .po +POFILES=$(find $PODIR -maxdepth 1 -type f -name ${MYLCTEST}.po) +if test "x$POFILES" != "x" +then + MYLC=$MYLCTEST +else + MYLCTEST=$(echo $MYLC|cut -b 1-2) + POFILES=$(find $PODIR -maxdepth 1 -type f -name ${MYLCTEST}.po) + if test "x$POFILES" != "x" + then + MYLC=$MYLCTEST + else + #echo "Your language ($MYLC) is not supported." + exit 0 + fi +fi + +if [ -f .locale/$MYLC/LC_MESSAGES/linux.mo ] +then + exit 0 +fi + +echo -n " LOCALE ($MYLC)... " + +# Find additional .po files +# This is a hook for external patches +for i in $(find $PODIR -maxdepth 1 -type d -path '*-po') +do + if [ -f $i/$MYLC.po ] + then + POFILES="$POFILES $i/$MYLC.po" + NEED_CAT=1 + fi +done + +# Trying msgfmt... and no returning error if it doesn't exist +msgfmt -V &>/dev/null || { + echo "msgfmt doesn't exist, please install gettext"; + # Exit with only warning message + exit 0; +} + +# Do translation... +mkdir -p .locale/$MYLC/LC_MESSAGES/ +if test "x$NEED_CAT" == "x1" +then + # Trying msgcat and no returning error if it doesn't exist + msgcat -V &>/dev/null || { + echo "msgcat doesn't exist, please install gettext 0.12 or newer"; + # Exit with only warning message + exit 0; + } + msgcat --use-first $POFILES | msgfmt --output=.locale/$MYLC/LC_MESSAGES/linux.mo - +else + msgfmt $POFILES --output=.locale/$MYLC/LC_MESSAGES/linux.mo +fi + +# Done +echo " done" + diff -rupN linux-2.6.24/scripts/kconfig/zconf.l linux-2.6.24-i18n/scripts/kconfig/zconf.l --- linux-2.6.24/scripts/kconfig/zconf.l 2008-01-24 23:58:37.000000000 +0100 +++ linux-2.6.24-i18n/scripts/kconfig/zconf.l 2008-01-25 13:19:28.000000000 +0100 @@ -217,6 +217,11 @@ n [A-Za-z0-9_] append_string("\n", 1); } [^ \t\n].* { + while (yyleng) { + if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t')) + break; + yyleng--; + } append_string(yytext, yyleng); if (!first_ts) first_ts = last_ts;