Re: Patch to make some strings available to translations

Поиск
Список
Период
Сортировка
От Guillaume Lelarge
Тема Re: Patch to make some strings available to translations
Дата
Msg-id 47E57F91.9010809@lelarge.info
обсуждение исходный текст
Ответ на Re: Patch to make some strings available to translations  (Alvaro Herrera <alvherre@commandprompt.com>)
Ответы Re: Patch to make some strings available to translations
Список pgsql-www
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
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 @@
               <div id="pgFrontUser">
                 <div id="pgFrontUserInner">
                   <div id="pgFrontUserWrap">
-                    <h2><img src="/layout/images/en/hdr_featureduser.png" width="104" height="10" alt="Featured User"
/></h2>
+                    <h2><img src=func_image('hdr_featureduser.png') width="104" height="10" alt="Featured User"
/></h2>
                     <div id="pgFrontUserContent">
                       <!-- INCLUDE about/quotes-index.html -->
                       <div id="txtFrontUserLink">
@@ -39,7 +39,7 @@
         </div>
         <div id="pgFrontRightContainer">
           <div id="pgFrontLatestReleases">
-            <h2><img src="/layout/images/en/hdr_latestreleases.png" width="120" height="10" alt="Latest Releases"
/></h2>
+            <h2><img src=func_image('hdr_latestreleases.png') width="120" height="10" alt="Latest Releases" /></h2>
             <div id="pgFrontLatestReleasesWrap">
 <!-- BEGIN front_release_loop -->
              <b>{version}:</b> <a href="/ftp/source/v{version}">Source</a> · <a
href="/ftp/binary/v{version}">Binary</a>· <a href="/docs/{majorver}/static/{relnotes}">Notes</a> 
@@ -49,7 +49,7 @@
             <div id="pgFrontLatestReleasesNote"><a href="/versions.rss" title="func_lang('Versions RSS Feed')"><img
class="pgRSSImage"src="/layout/images/ico_rss.png" width="28" height="13" alt="func_lang('Versions RSS Feed')" /></a> |
<ahref="/support/versioning">Why should I upgrade?</a></div> 
           </div>
           <div id="pgFrontShortcuts">
-            <h2><img src="/layout/images/en/hdr_shortcuts.png" width="85" height="10" alt="Shortcuts" /></h2>
+            <h2><img src=func_image('hdr_shortcuts.png') width="85" height="10" alt="Shortcuts" /></h2>
             <div id="pgFrontShortcutsWrap">
               <ul id="pgFrontShortcutsList">
                 <li>
@@ -77,7 +77,7 @@
             </div>
           </div>
           <div id="pgFrontSupportUs">
-            <h2><img src="/layout/images/en/hdr_supportus.png" width="81" height="10" alt="Support Us" /></h2>
+            <h2><img src=func_image('hdr_supportus.png') width="81" height="10" alt="Support Us" /></h2>
             <div id="pgFrontSupportUsWrap">
               <div id="txtFrontSupportUsText">
                 func_lang("PostgreSQL is free. Please support our work by making a <a
href=\"/about/donate\">donation</a>").
@@ -88,7 +88,7 @@
        <div id="pgFrontBottomContainer">
          <div id="pgFrontNews" class="txtNewsEvent">
            <a href="/about/newsarchive">
-           <img src="/layout/images/en/hdr_latestnews.png" width="90" height="10" alt="Latest News" />
+           <img src=func_image('hdr_latestnews.png') width="90" height="10" alt="Latest News" />
            </a>
            <div class="pgNewsEventsWrap">
              <!-- INCLUDE about/news-index-loop.html -->
@@ -110,7 +110,7 @@
          </div>
           <div id="pgFrontPlanet">
             <a href="http://www.planetpostgresql.org">
-            <img src="/layout/images/en/hdr_planetpg.png" width="140" height="10" alt="Planet PostgreSQL" />
+            <img src=func_image('hdr_planetpg.png') width="140" height="10" alt="Planet PostgreSQL" />
             </a>
             <div id="pgFrontPlanetWrap">
               <!-- BEGIN planet_loop -->
@@ -134,13 +134,13 @@
           </div>
          <div id="pgFrontEvents" class="txtNewsEvent">
            <a href="/about/eventarchive">
-           <img src="/layout/images/en/hdr_upcomingevents.png" width="123" height="10" alt="Upcoming Events" />
+           <img src=func_image('hdr_upcomingevents.png') width="123" height="10" alt="Upcoming Events" />
            </a>
            <div class="pgNewsEventsWrap">
                <!-- INCLUDE about/events-index-loop.html -->
            </div>
            <a href="/about/eventarchive">
-           <img src="/layout/images/en/hdr_upcomingtraining.png" alt="Upcoming training" />
+           <img src=func_image('hdr_upcomingtraining.png') alt="Upcoming training" />
            </a>
            <div class="pgNewsEventsWrap">
              <div id="pgFrontTrainingSummary">

В списке pgsql-www по дате отправления:

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: postgresql.org mail infrastructure
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: postgresql.org mail infrastructure