From 04b141d467e37b5a0fcba87666ee4d748d4223bd Mon Sep 17 00:00:00 2001
From: garvinhicking <garvinhicking>
Date: Mon, 1 Aug 2005 18:34:14 +0000
Subject: [PATCH] Allow to choose between NATIVE and UTF-8 format.

---
 docs/NEWS                        | 2 ++
 include/lang.inc.php             | 6 +++---
 include/tpl/config_local.inc.php | 7 +++++++
 serendipity_config.inc.php       | 5 +++++
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/docs/NEWS b/docs/NEWS
index 826cd6d..753e669 100644
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,8 @@
 Version 0.9 ()
 ------------------------------------------------------------------------
 
+    * Allow to switch charsets ("Native" / "UTF-8"). (garvinhicking)
+
     * Permissions: The permission "adminImagesViewOthers" now controls
       whether an author is allowed to view images or not. In older Serendipity
       versions, any author could always view any images, but only modify those
diff --git a/include/lang.inc.php b/include/lang.inc.php
index 908d454..7b70946 100644
--- a/include/lang.inc.php
+++ b/include/lang.inc.php
@@ -4,7 +4,7 @@
 
 if (!defined('serendipity_LANG_LOADED') || serendipity_LANG_LOADED !== true) {
     // Try and include preferred language from the configurated setting
-    if (@include(S9Y_INCLUDE_PATH . 'lang/serendipity_lang_'. $serendipity['lang'] .'.inc.php') ) {
+    if (@include(S9Y_INCLUDE_PATH . 'lang/' . $serendipity['charset'] . 'serendipity_lang_'. $serendipity['lang'] .'.inc.php') ) {
         // Only here can we truely say the language is loaded
         define('serendipity_LANG_LOADED', true);
     } elseif (IS_installed === false || (defined('IS_up2date') && IS_up2date === false)) {   /* -- Auto-Guess -- */
@@ -14,7 +14,7 @@ if (!defined('serendipity_LANG_LOADED') || serendipity_LANG_LOADED !== true) {
     }  //endif
 
     // Do fallback to english
-    if ((defined('serendipity_LANG_LOADED') && serendipity_LANG_LOADED === true) || IS_installed === false || (defined('IS_up2date') && IS_up2date === false)) {
+    if (IS_installed === false || (defined('IS_up2date') && IS_up2date === false)) {
         @include_once(S9Y_INCLUDE_PATH . 'lang/serendipity_lang_en.inc.php');
     }
 }
@@ -78,4 +78,4 @@ if (!defined('serendipity_MB_LOADED') && defined('serendipity_LANG_LOADED')) {
 }
 
 /* vim: set sts=4 ts=4 expandtab : */
-?>
+?>
\ No newline at end of file
diff --git a/include/tpl/config_local.inc.php b/include/tpl/config_local.inc.php
index ec8f336..02a0ba9 100644
--- a/include/tpl/config_local.inc.php
+++ b/include/tpl/config_local.inc.php
@@ -326,6 +326,13 @@
                                           'permission'  => 'siteConfiguration',
                                           'flags'       => array('simpleInstall')),
 
+                                    array('var'         => 'charset',
+                                          'title'       => INSTALL_CHARSET,
+                                          'description' => INSTALL_CHARSET_DESC,
+                                          'type'        => 'list',
+                                          'default'     => $serendipity['charsets'],
+                                          'permission'  => 'siteConfiguration'),
+
                                     array('var'         => 'calendar',
                                           'title'       => INSTALL_CAL,
                                           'description' => INSTALL_CAL_DESC,
diff --git a/serendipity_config.inc.php b/serendipity_config.inc.php
index 4e22a83..9f6e33d 100644
--- a/serendipity_config.inc.php
+++ b/serendipity_config.inc.php
@@ -211,6 +211,11 @@ if (defined('DATE_LOCALES')) {
     }
 }
 
+$serendipity['charsets'] = array(
+    '/UTF-8/' => 'UTF-8',
+    ''        => CHARSET_NATIVE
+);
+
 /*
  *   Fallback charset, if none is defined in the language files
  */
-- 
2.39.5