Jeremy Newman : adding a language change URL to homepage

Jeremy Newman jnewman at winehq.org
Mon Dec 8 11:33:01 CST 2008


Module: website
Branch: master
Commit: a84b248918640f2dabbe86d8bc3531f027aeffba
URL:    http://source.winehq.org/git/website.git/?a=commit;h=a84b248918640f2dabbe86d8bc3531f027aeffba

Author: Jeremy Newman <jnewman at codeweavers.com>
Date:   Mon Dec  8 11:29:41 2008 -0600

adding a language change URL to homepage
clean up language selection a bit

---

 include/data.php                             |   12 ++++++++++++
 include/html.php                             |    9 +++++++++
 include/plugins/language.php                 |    2 +-
 include/themes/winehq/content_nobox.template |    4 ++++
 styles.css                                   |   11 +++++++++++
 templates/en/lang.template                   |    4 +++-
 6 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/include/data.php b/include/data.php
index 7c1b92c..c5281d7 100644
--- a/include/data.php
+++ b/include/data.php
@@ -43,6 +43,18 @@ class data
                                  'wwn'
                                 );
 
+        // available languages
+        $this->languages = array(
+                                 'en' => array(
+                                               'name'   => 'English',
+                                               'change' => 'Change Language'
+                                              ),
+                                 'es' => array(
+                                               'name'   => 'Español',
+                                               'change' => 'Cambiar la Lengua'
+                                              )
+                                );
+
         return;
     }
 }
diff --git a/include/html.php b/include/html.php
index 69775e2..3e905b2 100644
--- a/include/html.php
+++ b/include/html.php
@@ -265,6 +265,7 @@ class html
         }
         
         // return language
+        debug("global", "lang: {$lang}");
         return $lang;
     }
 
@@ -1199,6 +1200,14 @@ class html
         $vars['server_name'] =& $_SERVER['SERVER_NAME'];
         $vars['base_url'] =& $GLOBALS['config']->base_url;
         
+        // language vars
+        if (defined("PAGE") and (PAGE == "home" or PAGE == "lang"))
+        {
+            $vars['langCode'] =& $this->lang;
+            $vars['langCur'] =& $GLOBALS['data']->languages[$this->lang]['name'];
+            $vars['langChange'] =& $GLOBALS['data']->languages[$this->lang]['change'];
+        }
+        
         // add config vars
         while (list($key, $val) = each($GLOBALS['config']))
         {
diff --git a/include/plugins/language.php b/include/plugins/language.php
index 8c0bf2e..0291f8b 100644
--- a/include/plugins/language.php
+++ b/include/plugins/language.php
@@ -11,7 +11,7 @@ global $html, $config;
 // if specified, switch to lang
 if (defined('PAGE_PARAMS') and in_array(PAGE_PARAMS, $config->languages))
 {
-    setcookie("lang", PAGE_PARAMS, time()+60*60*24*365);
+    setcookie("lang", PAGE_PARAMS, time()+60*60*24*365, '/');
     $html->redirect($config->base_url);
     exit();
 }
diff --git a/include/themes/winehq/content_nobox.template b/include/themes/winehq/content_nobox.template
index a299357..6842545 100644
--- a/include/themes/winehq/content_nobox.template
+++ b/include/themes/winehq/content_nobox.template
@@ -58,6 +58,10 @@
 
 </div>
 
+<div id="langsel">
+    {$langCur} (<a href="{$root}/lang">{$langChange}</a>)
+</div>
+
 <div id="footer">
     Hosted By
     <a href="http://www.codeweavers.com/"><img src="{$root}/images/cw_logo_sm.png" alt="CodeWeavers"
diff --git a/styles.css b/styles.css
index ac86b2a..b6afc9f 100644
--- a/styles.css
+++ b/styles.css
@@ -154,6 +154,17 @@ BODY                {
                      display: inline;
                     }
 
+/* Language Select */
+#langsel            {
+                     clear: both;
+                     color: #ffffff;
+                     text-align: left;
+                     margin: 0 0 0 110px;
+                     font-size: xx-small;
+                    }
+#langsel A          { color: #ffffff; text-decoration: none; }
+#langsel A:hover    { color: red; text-decoration: underline; }
+
 /* footer */
 #footer             {
                      clear: both;
diff --git a/templates/en/lang.template b/templates/en/lang.template
index 0054a66..2d4b1a7 100644
--- a/templates/en/lang.template
+++ b/templates/en/lang.template
@@ -1,10 +1,12 @@
 <!--TITLE:[WineHQ - Pick your Language]-->
 <!--BLURB:[WineHQ is a multi-lingual website]-->
 
-<h1 class="title">Pick Your Language</h1>
+<h1 class="title">{$langChange}</h1>
 
 <!--EXEC:[language]-->
 
+<p><b>Current Langage: </b> {$langCur}</p>
+
 <blockquote>
 
     <p>




More information about the wine-cvs mailing list