From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RvzM7-0007UH-H1 for mharc-grub-devel@gnu.org; Fri, 10 Feb 2012 17:54:15 -0500 Received: from eggs.gnu.org ([140.186.70.92]:55694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvzM5-0007UB-Np for grub-devel@gnu.org; Fri, 10 Feb 2012 17:54:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvzM4-00061B-7T for grub-devel@gnu.org; Fri, 10 Feb 2012 17:54:13 -0500 Received: from mail-we0-f169.google.com ([74.125.82.169]:39116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvzM3-000617-U8 for grub-devel@gnu.org; Fri, 10 Feb 2012 17:54:12 -0500 Received: by wera13 with SMTP id a13so2909741wer.0 for ; Fri, 10 Feb 2012 14:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; bh=J/t9bgZ4nQfZ8x8seBWWSQGHrcPDJjS445Nx/2v8l+o=; b=t5GDgzGmCm2seMUSfaIYggQPoHhm4hF/fcU5aTz+USVhf72M0WUp2fHO42kXo1nEeF Pr0xWY3/pU7HWnqk1iLJzKmeYhrQ8vs8Am01EzhlLlBo+aDTrGvoysNls//xQEjLkjFZ VnRWeKueXb1MmREJYxoU7M4rC2KTrrNPsKt5I= Received: by 10.180.101.165 with SMTP id fh5mr11995979wib.10.1328914450738; Fri, 10 Feb 2012 14:54:10 -0800 (PST) Received: from debian.x201.phnet (93-93.203-62.cust.bluewin.ch. [62.203.93.93]) by mx.google.com with ESMTPS id s8sm6162973wiz.8.2012.02.10.14.54.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Feb 2012 14:54:09 -0800 (PST) Message-ID: <4F35A00F.2010209@gmail.com> Date: Fri, 10 Feb 2012 23:54:07 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20120104 Icedove/8.0 MIME-Version: 1.0 To: The development of GRUB 2 Subject: gettext in scripts Content-Type: multipart/mixed; boundary="------------070900060902090508000501" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.169 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Feb 2012 22:54:14 -0000 This is a multi-part message in MIME format. --------------070900060902090508000501 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello, all. It was requested to have a way to gettextize Super GRUB disk. Original request was to extend gettext with -s options but it may result in a mess to temporary variables. So I'd propose to rather use $"..." syntax with the exception that we don't expand it after translation to avoid some pitfalls. Sharing syntax with bash will allow to use normal xgettext --language=Shell. The real problem is as to how to include SGD strings in grub.pot. I see following solutions: 1) Merge projects and put SGD inside GRUB2. It's possible if its authors want it but many more questions would need to be discussed. 2) Import sgd.pot into grub.pot regularly. This creates an administrative overhead and requires GRUB and scripts to have matching versions. I don't know if it's easy to merge .pot files 3) Just have a few strings for usage by external projects. This would heavily limit the extent of internationalisation and would result in a lot of feature requests one after another for this or that string. 4) Have some way to load .mo from another directory. Perhaps something like locale_dirs=$dir1:$dir2:$dir3. This creates some problems as to how and when to load files and how to store them. The easiest way consisting of having multiple opened gettext files and try each of it in turn. Trouble is that then when adding a single directory we need to either reload all files or compare the previous list with current to reload only changed directories. Any other ideas? -- Regards Vladimir 'φ-coder/phcoder' Serbinenko --------------070900060902090508000501 Content-Type: text/x-diff; name="gettext.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gettext.diff" === modified file 'grub-core/script/execute.c' --- grub-core/script/execute.c 2012-02-04 11:21:21 +0000 +++ grub-core/script/execute.c 2012-02-10 22:24:15 +0000 @@ -26,6 +26,7 @@ #include #include #include +#include /* Max digits for a char is 3 (0xFF is 255), similarly for an int it is sizeof (int) * 3, and one extra for a possible -ve sign. */ @@ -312,8 +313,8 @@ struct grub_script_arg *arg = 0; struct grub_script_argv result = { 0, 0, 0 }; - auto int append (char *s, int escape_type); - int append (char *s, int escape_type) + auto int append (const char *s, int escape_type); + int append (const char *s, int escape_type) { int r; char *p = 0; @@ -379,12 +380,20 @@ break; case GRUB_SCRIPT_ARG_TYPE_TEXT: - if (grub_strlen (arg->str) && + if (arg->str[0] && grub_script_argv_append (&result, arg->str, grub_strlen (arg->str))) goto fail; break; + case GRUB_SCRIPT_ARG_TYPE_GETTEXT: + { + const char *t = _(arg->str); + if (grub_script_argv_append (&result, t, grub_strlen (t))) + goto fail; + } + break; + case GRUB_SCRIPT_ARG_TYPE_DQSTR: case GRUB_SCRIPT_ARG_TYPE_SQSTR: if (append (arg->str, 1)) === modified file 'grub-core/script/yylex.l' --- grub-core/script/yylex.l 2012-02-03 10:56:49 +0000 +++ grub-core/script/yylex.l 2012-02-10 22:20:27 +0000 @@ -131,15 +131,17 @@ SQCHR [^\'] DQCHR {ESC}|[^\\\"] DQSTR \"{DQCHR}*\" +I18NSTR \$\"{DQCHR}*\" SQSTR \'{SQCHR}*\' SPECIAL \?|\#|\*|\@ VARIABLE ${NAME}|$\{{NAME}\}|${DIGITS}|$\{{DIGITS}\}|${SPECIAL}|$\{{SPECIAL}\} -WORD ({CHAR}|{DQSTR}|{SQSTR}|{ESC}|{VARIABLE})+ +WORD ({CHAR}|{DQSTR}|{SQSTR}|{ESC}|{VARIABLE}|{I18NSTR})+ MULTILINE {WORD}?((\"{DQCHR}*)|(\'{SQCHR}*)|(\\\n)) %x SPLIT %x DQUOTE +%x I18NQUOTE %x SQUOTE %x VAR @@ -215,6 +217,10 @@ yy_push_state (SQUOTE, yyscanner); ARG (GRUB_SCRIPT_ARG_TYPE_TEXT); } + "\$\"" { + yy_push_state (I18NQUOTE, yyscanner); + ARG (GRUB_SCRIPT_ARG_TYPE_GETTEXT); + } \$ { yy_push_state (VAR, yyscanner); ARG (GRUB_SCRIPT_ARG_TYPE_TEXT); @@ -280,6 +286,18 @@ (.|\n) { COPY (yytext, yyleng); } } +{ + \\\\ { COPY ("\\", 1); } + \\\" { COPY ("\"", 1); } + \\\n { /* ignore */ } + [^\"\\\n]+ { COPY (yytext, yyleng); } + \" { + yy_pop_state (yyscanner); + ARG (GRUB_SCRIPT_ARG_TYPE_GETTEXT); + } + (.|\n) { COPY (yytext, yyleng); } +} + <> { yypop_buffer_state (yyscanner); yyextra->lexerstate->eof = 1; === modified file 'include/grub/script_sh.h' --- include/grub/script_sh.h 2011-11-11 19:34:37 +0000 +++ include/grub/script_sh.h 2012-02-10 20:30:33 +0000 @@ -53,6 +53,7 @@ { GRUB_SCRIPT_ARG_TYPE_VAR, GRUB_SCRIPT_ARG_TYPE_TEXT, + GRUB_SCRIPT_ARG_TYPE_GETTEXT, GRUB_SCRIPT_ARG_TYPE_DQVAR, GRUB_SCRIPT_ARG_TYPE_DQSTR, GRUB_SCRIPT_ARG_TYPE_SQSTR, --------------070900060902090508000501--