Skip to content

Commit

Permalink
[PATCH] Kconfig i18n support
Browse files Browse the repository at this point in the history
This patch adds i18n support for make *config, allowing users to have the
config process in their own language.

No printk was harmed in the process, don't worry, so all the bug reports,
kernel messages, etc, remain in english, just the user tools to configure
the kernel are internationalized.

Users not interested in translations can just unset the related LANG,
LC_ALL, etc env variables and have the config process in plain english,
something like:

LANG= make menuconfig

is enough for having the whole config process in english. Or just don't
install any translation file.

Translations for brazilian portuguese are being done by a team of
volunteers at:

http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes

To start the translation process:

  make update-po-config

  This will generate the pot template named scripts/kconfig/linux.pot,
  copy it to, say, ~/es.po, to start the translation for spanish.

To test your translation, as root issue this command:

  msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po

  Replace "es" with your language code.

  Then execute, for instance:

  make menuconfig

The current patch doesn't use any optimization to reduce the size of the
generated .mo file, it is possible to use the config option as a key, but
this doesn't prevent the current patch from being used or the translations
done under the current scheme to be in any way lost if we chose to do any
kind of keying.

Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese)
translation effort, Thiago Maciera for helping me with the gconf.cc (QT
frontent) i18n coding and to all the volunteers that are already working on
the first translation, to pt_BR.

I left the question on whether to ship the translations with the stock kernel
sources to be discussed here, please share your suggestions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org
Signed-off-by: Andrew Morton <akpm@osdl.org>
  • Loading branch information
Arnaldo Carvalho de Melo authored and Linus Torvalds committed May 5, 2005
1 parent f403b7f commit 3b9fa09
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 124 deletions.
14 changes: 11 additions & 3 deletions scripts/kconfig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Kernel configuration targets
# These targets are used from top-level makefile

.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig
.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config

xconfig: $(obj)/qconf
$< arch/$(ARCH)/Kconfig
Expand All @@ -23,6 +23,13 @@ oldconfig: $(obj)/conf
silentoldconfig: $(obj)/conf
$< -s arch/$(ARCH)/Kconfig

update-po-config: $(obj)/kxgettext
xgettext --default-domain=linux \
--add-comments --keyword=_ --keyword=N_ \
--files-from=scripts/kconfig/POTFILES.in \
-o scripts/kconfig/linux.pot
scripts/kconfig/kxgettext arch/$(ARCH)/Kconfig >> scripts/kconfig/linux.pot

.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig

randconfig: $(obj)/conf
Expand Down Expand Up @@ -72,9 +79,10 @@ help:
# Based on GTK which needs to be installed to compile it
# object files used by all kconfig flavours

hostprogs-y := conf mconf qconf gconf
hostprogs-y := conf mconf qconf gconf kxgettext
conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o
kxgettext-objs := kxgettext.o zconf.tab.o

ifeq ($(MAKECMDGOALS),xconfig)
qconf-target := 1
Expand Down Expand Up @@ -107,7 +115,7 @@ HOSTLOADLIBES_gconf = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --libs`
HOSTCFLAGS_gconf.o = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` \
-D LKC_DIRECT_LINK

$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o: $(obj)/zconf.tab.h
$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o $(obj)/kxgettext: $(obj)/zconf.tab.h

$(obj)/zconf.tab.h: $(src)/zconf.tab.h_shipped
$(obj)/zconf.tab.c: $(src)/zconf.tab.c_shipped
Expand Down
5 changes: 5 additions & 0 deletions scripts/kconfig/POTFILES.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scripts/kconfig/mconf.c
scripts/kconfig/conf.c
scripts/kconfig/confdata.c
scripts/kconfig/gconf.c
scripts/kconfig/qconf.cc
20 changes: 10 additions & 10 deletions scripts/kconfig/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int conf_cnt;
static signed char line[128];
static struct menu *rootEntry;

static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");

static void strip(signed char *str)
{
Expand All @@ -56,9 +56,9 @@ static void strip(signed char *str)
static void check_stdin(void)
{
if (!valid_stdin && input_mode == ask_silent) {
printf("aborted!\n\n");
printf("Console input/output is redirected. ");
printf("Run 'make oldconfig' to update configuration.\n\n");
printf(_("aborted!\n\n"));
printf(_("Console input/output is redirected. "));
printf(_("Run 'make oldconfig' to update configuration.\n\n"));
exit(1);
}
}
Expand Down Expand Up @@ -470,7 +470,7 @@ static void check_conf(struct menu *menu)
if (sym) {
if (sym_is_changable(sym) && !sym_has_value(sym)) {
if (!conf_cnt++)
printf("*\n* Restart config...\n*\n");
printf(_("*\n* Restart config...\n*\n"));
rootEntry = menu_get_parent_menu(menu);
conf(rootEntry);
}
Expand Down Expand Up @@ -504,7 +504,7 @@ int main(int ac, char **av)
input_mode = set_default;
defconfig_file = av[i++];
if (!defconfig_file) {
printf("%s: No default config file specified\n",
printf(_("%s: No default config file specified\n"),
av[0]);
exit(1);
}
Expand All @@ -530,7 +530,7 @@ int main(int ac, char **av)
}
name = av[i];
if (!name) {
printf("%s: Kconfig file missing\n", av[0]);
printf(_("%s: Kconfig file missing\n"), av[0]);
}
conf_parse(name);
//zconfdump(stdout);
Expand All @@ -547,12 +547,12 @@ int main(int ac, char **av)
break;
case ask_silent:
if (stat(".config", &tmpstat)) {
printf("***\n"
printf(_("***\n"
"*** You have not yet configured your kernel!\n"
"***\n"
"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
"*** \"make menuconfig\" or \"make xconfig\").\n"
"***\n");
"***\n"));
exit(1);
}
case ask_all:
Expand All @@ -576,7 +576,7 @@ int main(int ac, char **av)
check_conf(&rootmenu);
} while (conf_cnt);
if (conf_write(NULL)) {
fprintf(stderr, "\n*** Error during writing of the kernel configuration.\n\n");
fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
return 1;
}
return 0;
Expand Down
16 changes: 8 additions & 8 deletions scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ int conf_read(const char *name)
name = conf_expand_value(name);
in = zconf_fopen(name);
if (in) {
printf("#\n"
"# using defaults found in %s\n"
"#\n", name);
printf(_("#\n"
"# using defaults found in %s\n"
"#\n"), name);
break;
}
}
Expand Down Expand Up @@ -312,11 +312,11 @@ int conf_write(const char *name)
if (env && *env)
use_timestamp = 0;

fprintf(out, "#\n"
"# Automatically generated make config: don't edit\n"
"# Linux kernel version: %s\n"
"%s%s"
"#\n",
fprintf(out, _("#\n"
"# Automatically generated make config: don't edit\n"
"# Linux kernel version: %s\n"
"%s%s"
"#\n"),
sym_get_string_value(sym),
use_timestamp ? "# " : "",
use_timestamp ? ctime(&now) : "");
Expand Down
52 changes: 28 additions & 24 deletions scripts/kconfig/gconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static gboolean resizeable = FALSE;
static gboolean config_changed = FALSE;

static char nohelp_text[] =
"Sorry, no help available for this option yet.\n";
N_("Sorry, no help available for this option yet.\n");

GtkWidget *main_wnd = NULL;
GtkWidget *tree1_w = NULL; // left frame
Expand Down Expand Up @@ -193,7 +193,7 @@ void init_main_window(const gchar * glade_file)

xml = glade_xml_new(glade_file, "window1", NULL);
if (!xml)
g_error("GUI loading failed !\n");
g_error(_("GUI loading failed !\n"));
glade_xml_signal_autoconnect(xml);

main_wnd = glade_xml_get_widget(xml, "window1");
Expand Down Expand Up @@ -275,7 +275,7 @@ void init_main_window(const gchar * glade_file)
/*"style", PANGO_STYLE_OBLIQUE, */
NULL);

sprintf(title, "Linux Kernel v%s Configuration",
sprintf(title, _("Linux Kernel v%s Configuration"),
getenv("KERNELRELEASE"));
gtk_window_set_title(GTK_WINDOW(main_wnd), title);

Expand Down Expand Up @@ -325,7 +325,7 @@ void init_left_tree(void)

column = gtk_tree_view_column_new();
gtk_tree_view_append_column(view, column);
gtk_tree_view_column_set_title(column, "Options");
gtk_tree_view_column_set_title(column, _("Options"));

renderer = gtk_cell_renderer_toggle_new();
gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
Expand Down Expand Up @@ -370,7 +370,7 @@ void init_right_tree(void)

column = gtk_tree_view_column_new();
gtk_tree_view_append_column(view, column);
gtk_tree_view_column_set_title(column, "Options");
gtk_tree_view_column_set_title(column, _("Options"));

renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
Expand Down Expand Up @@ -401,7 +401,7 @@ void init_right_tree(void)

renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(view, -1,
"Name", renderer,
_("Name"), renderer,
"text", COL_NAME,
"foreground-gdk",
COL_COLOR, NULL);
Expand All @@ -425,7 +425,7 @@ void init_right_tree(void)
COL_COLOR, NULL);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(view, -1,
"Value", renderer,
_("Value"), renderer,
"text", COL_VALUE,
"editable",
COL_EDIT,
Expand Down Expand Up @@ -466,15 +466,15 @@ static void text_insert_help(struct menu *menu)
GtkTextIter start, end;
const char *prompt = menu_get_prompt(menu);
gchar *name;
const char *help = nohelp_text;
const char *help = _(nohelp_text);

if (!menu->sym)
help = "";
else if (menu->sym->help)
help = menu->sym->help;
help = _(menu->sym->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("");

Expand Down Expand Up @@ -530,7 +530,7 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
if (config_changed == FALSE)
return FALSE;

dialog = gtk_dialog_new_with_buttons("Warning !",
dialog = gtk_dialog_new_with_buttons(_("Warning !"),
GTK_WINDOW(main_wnd),
(GtkDialogFlags)
(GTK_DIALOG_MODAL |
Expand All @@ -544,7 +544,7 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
gtk_dialog_set_default_response(GTK_DIALOG(dialog),
GTK_RESPONSE_CANCEL);

label = gtk_label_new("\nSave configuration ?\n");
label = gtk_label_new(_("\nSave configuration ?\n"));
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
gtk_widget_show(label);

Expand Down Expand Up @@ -604,7 +604,7 @@ load_filename(GtkFileSelection * file_selector, gpointer user_data)
(user_data));

if (conf_read(fn))
text_insert_msg("Error", "Unable to load configuration !");
text_insert_msg(_("Error"), _("Unable to load configuration !"));
else
display_tree(&rootmenu);
}
Expand All @@ -613,7 +613,7 @@ void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkWidget *fs;

fs = gtk_file_selection_new("Load file...");
fs = gtk_file_selection_new(_("Load file..."));
g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
"clicked",
G_CALLBACK(load_filename), (gpointer) fs);
Expand All @@ -632,7 +632,7 @@ void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
if (conf_write(NULL))
text_insert_msg("Error", "Unable to save configuration !");
text_insert_msg(_("Error"), _("Unable to save configuration !"));

config_changed = FALSE;
}
Expand All @@ -647,7 +647,7 @@ store_filename(GtkFileSelection * file_selector, gpointer user_data)
(user_data));

if (conf_write(fn))
text_insert_msg("Error", "Unable to save configuration !");
text_insert_msg(_("Error"), _("Unable to save configuration !"));

gtk_widget_destroy(GTK_WIDGET(user_data));
}
Expand All @@ -656,7 +656,7 @@ void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkWidget *fs;

fs = gtk_file_selection_new("Save file as...");
fs = gtk_file_selection_new(_("Save file as..."));
g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
"clicked",
G_CALLBACK(store_filename), (gpointer) fs);
Expand Down Expand Up @@ -740,7 +740,7 @@ on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data)
void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkWidget *dialog;
const gchar *intro_text =
const gchar *intro_text = _(
"Welcome to gkc, the GTK+ graphical kernel configuration tool\n"
"for Linux.\n"
"For each option, a blank box indicates the feature is disabled, a\n"
Expand All @@ -756,7 +756,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
"option.\n"
"\n"
"Toggling Show Debug Info under the Options menu will show \n"
"the dependencies, which you can then match by examining other options.";
"the dependencies, which you can then match by examining other options.");

dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
Expand All @@ -773,8 +773,8 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkWidget *dialog;
const gchar *about_text =
"gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
"Based on the source code from Roman Zippel.\n";
_("gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
"Based on the source code from Roman Zippel.\n");

dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
Expand All @@ -791,9 +791,9 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkWidget *dialog;
const gchar *license_text =
"gkc is released under the terms of the GNU GPL v2.\n"
"For more information, please see the source code or\n"
"visit http://www.fsf.org/licenses/licenses.html\n";
_("gkc is released under the terms of the GNU GPL v2.\n"
"For more information, please see the source code or\n"
"visit http://www.fsf.org/licenses/licenses.html\n");

dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
Expand Down Expand Up @@ -1579,6 +1579,10 @@ int main(int ac, char *av[])
kconfig_load();
#endif

bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);

/* GTK stuffs */
gtk_set_locale();
gtk_init(&ac, &av);
Expand Down
Loading

0 comments on commit 3b9fa09

Please sign in to comment.