Skip to contentSkip to conversation

Kconfig i18n support

PATCH New Arnaldo Carvalho de Melo 1 participant 1 message Mar 27, 2005 Kconfig

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Kconfig i18n support

Hi,

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 Fabrício 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 wether to ship the translations with the
stock kernel sources to be discussed here, please share your suggestions.

Available at:

bk://kernel.bkbits.net/acme/Kconfig-i18n-2.6

Linus/Andrew, please consider applying.

- Arnaldo

===================================================================

[email protected], 2005-03-26 23:21:36-03:00, [email protected]
[KCONFIG] i18n support

For the menu entries and help texts. A new tool, kxgettext, is now used with the make update-po-config to extract the text entries and help texts into scripts/kconfig/linux.pot, that should be used as as the starting point for translations.

 Makefile    |   14 ++-
 POTFILES.in |    5 +
 conf.c      |   20 ++---
 confdata.c  |   16 ++--
 gconf.c     |   52 +++++++-------
 kxgettext.c |  221 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lkc.h       |    8 ++
 mconf.c     |  120 +++++++++++++++++---------------
 menu.c      |    4 -
 qconf.cc    |   59 ++++++++++------
 10 files changed, 395 insertions(+), 124 deletions(-)
scripts/kconfig/Makefile +11 -3
diff -Nru a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
@@ -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
@@ -23,6 +23,13 @@
 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
@@ -72,9 +79,10 @@
 #         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
@@ -107,7 +115,7 @@
 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
scripts/kconfig/POTFILES.in new file +5 -0
diff -Nru a/scripts/kconfig/POTFILES.in b/scripts/kconfig/POTFILES.in
@@ -0,0 +1,5 @@
+scripts/kconfig/mconf.c
+scripts/kconfig/conf.c
+scripts/kconfig/confdata.c
+scripts/kconfig/gconf.c
+scripts/kconfig/qconf.cc
scripts/kconfig/conf.c +10 -10
diff -Nru a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
@@ -34,7 +34,7 @@
 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)
 {
@@ -56,9 +56,9 @@
 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);
 	}
 }
@@ -470,7 +470,7 @@
 	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);
 		}
@@ -504,7 +504,7 @@
 			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);
 			}
@@ -530,7 +530,7 @@
 	}
   	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);
@@ -547,12 +547,12 @@
 		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:
@@ -576,7 +576,7 @@
 		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;
scripts/kconfig/confdata.c +8 -8
diff -Nru a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
@@ -88,9 +88,9 @@
 			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;
 			}
 		}
@@ -312,11 +312,11 @@
 	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) : "");
scripts/kconfig/gconf.c +28 -24

178 lines not on this page · raw message

scripts/kconfig/kxgettext.c new file +221 -0

221 lines not on this page · raw message

scripts/kconfig/lkc.h +8 -0
diff -Nru a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
@@ -8,6 +8,8 @@
 
 #include "expr.h"
 
+#include <libintl.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -22,6 +24,12 @@
 #undef P
 
 #define SRCTREE "srctree"
+
+#define PACKAGE "linux"
+#define LOCALEDIR "/usr/share/locale"
+
+#define _(text) gettext(text)
+#define N_(text) (text)
 
 int zconfparse(void);
 void zconfdump(FILE *out);
scripts/kconfig/mconf.c +63 -57

296 lines not on this page · raw message

scripts/kconfig/menu.c +2 -2
diff -Nru a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
@@ -365,9 +365,9 @@
 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;
 }
 
scripts/kconfig/qconf.cc +39 -20

168 lines not on this page · raw message