Обсуждение: Patch to make some strings available to translations

Поиск
Список
Период
Сортировка

Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Hi,

I already sent this patch a few months before, but didn't get an answer
on it. So, I updated it and hope for the best :)

Anyways, a few words on one file of this patch. I had to change
system/global/pgpage.php in two ways.

First, to add '.UTF-8' to the locale. Without, I couldn't get any
gettext translation to work. I wonder if Adrian had to do the same for
his translation. I don't think the way I did it is absolutely right, so
I would like comments on this.

Second, base_href is set to http://www.postgresql.org/, making any links
go to the official website. I'm wondering why we didn't use the value of
$_SETTINGS['hosted_url'] for example as it can be a local setting.

Any comments ? better ways to solve these ?

Thanks.

Regards.


--
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com
Index: system/global/pgpage.php
===================================================================
--- system/global/pgpage.php    (révision 1995)
+++ system/global/pgpage.php    (copie de travail)
@@ -87,6 +87,7 @@
        $locale = $this->language;
        if (isset($_LANGUAGE_ALIASES[$this->language]))
            $locale = $_LANGUAGE_ALIASES[$this->language];
+       $locale .= '.UTF-8';

        putenv('LANG=' . $locale);
        putenv('LANGUAGE=' . $locale);
@@ -183,7 +184,7 @@

       if (!isset($_SERVER['ISMASTER']) || $_SERVER['ISMASTER'] != '1') {
           if ($this->navsection != 'admin')
-             $this->tpl->setVariable('base_href', 'http://www.postgresql.org/' . $this->url);
+             $this->tpl->setVariable('base_href', $_SETTINGS['hosted_url'] . $this->url);
       }
    }

Index: system/global/languages.php
===================================================================
--- system/global/languages.php    (révision 1995)
+++ system/global/languages.php    (copie de travail)
@@ -33,6 +33,7 @@
 $GLOBALS['_LANGUAGE_ALIASES'] = array(
     'br' => 'pt_BR',
     'en' => 'en_US',
+    'fr' => 'fr_FR',
     'ru' => 'ru_RU',
     'tr' => 'tr_TR'
 );
Index: template/common.html
===================================================================
--- template/common.html    (révision 1995)
+++ template/common.html    (copie de travail)
@@ -9,13 +9,13 @@
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <link rel="shortcut icon" href="/favicon.ico" />
 <!-- BEGIN page_rss_links -->
-    <link rel="alternate" type="application/rss+xml" title="PostgreSQL news" href="/news.rss" />
-    <link rel="alternate" type="application/rss+xml" title="PostgreSQL events" href="/events.rss" />
-    <link rel="alternate" type="application/rss+xml" title="PostgreSQL latest versions" href="/versions.rss" />
-    <link rel="alternate" type="application/rss+xml" title="Planet PostgreSQL"
href="http://www.planetpostgresql.org/rss20.xml"/> 
+    <link rel="alternate" type="application/rss+xml" title="func_lang('PostgreSQL news')" href="/news.rss" />
+    <link rel="alternate" type="application/rss+xml" title="func_lang('PostgreSQL events')" href="/events.rss" />
+    <link rel="alternate" type="application/rss+xml" title="func_lang('PostgreSQL latest versions')"
href="/versions.rss"/> 
+    <link rel="alternate" type="application/rss+xml" title="func_lang('Planet PostgreSQL')"
href="http://www.planetpostgresql.org/rss20.xml"/> 
 <!-- END page_rss_links -->
     <style type="text/css" media="screen" title="Normal Text">@import url("/layout/css/blue/fixed.css");</style>
-    <link rel="alternate stylesheet" media="screen" href="/layout/css/blue/fixed_large.css" type="text/css"
title="LargeText" /> 
+    <link rel="alternate stylesheet" media="screen" href="/layout/css/blue/fixed_large.css" type="text/css"
title="func_lang('LargeText')" /> 
     <script type="text/javascript" src="/layout/js/styleswitcher.js"></script>
     <script type="text/javascript" src="/layout/js/geckostyle.js"></script>
 <!-- BEGIN include_tinymce_scripts -->
@@ -30,14 +30,14 @@
   <body>
    <div id="pgContainerWrap">
     <div id="pgContainer">
-      <span class="txtOffScreen"><a href="#pgContent" title="Skip site navigation" accesskey="1">Skip site
navigation</a>(1)</span> 
-      <span class="txtOffScreen"><a href="#pgContentWrap" title="Skip section navigation" accesskey="2">Skip section
navigation</a>(2)</span> 
+      <span class="txtOffScreen"><a href="#pgContent" title="func_lang('Skip site navigation')"
accesskey="1">func_lang("Skipsite navigation")</a> (1)</span> 
+      <span class="txtOffScreen"><a href="#pgContentWrap" title="func_lang('Skip section navigation')"
accesskey="2">func_lang("Skipsection navigation")</a> (2)</span> 
       <div id="pgHeaderContainer">
         <div id="pgSearch">
           <form method="get" action="http://search.postgresql.org/search">
             <div>
           <h2 class="pgBlockHide"><label for="q">func_lang("Search")</label></h2>
-          <input id="q" name="q" type="text" size="20" maxlength="255" onfocus="if( this.value==this.defaultValue )
this.value='';"value="Search" accesskey="s" /><input name="a" type="hidden" value="1"/><input id="submit" name="submit"
type="submit"value="Search" /> 
+          <input id="q" name="q" type="text" size="20" maxlength="255" onfocus="if( this.value==this.defaultValue )
this.value='';"value="func_lang('Search')" accesskey="s" /><input name="a" type="hidden" value="1"/><input id="submit"
name="submit"type="submit" value="func_lang('Search')" /> 
             </div>
           </form>
        <h2 class="pgBlockHide">func_lang("Peripheral Links")</h2>
@@ -62,7 +62,7 @@
           </div>
           <div id="pgHeaderLogoRight">
             <span class="txtOffScreen">|</span>
-            <a href="/" title="The world's most advanced open source database."><img
src="/layout/images/hdr_right.png"width="210" height="80" alt="The world's most advanced open source database." /></a> 
+            <a href="/" title="func_lang('The world\'s most advanced open source database.')"><img
src="/layout/images/hdr_right.png"width="210" height="80" alt="func_lang('The world\'s most advanced open source
database.')"/></a> 
           </div>
         </div>
       <h2 class="pgBlockHide">func_lang("Site Navigation")</h2>
Index: template/search.html
===================================================================
--- template/search.html    (révision 1995)
+++ template/search.html    (copie de travail)
@@ -5,32 +5,32 @@
  <div class="tblBasic">
   <table border="0" cellpadding="0" cellspacing="0" class="tblBasicGrey" width="590">
    <tr>
-    <td class="colFirstR">Search for:</td>
-    <th class="colLast"><input type="text" name="q" value="{searchfor}" /> <input type="submit" value="Search" /></th>
+    <td class="colFirstR">func_lang("Search for"):</td>
+    <th class="colLast"><input type="text" name="q" value="{searchfor}" /> <input type="submit"
value="func_lang('Search')"/></th> 
    </tr>
 <!-- BEGIN main_form -->
    <tr class="lastrow">
     <td class="colFirst"></td>
-    <td class="colLast"><input type="checkbox" name="a" value="1" {comsites}/>Include community sites</td>
+    <td class="colLast"><input type="checkbox" name="a" value="1" {comsites}/>func_lang("Include community
sites")</td>
    </tr>
 <!-- END main_form -->
 <!-- BEGIN archives_form -->
    <tr>
-    <td class="colFirstR">List:<input type="hidden" name="m" value="1" /></td>
+    <td class="colFirstR">func_lang("List"):<input type="hidden" name="m" value="1" /></td>
     <td class="colLast"><select name="l"><!-- BEGIN archives_lists -->
  <option value="{listid}"{listselect}>{listname}</option>
 <!-- END archives_lists -->
 </select></td>
    </tr>
    <tr>
-    <td class="colFirstR">Post date:</td>
+    <td class="colFirstR">func_lang("Post date"):</td>
     <td class="colLast"><select name="d"><!-- BEGIN archives_dates -->
 <option value="{archives_dates_val}" {archives_dates_sel}>{archives_dates_txt}</option>
 <!-- END archives_dates -->
 </select></td>
    </tr>
    <tr class="lastrow">
-    <td class="colFirst" align="right">Sort by:</td>
+    <td class="colFirst" align="right">func_lang("Sort by"):</td>
     <td class="colLast"><select name="s">{archives_sort_str}</select></td>
    </tr>
 <!-- END archives_form -->
@@ -44,7 +44,7 @@
 <!-- END search_error -->
 </div>
 <!-- BEGIN docbot_search -->
-Based on your search term, we recommend the following links:
+func_lang("Based on your search term, we recommend the following links"):
 <ul id="pgFrontShortcutsList">
 <!-- BEGIN docbot_search_loop -->
 <li><a href="{docbot_url}">{docbot_url}</a></li>
@@ -52,14 +52,14 @@
 </ul>
 <!-- END docbot_search -->
 <!-- BEGIN no_hits -->
-<p>Your search for <b>{searchfor}</b> returned no hits.</p>
+<p>func_lang("Your search for <b>{searchfor}</b> returned no hits").</p>
 <!-- END no_hits -->
 <!-- BEGIN main_search -->
-<h2>Results {firsthit}-{lasthit} of {totalhits}.</h2>
-<p>Searching in {searchpages} pages took {searchtime} seconds.
-Site search powered by <a href="http://www.postgresql.org">PostgreSQL 8.3</a>.</p>
+<h2>func_lang("Results {firsthit}-{lasthit} of {totalhits}").</h2>
+<p>func_lang("Searching in {searchpages} pages took {searchtime} seconds").
+func_lang("Site search powered by") <a href="http://www.postgresql.org">PostgreSQL 8.3</a>.</p>
 <!-- BEGIN page_links1 -->
-Result pages: {page_links}<br/><br/>
+func_lang("Result pages"): {page_links}<br/><br/>
 <!-- END page_links1 -->
 <!-- BEGIN main_search_loop -->
 {hit_num}. <a href="{hit_url}">{hit_title}</a> [{hit_rank}]<br/>
@@ -69,12 +69,12 @@
 <!-- END main_search_loop -->
 <!-- BEGIN archives_search_loop -->
 {arch_num} . <a
href="http://archives.postgresql.org/{arch_list}/{arch_year}-{arch_month}/msg{arch_msgnum}.php">{arch_subject}</a>
[{arch_rank}]<br/>
-Posted {arch_date} by {arch_author}.<br/>
+func_lang("Posted {arch_date} by {arch_author}.")<br/>
 {arch_abstract}<br/>
 <a
href="http://archives.postgresql.org/{arch_list}/{arch_year}-{arch_month}/msg{arch_msgnum}.php">http://archives.postgresql.org/{arch_list}/{arch_year}-{arch_month}/msg{arch_msgnum}.php</a><br/>
 <br/>
 <!-- END archives_search_loop -->
 <!-- BEGIN page_links2 -->
-Result pages: {page_links}<br/><br/>
+func_lang("Result pages"): {page_links}<br/><br/>
 <!-- END page_links2 -->
 <!-- END main_search -->
Index: template/download.html
===================================================================
--- template/download.html    (révision 1995)
+++ template/download.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-Choose a Mirror
+func_lang("Choose a Mirror")
 <!-- END page_title_block -->
 <!-- BEGIN www_mirror_greeting -->
 <h1>func_lang("Choose a website mirror")</h1>
@@ -22,8 +22,7 @@
 <b><a href="{master_server}/redir?{url}">{urlh}</a></b>
 </p>
 <!-- BEGIN last_mirror_download_block -->
-<p>Your download will start automatically from this mirror in 5 seconds unless you select
-another mirror in the list below.</p>
+<p>func_lang("Your download will start automatically from this mirror in 5 seconds unless you select another mirror in
thelist below.")</p> 
 <!-- END last_mirror_download_block -->
 <!-- BEGIN last_mirror_browse_block -->
 <p>You will be automatically redirected to this mirror in 5 seconds unless you
Index: template/community-docs.html
===================================================================
--- template/community-docs.html    (révision 1995)
+++ template/community-docs.html    (copie de travail)
@@ -2,7 +2,7 @@
  <table border="0" cellpadding="0" cellspacing="0" width="95%" class="tblCompact tblBasicGrey">
   <tr class="firstrow">
    <td class="colFirstT">
-This page is user contributed documentation. See the bottom of the page for information about the author.
+func_lang("This page is user contributed documentation. See the bottom of the page for information about the author.")
    </td>
    <td class="colLastT"> </td>
   </tr>
@@ -23,16 +23,16 @@
 <div id="pgCommunityDocsFooter" class="tblBasic">
  <table border="0" cellpadding="0" cellspacing="0" width="95%" class="tblCompact tblBasicGrey">
   <tr class="firstrow">
-   <td class="colFirstT">Updated:</td>
+   <td class="colFirstT">func_lang("Updated"):</td>
    <td class="colLastT">{savedate}</td>
   </tr>
   <tr>
-   <td class="colFirstT">Author:</td>
+   <td class="colFirstT">func_lang("Author"):</td>
    <td class="colLastT"><strong>{author_name}</strong><br/>{author_info}</td>
   </tr>
 <!-- BEGIN communitydoc_versionhistory_wrap -->
   <tr>
-   <td class="colFirstT">Version history:</td>
+   <td class="colFirstT">func_lang("Version history"):</td>
    <td class="colLastT">
    <ul>
     <!-- BEGIN communitydocs_versionhistory -->
@@ -43,8 +43,8 @@
   </tr>
 <!-- END communitydoc_versionhistory_wrap -->
   <tr class="lastrow">
-   <td class="colFirstT">Operations:</td>
-   <td class="colLastT"><a href="{master_server}/community/docedit.{page_id}">Edit</a> <a
href="{master_server}/community/docadd.{page_id}">Createsubpage</a> (Requires <a href="/community/signup">community
login</a>)</td>
+   <td class="colFirstT">func_lang("Operations"):</td>
+   <td class="colLastT"><a href="{master_server}/community/docedit.{page_id}">func_lang("Edit")</a> <a
href="{master_server}/community/docadd.{page_id}">func_lang("Createsubpage")</a> (func_lang("Requires") <a
href="/community/signup">func_lang("communitylogin")</a>)</td> 
   </tr>
  </table>
 </div>
Index: template/common-docs.html
===================================================================
--- template/common-docs.html    (révision 1995)
+++ template/common-docs.html    (copie de travail)
@@ -23,7 +23,7 @@
     <form action="http://search.postgresql.org/search" method="get">
     <div>
     <input type="hidden" name="u" value="/docs/{doc_nav_version}/{docs_type}/" />
-    <label for="q">func_lang("Search Documentation:") </label><input type="text" id="q" name="q" size="20"
onfocus="if(this.value==this.defaultValue ) this.value='';" value="Search" /><input id="submit" type="submit"
value="func_lang('Search')"/> 
+    <label for="q">func_lang("Search Documentation:") </label><input type="text" id="q" name="q" size="20"
onfocus="if(this.value==this.defaultValue ) this.value='';" value="func_lang('Search')" /><input id="submit"
type="submit"value="func_lang('Search')" /> 
     </div>
     </form>
         <div id="docTextSize">func_lang("Text Size:") <a href="#" onclick="setActiveStyleSheet('Normal Text'); return
false;"onkeypress="return false;" title="func_lang('Normal Text Size')">func_lang("Normal")</a> / <a href="#"
onclick="setActiveStyleSheet('LargeText'); return false;" onkeypress="return false;" title="func_lang('Large Text
Size')">func_lang("Large")</a></div>
Index: template/community/survey.html
===================================================================
--- template/community/survey.html    (révision 1995)
+++ template/community/survey.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-Community: Survey Results: {page_title}
+func_lang("Community: Survey Results:") {page_title}
 <!-- END page_title_block -->
 <h1>func_lang("Survey Results")</h1>
 <p>func_lang("The current results of our <b>{result_title}</b> survey are:")</p>
Index: template/navigation/community.html
===================================================================
--- template/navigation/community.html    (révision 1995)
+++ template/navigation/community.html    (copie de travail)
@@ -15,8 +15,8 @@
 <li><a href="/community/weeklynews/">func_lang("Weekly News")</a></li>
 <li class="last-child"><a href="/community/signup">Community login</a>
     <ul>
-        <li><a href="{master_server}/community/profile">Profile</a></li>
-        <li class="last-child"><a href="/community/lostpwd">Lost password</a></li>
+        <li><a href="{master_server}/community/profile">func_lang("Profile")</a></li>
+        <li class="last-child"><a href="/community/lostpwd">func_lang("Lost password")</a></li>
     </ul>
 </li>
 </ul>
Index: template/navigation/download.html
===================================================================
--- template/navigation/download.html    (révision 1995)
+++ template/navigation/download.html    (copie de travail)
@@ -1,7 +1,7 @@
 <ul>
 <li><a href="/download/">func_lang("Downloads")</a></li>
 <li><a href="/ftp/">func_lang("File Browser")</a></li>
-<li><a href="/download/#other">Community Software</a>
+<li><a href="/download/#other">func_lang("Community Software")</a>
  <ul>
   <li class="last-child"><a href="http://pgfoundry.org">pgFoundry</a></li>
  </ul>
Index: template/navigation/about.html
===================================================================
--- template/navigation/about.html    (révision 1995)
+++ template/navigation/about.html    (copie de travail)
@@ -10,7 +10,7 @@
 <li><a href="/about/history">func_lang("History")</a></li>
 <li><a href="/about/sponsors">func_lang("Sponsors")</a>
  <ul>
-  <li class="last-child"><a href="/about/servers">Servers</a></li>
+  <li class="last-child"><a href="/about/servers">func_lang("Servers")</a></li>
  </ul>
 </li>
 <li><a href="/about/newsarchive">func_lang("Latest News")</a></li>
Index: template/about/news.html
===================================================================
--- template/about/news.html    (révision 1995)
+++ template/about/news.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-News: {title_headline}
+func_lang("News"): {title_headline}
 <!-- END page_title_block -->
 <h1>{headline}</h1>
 <div id="pgArchiveWrap">
Index: template/about/newsarchive.html
===================================================================
--- template/about/newsarchive.html    (révision 1995)
+++ template/about/newsarchive.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-News
+func_lang("News")
 <!-- END page_title_block -->
 <h1>func_lang("News")</h1>

Index: template/about/quotes.html
===================================================================
--- template/about/quotes.html    (révision 1995)
+++ template/about/quotes.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-Quote: {title_headline}
+func_lang("Quote"): {title_headline}
 <!-- END page_title_block -->
 <h1>func_lang("Featured User")</h1>
 <div id="txtFrontUserText">
Index: template/about/event.html
===================================================================
--- template/about/event.html    (révision 1995)
+++ template/about/event.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-Events: {title_event} in {title_location}
+func_lang("Events: {title_event} in {title_location}")
 <!-- END page_title_block -->
 <h1>{event}</h1>
 <div id="pgArchiveWrap">
Index: template/about/quotesarchive.html
===================================================================
--- template/about/quotesarchive.html    (révision 1995)
+++ template/about/quotesarchive.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-Quotes
+func_lang("Quotes")
 <!-- END page_title_block -->
 <h1>func_lang("Quotes")</h1>

Index: template/about/eventarchive.html
===================================================================
--- template/about/eventarchive.html    (révision 1995)
+++ template/about/eventarchive.html    (copie de travail)
@@ -1,5 +1,5 @@
 <!-- BEGIN page_title_block -->
-Events
+func_lang("Events")
 <!-- END page_title_block -->
 <h1>func_lang("Events")</h1>
 <br />
Index: template/about/events-loop.html
===================================================================
--- template/about/events-loop.html    (révision 1995)
+++ template/about/events-loop.html    (copie de travail)
@@ -6,7 +6,7 @@
     <!-- BEGIN event_date_startend -->
     func_lang("Date:") <b>{event_date_start} – {event_date_end}</b>
     <!-- END event_date_startend -->
-    func_lang("Location:") <B>{event_location}</b><br />
+    func_lang("Location:") <b>{event_location}</b><br />
 func_lang("Posted by <b>{event_posted_by}</b>")<br />
 <div class="listsummary">{event_summary} <a href="/about/event.{event_id}">func_lang("more...")</a></div><br />
 <!-- END event_loop -->
Index: template/index.html
===================================================================
--- template/index.html    (révision 1995)
+++ template/index.html    (copie de travail)
@@ -27,11 +27,11 @@
               <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="/layout/images/en/hdr_featureduser.png" width="104" height="10"
alt="func_lang('FeaturedUser')" /></h2> 
                     <div id="pgFrontUserContent">
                       <!-- INCLUDE about/quotes-index.html -->
                       <div id="txtFrontUserLink">
-                          <img src="/layout/images/blt_blu_arrow.png" width="6" height="5" alt="" /><a
href="/about/casestudies">func_lang("CaseStudies")</a><span class="txtDivider">|</span><a href="/about/quotesarchive"
title="Seemore quotes">func_lang("More Quotes")</a><span class="txtDivider">|</span><a href="/about/users" title="See
featuredusers">func_lang("Featured Users")</a> 
+                          <img src="/layout/images/blt_blu_arrow.png" width="6" height="5" alt="" /><a
href="/about/casestudies">func_lang("CaseStudies")</a><span class="txtDivider">|</span><a href="/about/quotesarchive"
title="func_lang('Seemore quotes')">func_lang("More Quotes")</a><span class="txtDivider">|</span><a href="/about/users"
title="Seefeatured users">func_lang("Featured Users")</a> 
                       </div>
                     </div>
                   </div>
@@ -42,17 +42,17 @@
         </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="/layout/images/en/hdr_latestreleases.png" width="120" height="10" alt="func_lang('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> 
+             <b>{version}:</b> <a href="/ftp/source/v{version}">func_lang("Source")</a> · <a
href="/ftp/binary/v{version}">func_lang("Binary")</a>· <a
href="/docs/{majorver}/static/{relnotes}">func_lang("Notes")</a>
               <br />
 <!-- END front_release_loop -->
             </div>
-            <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 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">func_lang("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="/layout/images/en/hdr_shortcuts.png" width="85" height="10" alt="func_lang('Shortcuts')"
/></h2>
             <div id="pgFrontShortcutsWrap">
               <ul id="pgFrontShortcutsList">
                 <li>
@@ -80,7 +80,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="/layout/images/en/hdr_supportus.png" width="81" height="10" alt="func_lang('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>").
@@ -91,7 +91,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="/layout/images/en/hdr_latestnews.png" width="90" height="10" alt="func_lang('Latest News')" />
            </a>
            <div class="pgNewsEventsWrap">
              <!-- INCLUDE about/news-index-loop.html -->
@@ -113,7 +113,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="/layout/images/en/hdr_planetpg.png" width="140" height="10" alt="func_lang('Planet PostgreSQL')"
/>
             </a>
             <div id="pgFrontPlanetWrap">
               <!-- BEGIN planet_loop -->
@@ -137,13 +137,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="/layout/images/en/hdr_upcomingevents.png" width="123" height="10" alt="func_lang('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="/layout/images/en/hdr_upcomingtraining.png" alt="func_lang('Upcoming training')" />
            </a>
            <div class="pgNewsEventsWrap">
              <div id="pgFrontTrainingSummary">
Index: .htaccess
===================================================================
--- .htaccess    (révision 1995)
+++ .htaccess    (copie de travail)
@@ -3,18 +3,15 @@
 AddDefaultCharset utf-8

 # Pear modules
-php_value include_path "/usr/local/www/portal.postgresql.org/pear/lib:."
+php_value include_path "/usr/share/php:."

 # Fire up mod_rewrite

 RewriteEngine On

-# Disallow access to .svn directories
-RewriteRule /.svn - [F]
-
 # Rewrite every request except those for
 # static files to system/handler.php
-RewriteRule
^(favicon\.ico|admin|template|layout|files|external|system/handler\.php|system/rss\.php|system/redir\.php|system/communityfiles\.php|system/oldsearch\.php|sync_timestamp|web_sync_timestamp|mirrors.xml|robots.txt)
-[L] 
+RewriteRule
^(favicon\.ico|admin|template|layout|files|external|system/handler\.php|system/rss\.php|system/redir\.php|system/communityfiles\.php|sync_timestamp|robots.txt)
-[L] 

 # Redirector
 RewriteRule ^redir$ /system/redir.php [QSA,L]

Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Guillaume Lelarge a écrit :
> I already sent this patch a few months before, but didn't get an answer 
> on it. So, I updated it and hope for the best :)
> 
> Anyways, a few words on one file of this patch. I had to change 
> system/global/pgpage.php in two ways.
> 
> First, to add '.UTF-8' to the locale. Without, I couldn't get any 
> gettext translation to work. I wonder if Adrian had to do the same for 
> his translation. I don't think the way I did it is absolutely right, so 
> I would like comments on this.
> 
> Second, base_href is set to http://www.postgresql.org/, making any links 
> go to the official website. I'm wondering why we didn't use the value of 
> $_SETTINGS['hosted_url'] for example as it can be a local setting.
> 
> Any comments ? better ways to solve these ?
> 

I forgot something. "tools/schema.sql" seems to be the schema of the 
pgweb database. Unfortunately, it doesn't seem up to date... at least, 
the organisation column is missing on the events table.


-- 
Guillaume. http://www.postgresqlfr.org http://dalibo.com


Re: Patch to make some strings available to translations

От
Magnus Hagander
Дата:
Guillaume Lelarge wrote:
> Guillaume Lelarge a écrit :
>> I already sent this patch a few months before, but didn't get an 
>> answer on it. So, I updated it and hope for the best :)
>>
>> Anyways, a few words on one file of this patch. I had to change 
>> system/global/pgpage.php in two ways.
>>
>> First, to add '.UTF-8' to the locale. Without, I couldn't get any 
>> gettext translation to work. I wonder if Adrian had to do the same for 
>> his translation. I don't think the way I did it is absolutely right, 
>> so I would like comments on this.
>>
>> Second, base_href is set to http://www.postgresql.org/, making any 
>> links go to the official website. I'm wondering why we didn't use the 
>> value of $_SETTINGS['hosted_url'] for example as it can be a local 
>> setting.
>>
>> Any comments ? better ways to solve these ?
>>
> 
> I forgot something. "tools/schema.sql" seems to be the schema of the 
> pgweb database. Unfortunately, it doesn't seem up to date... at least, 
> the organisation column is missing on the events table.

Yeah, that's a known problem. I'm working with JD (I hope) to get it set 
up so it'll automatically be committed there from the production db.

//Magnus


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Magnus Hagander a écrit :
> Guillaume Lelarge wrote:
>> Guillaume Lelarge a écrit :
>>> I already sent this patch a few months before, but didn't get an 
>>> answer on it. So, I updated it and hope for the best :)
>>>
>>> Anyways, a few words on one file of this patch. I had to change 
>>> system/global/pgpage.php in two ways.
>>>
>>> First, to add '.UTF-8' to the locale. Without, I couldn't get any 
>>> gettext translation to work. I wonder if Adrian had to do the same 
>>> for his translation. I don't think the way I did it is absolutely 
>>> right, so I would like comments on this.
>>>
>>> Second, base_href is set to http://www.postgresql.org/, making any 
>>> links go to the official website. I'm wondering why we didn't use the 
>>> value of $_SETTINGS['hosted_url'] for example as it can be a local 
>>> setting.
>>>
>>> Any comments ? better ways to solve these ?
>>>
>>
>> I forgot something. "tools/schema.sql" seems to be the schema of the 
>> pgweb database. Unfortunately, it doesn't seem up to date... at least, 
>> the organisation column is missing on the events table.
> 
> Yeah, that's a known problem. I'm working with JD (I hope) to get it set 
> up so it'll automatically be committed there from the production db.
> 

OK. Can you send me an updated schema.sql so that I can better work on 
the website' translation issues ? Thanks.


-- 
Guillaume. http://www.postgresqlfr.org http://dalibo.com


Re: Patch to make some strings available to translations

От
Magnus Hagander
Дата:
Guillaume Lelarge wrote:
> Hi,
> 
> I already sent this patch a few months before, but didn't get an answer 
> on it. So, I updated it and hope for the best :)
> 
> Anyways, a few words on one file of this patch. I had to change 
> system/global/pgpage.php in two ways.
> 
> First, to add '.UTF-8' to the locale. Without, I couldn't get any 
> gettext translation to work. I wonder if Adrian had to do the same for 
> his translation. I don't think the way I did it is absolutely right, so 
> I would like comments on this.

Good question. I *think* it's correct since it has to match a locale on 
the machine, which does require .UTF-8.

Anybody else?


> Second, base_href is set to http://www.postgresql.org/, making any links 
> go to the official website. I'm wondering why we didn't use the value of 
> $_SETTINGS['hosted_url'] for example as it can be a local setting.

This is intentional. If you end up on wwwmaster by a link, you should 
automatically be sent back to the www mirrors.

You can control this by setting the ISMASTER variable from your apache 
configuration. Set it to "1" and there will be no base href set. For 
example, the config on wwwmaster has:

# When accessed locally, don't set BASE HREF, because that would break
# the static mirrors. When accessed dynamically, set it so we don't
# load the dynamic server with static requests.        SetEnvIf Remote_Addr "^(127|217\.196\.146\.204)" ISMASTER=1


In the apache config.

> Any comments ? better ways to solve these ?

I assume it's a typo that you included a patch for .htaccess there? If 
not, then that part certainly looks wrong :-)

I assume you have tested that once these things are changed, 
translations of them actually work? I'm particularly wondering about the 
parts where there are template tags inside the translation.

//Magnus


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Magnus Hagander a écrit :
> Guillaume Lelarge wrote:
>> [...]
>> Second, base_href is set to http://www.postgresql.org/, making any 
>> links go to the official website. I'm wondering why we didn't use the 
>> value of $_SETTINGS['hosted_url'] for example as it can be a local 
>> setting.
> 
> This is intentional. If you end up on wwwmaster by a link, you should 
> automatically be sent back to the www mirrors.
> 
> You can control this by setting the ISMASTER variable from your apache 
> configuration. Set it to "1" and there will be no base href set. For 
> example, the config on wwwmaster has:
> 
> # When accessed locally, don't set BASE HREF, because that would break
> # the static mirrors. When accessed dynamically, set it so we don't
> # load the dynamic server with static requests.
>         SetEnvIf Remote_Addr "^(127|217\.196\.146\.204)" ISMASTER=1
> 
> 
> In the apache config.
> 

OK, works great with this.

>  > Any comments ? better ways to solve these ?
> 
> I assume it's a typo that you included a patch for .htaccess there? If 
> not, then that part certainly looks wrong :-)
> 

You're right, it's a typo. Sorry about this.

> I assume you have tested that once these things are changed, 
> translations of them actually work? I'm particularly wondering about the 
> parts where there are template tags inside the translation.
> 

Actually, I didn't check all strings. Strictly speaking about the parts 
with template tags, I did it because I've seen other parts with template 
tags within a func_lang function call. I'll check more deeply... but I 
think it will be harder because many of them depend on the search 
functionality. Anyways, I'm working on it...

Thanks for your comments.


-- 
Guillaume. http://www.postgresqlfr.org http://dalibo.com


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Seems my mail didn't go through, probably because of my big attachment.
I'm sending it again, but compressed this time.

Guillaume Lelarge a écrit :
> Magnus Hagander a écrit :
>> I assume you have tested that once these things are changed,
>> translations of them actually work? I'm particularly wondering about
>> the parts where there are template tags inside the translation.
>>
>
> Actually, I didn't check all strings. Strictly speaking about the parts
> with template tags, I did it because I've seen other parts with template
> tags within a func_lang function call. I'll check more deeply... but I
> think it will be harder because many of them depend on the search
> functionality. Anyways, I'm working on it...
>

OK, so, I tested the template tags inside translation and it works  :)

But, to be honest, title and alt strings weren't translatable with my
previous patch. Here is a new one which fixes this (and include the
other one, without the .htaccess)..

Next work... translatable images.


--
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com

Вложения

Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Guillaume Lelarge a écrit :
> [...]
> Next work... translatable images.
> 

I found a way to get translatables images but I can't stop thinking this 
is an ugly *ugly* hack. Here is my idea : using the func_lang on the 
href part of the img tag. For example, here is a part of the patch :

-                    <h2><img 
src="/layout/images/en/hdr_featureduser.png" width="104" height="10" 
alt="Featured User" /></h2>
+                    <h2><img 
src=func_lang("'/layout/images/en/hdr_featureduser.png'") width="104" 
height="10" alt=func_lang("'Featured User'") /></h2>

This way, each translation can add a specific path and a specific 
filename. Perhaps, we can only use the path. In my tests, I use 
/layout/images/fr instead of /layout/images/en.

Do you have any comments on this dirty idea ? :) if you think this is 
something doable, I can quickly build a small patch.

But my real issue is doing the actual images... I'm not good a this :)


-- 
Guillaume. http://www.postgresqlfr.org http://dalibo.com


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Magnus Hagander a écrit :
> Guillaume Lelarge wrote:
>> Guillaume Lelarge a écrit :
>>> [...]
>>> Next work... translatable images.
>>>
>>
>> I found a way to get translatables images but I can't stop thinking 
>> this is an ugly *ugly* hack. Here is my idea : using the func_lang on 
>> the href part of the img tag. For example, here is a part of the patch :
>>
>> -                    <h2><img 
>> src="/layout/images/en/hdr_featureduser.png" width="104" height="10" 
>> alt="Featured User" /></h2>
>> +                    <h2><img 
>> src=func_lang("'/layout/images/en/hdr_featureduser.png'") width="104" 
>> height="10" alt=func_lang("'Featured User'") /></h2>
>>
>> This way, each translation can add a specific path and a specific 
>> filename. Perhaps, we can only use the path. In my tests, I use 
>> /layout/images/fr instead of /layout/images/en.
>>
>> Do you have any comments on this dirty idea ? :) if you think this is 
>> something doable, I can quickly build a small patch.
> 
> I don't like it at all.
> 

Yep, I guess it couldn't be that simple :)

> I think we need something like func_image('hdr_featureduser.png'), and 
> then have the framework take care of that one.
> 

Which means we need to modify the framework ? that'll be a much bigger 
work than what I intended to do. Anyways, I'll get a look at it.

>> But my real issue is doing the actual images... I'm not good a this :)
> 
> That's another problem. It requires non-free fonts... See the archives :-(
> 

Yes, I remember this.

> Perhaps this is a good time to try to find a free font that can do what 
> we need.
> 

+1


-- 
Guillaume. http://www.postgresqlfr.org http://dalibo.com


Re: Patch to make some strings available to translations

От
Magnus Hagander
Дата:
Guillaume Lelarge wrote:
> Guillaume Lelarge a écrit :
>> [...]
>> Next work... translatable images.
>>
> 
> I found a way to get translatables images but I can't stop thinking this 
> is an ugly *ugly* hack. Here is my idea : using the func_lang on the 
> href part of the img tag. For example, here is a part of the patch :
> 
> -                    <h2><img 
> src="/layout/images/en/hdr_featureduser.png" width="104" height="10" 
> alt="Featured User" /></h2>
> +                    <h2><img 
> src=func_lang("'/layout/images/en/hdr_featureduser.png'") width="104" 
> height="10" alt=func_lang("'Featured User'") /></h2>
> 
> This way, each translation can add a specific path and a specific 
> filename. Perhaps, we can only use the path. In my tests, I use 
> /layout/images/fr instead of /layout/images/en.
> 
> Do you have any comments on this dirty idea ? :) if you think this is 
> something doable, I can quickly build a small patch.

I don't like it at all.

I think we need something like func_image('hdr_featureduser.png'), and 
then have the framework take care of that one.


> But my real issue is doing the actual images... I'm not good a this :)

That's another problem. It requires non-free fonts... See the archives :-(

Perhaps this is a good time to try to find a free font that can do what 
we need.


//Magnus


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Guillaume Lelarge a écrit :
> Magnus Hagander a écrit :
> [...]
>> I think we need something like func_image('hdr_featureduser.png'), and 
>> then have the framework take care of that one.
>>
> 
> Which means we need to modify the framework ? that'll be a much bigger 
> work than what I intended to do. Anyways, I'll get a look at it.
> 

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).


-- 
Guillaume. http://www.postgresqlfr.org http://dalibo.com


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Guillaume Lelarge a écrit :
> Guillaume Lelarge a écrit :
>> Magnus Hagander a écrit :
>> [...]
>>> I think we need something like func_image('hdr_featureduser.png'),
>>> and then have the framework take care of that one.
>>>
>>
>> Which means we need to modify the framework ? that'll be a much bigger
>> work than what I intended to do. Anyways, I'll get a look at it.
>>
>
> 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).
>

And now with the patch... sorry about this...


--
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,12 @@
 // $Id: pgpage.php,v 1.6 2007-10-21 17:20:07 mastermind Exp $
 // Base-class for all pages
 //
+
+function getimage($arg) {
+  global $pgpage;
+  return '"/layout/images/'.$pgpage->getLanguage().'/'.$arg.'"';
+}
+
 abstract class PgPage {
    protected $language;
    protected $language_direction;
@@ -87,6 +93,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 +111,10 @@
        header('Content-Language: ' . $this->language);
    }

+   public function getLanguage() {
+     return $this->language;
+   }
+
    private function getLanguageFromHeaders() {
        global $_LANGUAGES;

@@ -122,6 +133,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">

Re: Patch to make some strings available to translations

От
Alvaro Herrera
Дата:
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.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
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">

Re: Patch to make some strings available to translations

От
Magnus Hagander
Дата:
On Sat, 22 Mar 2008 22:52:17 +0100
Guillaume Lelarge <guillaume@lelarge.info> wrote:

> 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.

Applied, thanks.

Can you please re-send the patch with the other translation stuff? I've
managed to mess up the different versions of it so I'm no longer sure
I'm working off the correct one :-(

//Magnus


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Magnus Hagander a écrit :
> On Sat, 22 Mar 2008 22:52:17 +0100
> Guillaume Lelarge <guillaume@lelarge.info> wrote:
>
>> 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.
>
> Applied, thanks.
>

Thanks a lot.

> Can you please re-send the patch with the other translation stuff? I've
> managed to mess up the different versions of it so I'm no longer sure
> I'm working off the correct one :-(
>

Here it is. Thanks for looking at it.


--
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com

Вложения

Re: Patch to make some strings available to translations

От
Magnus Hagander
Дата:
Guillaume Lelarge wrote:
> Magnus Hagander a écrit :
> > On Sat, 22 Mar 2008 22:52:17 +0100
> > Guillaume Lelarge <guillaume@lelarge.info> wrote:
> >
> >> 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.
> >
> > Applied, thanks.
> >
>
> Thanks a lot.
>
> > Can you please re-send the patch with the other translation stuff?
> > I've managed to mess up the different versions of it so I'm no
> > longer sure I'm working off the correct one :-(
> >
>
> Here it is. Thanks for looking at it.
>
>
> --
> Guillaume.
>   http://www.postgresqlfr.org
>   http://dalibo.com


This patch no longer applies :-(

The change to pgpage.php was in your other patch.

There's a whole bunch of conflicts in index.html.

Also, the page as generated does not come out as XHTML valid. This is
because you changed it to use ' instead of " for some attributes, and
when there is ' in the text (The world's most advanced...), the HTML is
broken. I'd really like a way to keep the "s on the tags instead of ',
so please see if you can find some way for that :-)

//Magnus


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Magnus Hagander a écrit :
> [...]
> This patch no longer applies :-(
> 
> The change to pgpage.php was in your other patch.
> 

Fixed.

> There's a whole bunch of conflicts in index.html.
> 

Fixed.

> Also, the page as generated does not come out as XHTML valid. This is
> because you changed it to use ' instead of " for some attributes, and
> when there is ' in the text (The world's most advanced...), the HTML is
> broken. I'd really like a way to keep the "s on the tags instead of ',
> so please see if you can find some way for that :-)
> 

I tried but didn't get any interesting results. Will try again, perhaps 
I'll have a better idea this time.


-- 
Guillaume. http://www.postgresqlfr.org http://dalibo.com


Re: Patch to make some strings available to translations

От
Magnus Hagander
Дата:
Guillaume Lelarge wrote:
> Magnus Hagander a écrit :
> > [...]
> > This patch no longer applies :-(
> >
> > The change to pgpage.php was in your other patch.
> >
>
> Fixed.
>
> > There's a whole bunch of conflicts in index.html.
> >
>
> Fixed.

Great.


> > Also, the page as generated does not come out as XHTML valid. This
> > is because you changed it to use ' instead of " for some
> > attributes, and when there is ' in the text (The world's most
> > advanced...), the HTML is broken. I'd really like a way to keep the
> > "s on the tags instead of ', so please see if you can find some way
> > for that :-)
> >
>
> I tried but didn't get any interesting results. Will try again,
> perhaps I'll have a better idea this time.

It'd really be better if it could be done. If it's not possible, then
it's not possible, but I just have a feeling there has to be *some* way
to deal with it.

//Magnus


Re: Patch to make some strings available to translations

От
Guillaume Lelarge
Дата:
Magnus Hagander a écrit :
> Guillaume Lelarge wrote:
>> Magnus Hagander a écrit :
> [...]
>>> Also, the page as generated does not come out as XHTML valid. This
>>> is because you changed it to use ' instead of " for some
>>> attributes, and when there is ' in the text (The world's most
>>> advanced...), the HTML is broken. I'd really like a way to keep the
>>> "s on the tags instead of ', so please see if you can find some way
>>> for that :-)
>>>
>> I tried but didn't get any interesting results. Will try again,
>> perhaps I'll have a better idea this time.
>
> It'd really be better if it could be done. If it's not possible, then
> it's not possible, but I just have a feeling there has to be *some* way
> to deal with it.
>

I really don't know why I didn't think about this. Anyways, done. See
attached patch.


--
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com

Вложения