Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B4FD22E002D for ; Sat, 22 Mar 2008 18:52:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57408-01 for ; Sat, 22 Mar 2008 18:52:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sd-2317.dedibox.fr (sd-2317.dedibox.fr [88.191.17.192]) by postgresql.org (Postfix) with ESMTP id B9A712E005C for ; Sat, 22 Mar 2008 18:52:20 -0300 (ADT) Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by sd-2317.dedibox.fr (Postfix) with ESMTP id 0799EA21D; Sat, 22 Mar 2008 22:52:17 +0100 (CET) Message-ID: <47E57F91.9010809@lelarge.info> Date: Sat, 22 Mar 2008 22:52:17 +0100 From: Guillaume Lelarge User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: Alvaro Herrera CC: Magnus Hagander , PostgreSQL www Subject: Re: Patch to make some strings available to translations References: <47DAF7E3.8070502@lelarge.info> <47DD4BAA.5000402@hagander.net> <47DD9F5C.1060101@lelarge.info> <47E0B5CD.9030504@lelarge.info> <47E18498.4060609@lelarge.info> <47E18CDB.60303@hagander.net> <47E18DFA.5030003@lelarge.info> <47E52413.1030407@lelarge.info> <47E52489.7030608@lelarge.info> <20080322205914.GF13206@alvh.no-ip.org> In-Reply-To: <20080322205914.GF13206@alvh.no-ip.org> Content-Type: multipart/mixed; boundary="------------080007020407030109080708" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/504 X-Sequence-Number: 14623 This is a multi-part message in MIME format. --------------080007020407030109080708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Alvaro Herrera a écrit : > Guillaume Lelarge wrote: > >>> I guess I was wrong. You'll find a patch attached that implements a >>> func_image function via a call to setCallbackFunction. >>> >>> I can also send a complete patch (the previous one which adds >>> translation to some texts, and this patch). > > Suggestion: check if the image exists in the translated version, serve > the english version if not. That way you only need to produce alternate > images for those that need translation. > Damn, forgot about this one. You're right. Patch version 2 attached. Thanks Alvaro. -- Guillaume. http://www.postgresqlfr.org http://dalibo.com --------------080007020407030109080708 Content-Type: text/x-patch; name="images_v2.patch" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="images_v2.patch" Index: system/global/pgpage.php =================================================================== --- system/global/pgpage.php (révision 2004) +++ system/global/pgpage.php (copie de travail) @@ -2,6 +2,17 @@ // $Id: pgpage.php,v 1.6 2007-10-21 17:20:07 mastermind Exp $ // Base-class for all pages // + +function getimage($arg) { + global $pgpage; + if (file_exists('../layout/images/'.$pgpage->getLanguage().'/'.$arg)) { + return '"/layout/images/'.$pgpage->getLanguage().'/'.$arg.'"'; + } + else { + return '"/layout/images/en/'.$arg.'"'; + } +} + abstract class PgPage { protected $language; protected $language_direction; @@ -87,6 +98,7 @@ $locale = $this->language; if (isset($_LANGUAGE_ALIASES[$this->language])) $locale = $_LANGUAGE_ALIASES[$this->language]; + $locale .= '.UTF-8'; putenv('LANG=' . $locale); putenv('LANGUAGE=' . $locale); @@ -104,6 +116,10 @@ header('Content-Language: ' . $this->language); } + public function getLanguage() { + return $this->language; + } + private function getLanguageFromHeaders() { global $_LANGUAGES; @@ -122,6 +138,7 @@ // Prepare the template $this->tpl =& new HTML_Template_Sigma('../template'); $this->tpl->setCallbackFunction('lang', 'gettext', true); + $this->tpl->setCallbackFunction('image', 'getimage', true); $this->tpl->loadTemplateFile($this->base_template, true, true); $this->tpl->setGlobalVariable(array( 'site_title' => $_SETTINGS['site_title'], Index: template/index.html =================================================================== --- template/index.html (révision 2004) +++ template/index.html (copie de travail) @@ -24,7 +24,7 @@
-

Featured User

+

Featured User

-

Latest Releases

+

Latest Releases

{version}: Source · Binary · Notes @@ -49,7 +49,7 @@
-

Shortcuts

+

Shortcuts

  • @@ -77,7 +77,7 @@
-

Support Us

+

Support Us

func_lang("PostgreSQL is free. Please support our work by making a donation"). @@ -88,7 +88,7 @@
- Latest News + Latest News
@@ -110,7 +110,7 @@
- Planet PostgreSQL + Planet PostgreSQL
@@ -134,13 +134,13 @@
- Upcoming Events + Upcoming Events
- Upcoming training + Upcoming training
--------------080007020407030109080708--