From owner-freebsd-current@FreeBSD.ORG Sun Jan 22 22:30:46 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1502D106566C for ; Sun, 22 Jan 2012 22:30:46 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) by mx1.freebsd.org (Postfix) with ESMTP id C90998FC16 for ; Sun, 22 Jan 2012 22:30:45 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id q0MMUioa098772; Sun, 22 Jan 2012 22:30:44 GMT (envelope-from tim@kientzle.com) Received: from [192.168.2.119] (CiscoE3000 [192.168.1.65]) by kientzle.com with SMTP id 8wxxnga825thdhwieziihq94m2; Sun, 22 Jan 2012 22:30:44 +0000 (UTC) (envelope-from tim@kientzle.com) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Tim Kientzle In-Reply-To: <4F1C8816.5030104@fuzzwad.org> Date: Sun, 22 Jan 2012 14:30:39 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4F1C8816.5030104@fuzzwad.org> To: Ron McDowell X-Mailer: Apple Mail (2.1251.1) Cc: freebsd-current Subject: Re: i18n and shell scripts X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jan 2012 22:30:46 -0000 On Jan 22, 2012, at 2:05 PM, Ron McDowell wrote: > I'm working on the new bsdconfig, and looking for some good examples = of how to incorporate internationalization into the scripts. I'm not = finding much love in this area. :-( >=20 > Any pointers appreciated. GNU gettext may not be an option here, but the documentation at http://www.gnu.org/software/gettext/manual/gettext.html#sh outlines how this can be done. The general model used by gettext and lots of other translation systems = is: * There's a distinctive function name or source code pattern wrapping = the English text strings. * So you can run a simple program that identifies and extracts these = strings. (Simple sed or awk scripts often suffice.) * Translation files map English text =3D=3D> translated text. (There = are many more-or-less standard formats used for translation files; the = .po format used by gettext is widely supported by translation tools. In = particular, there are a number of commercial translation management = interfaces that allow free use by open-source projects and can directly = upload/download po files.) * Translation files can be compiled into some dictionary structure = that can be used efficiently at run time. * The "distinctive source code pattern" above is typically a function = name. At run-time, that function looks up the English text string from = the source file and emits the result. Nothing here is difficult to just build from scratch. The complex part = is the process for actually keeping track of what has and hasn't been = translated across a large number of languages. Fortunately, there are = some pretty good translation management systems on the web where you can = upload .po files, invite people to contribute translations and then = download constructed .po files for each language. At work, we've = started using getLocalization.com, which looks pretty promising, but = there are many others. Warning: Translating quantities (e.g., "$x bytes") is complicated (why = does 'zero' take a plural in English?). You can sometimes just avoid it = ("size in bytes: $x") and sometimes get by with stilted language (e.g., = "1 bytes" or "$x byte(s)"). If you require high-quality handling of = phrases that include variable numbers, then you'll need something more = complex than just a lookup table. Cheers, Tim