Index: /trunk/about.php
===================================================================
--- /trunk/about.php	(revision 5207)
+++ /trunk/about.php	(revision 5208)
@@ -40,5 +40,5 @@
 
 /**
- * set in ./language/en_UK.iso-8859-1/local.lang.php (maybe to create)
+ * set in ./local/language/en_UK.lang.php (maybe to create)
  * for example for clear theme:
   $lang['Theme: clear'] = 'This is the clear theme based on yoga template. '.
Index: /trunk/include/common.inc.php
===================================================================
--- /trunk/include/common.inc.php	(revision 5207)
+++ /trunk/include/common.inc.php	(revision 5208)
@@ -137,5 +137,5 @@
 }
 trigger_action('loading_lang');
-load_language('local.lang', '', array('no_fallback'=>true) );
+load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
 
 // only now we can set the localized username of the guest user (and not in
Index: /trunk/include/config_default.inc.php
===================================================================
--- /trunk/include/config_default.inc.php	(revision 5207)
+++ /trunk/include/config_default.inc.php	(revision 5208)
@@ -475,4 +475,9 @@
 // better performance.
 $conf['template_compile_check'] = true;
+
+// This forces Smarty to (re)compile templates on every invocation. This is
+// handy for development and debugging. It should never be used in a
+// production environment.
+$conf['template_force_compile'] = false;
 
 // this permit to show the php errors reporting (see INI 'error_reporting'
Index: /trunk/include/functions.inc.php
===================================================================
--- /trunk/include/functions.inc.php	(revision 5207)
+++ /trunk/include/functions.inc.php	(revision 5208)
@@ -584,5 +584,5 @@
     load_language('common.lang');
     trigger_action('loading_lang');
-    load_language('local.lang', '', array('no_fallback'=>true) );
+    load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
     $template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme());
   }
@@ -1169,4 +1169,5 @@
  *     target_charset -
  *     no_fallback - the language must be respected
+ *     local - if true, get local language file
  * @return boolean success status or a string if options['return'] is true
  */
@@ -1218,5 +1219,8 @@
   foreach ($languages as $language)
   {
-    $f = $dirname.$language.'/'.$filename;
+    $f = @$options['local'] ?
+      $dirname.$language.'.'.$filename:
+      $dirname.$language.'/'.$filename;
+
     if (file_exists($f))
     {
Index: /trunk/include/functions_mail.inc.php
===================================================================
--- /trunk/include/functions_mail.inc.php	(revision 5207)
+++ /trunk/include/functions_mail.inc.php	(revision 5208)
@@ -256,5 +256,7 @@
     load_language('admin.lang', '', array('language'=>$language) );
     trigger_action('loading_lang');
-    load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true));
+    load_language('lang', PHPWG_ROOT_PATH.'local/',
+      array('language'=>$language, 'no_fallback'=>true, 'local'=>true)
+    );
 
     $switch_lang['language'][$language]['lang_info'] = $lang_info;
Index: /trunk/include/template.class.php
===================================================================
--- /trunk/include/template.class.php	(revision 5207)
+++ /trunk/include/template.class.php	(revision 5208)
@@ -50,5 +50,6 @@
     $this->smarty = new Smarty;
     $this->smarty->debugging = $conf['debug_template'];
-    $this->smarty->compile_check=$conf['template_compile_check'];
+    $this->smarty->compile_check = $conf['template_compile_check'];
+    $this->smarty->force_compile = $conf['template_force_compile'];
 
     $compile_dir = $conf['local_data_dir'].'/templates_c';
@@ -71,5 +72,8 @@
     $this->smarty->template_dir = array();
     if ( !empty($theme) )
+    {
       $this->set_theme($root, $theme, $path);
+      $this->set_prefilter( 'header', array('Template', 'prefilter_local_css') );
+    }
     else
       $this->set_template_dir($root);
@@ -546,4 +550,28 @@
     return $source;
   }
+
+  static function prefilter_local_css($source, &$smarty)
+  {
+    $css = array();
+
+    foreach ($smarty->get_template_vars('themes') as $theme)
+    {
+      if (file_exists(PHPWG_ROOT_PATH.'local/css/'.$theme['id'].'-rules.css'))
+      {
+        array_push($css, '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}local/css/'.$theme['id'].'-rules.css">');
+      }
+    }
+    if (file_exists(PHPWG_ROOT_PATH.'local/css/rules.css'))
+    {
+      array_push($css, '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}local/css/rules.css">');
+    }
+
+    if (!empty($css))
+    {
+      $source = str_replace("\n</head>", "\n".implode( "\n", $css )."\n</head>", $source);
+    }
+
+    return $source;
+  }
 }
 
Index: /trunk/local/config/index.php
===================================================================
--- /trunk/local/config/index.php	(revision 5208)
+++ /trunk/local/config/index.php	(revision 5208)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /trunk/local/css/index.php
===================================================================
--- /trunk/local/css/index.php	(revision 5208)
+++ /trunk/local/css/index.php	(revision 5208)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /trunk/local/index.php
===================================================================
--- /trunk/local/index.php	(revision 5208)
+++ /trunk/local/index.php	(revision 5208)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /trunk/local/language/index.php
===================================================================
--- /trunk/local/language/index.php	(revision 5208)
+++ /trunk/local/language/index.php	(revision 5208)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /trunk/nbm.php
===================================================================
--- /trunk/nbm.php	(revision 5207)
+++ /trunk/nbm.php	(revision 5208)
@@ -35,5 +35,5 @@
 // Need to update a second time
 trigger_action('loading_lang');
-load_language('local.lang', '', array('no_fallback'=>true) );
+load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
 
 
Index: /trunk/plugins/language_switch/language_switch.inc.php
===================================================================
--- /trunk/plugins/language_switch/language_switch.inc.php	(revision 5207)
+++ /trunk/plugins/language_switch/language_switch.inc.php	(revision 5208)
@@ -50,5 +50,7 @@
     if ( $same !== $user['language']) {
       load_language('common.lang', '', array('language'=>$user['language']) );
-      load_language('local.lang', '', array('language'=>$user['language'], 'no_fallback'=>true) );
+      load_language('lang', PHPWG_ROOT_PATH.'local/',
+        array('language'=>$user['language'], 'no_fallback'=>true, 'local'=>true)
+      );
       if (defined('IN_ADMIN') and IN_ADMIN) { // Never currently
         load_language('admin.lang', '', array('language'=>$user['language']) );
