summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/main.inc30
-rw-r--r--program/include/rcube_shared.inc15
2 files changed, 39 insertions, 6 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index d00efc747..0ebbeaa5a 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -226,7 +226,7 @@ function get_table_name($table)
// init output object for GUI and add common scripts
function load_gui()
{
- global $CONFIG, $OUTPUT, $COMM_PATH, $IMAP, $JS_OBJECT_NAME;
+ global $CONFIG, $OUTPUT, $COMM_PATH, $JS_OBJECT_NAME, $sess_user_lang;
// init output page
$OUTPUT = new rcube_html_page();
@@ -237,13 +237,35 @@ function load_gui()
if (!empty($GLOBALS['_framed']))
$javascript .= "$JS_OBJECT_NAME.set_env('framed', true);\n";
-
+
$OUTPUT->add_script($javascript);
$OUTPUT->include_script('program/js/common.js');
- $OUTPUT->include_script('program/js/app.js');
+ $OUTPUT->include_script('program/js/app.js');
+
+ // set user-selected charset
+ if ($CONFIG['charset'])
+ $OUTPUT->set_charset($CONFIG['charset']);
+ else
+ rcmail_set_locale($sess_user_lang);
}
+// set localization charset based on the given language
+function rcmail_set_locale($lang)
+ {
+ global $OUTPUT, $INSTLL_PATH;
+ static $rcube_charsets;
+
+ if (!$rcube_charsets)
+ @include($INSTLL_PATH.'program/localization/index.inc');
+
+ if (isset($rcube_charsets[$lang]))
+ $OUTPUT->set_charset($rcube_charsets[$lang]);
+ else
+ $OUTPUT->set_charset('ISO-8859-1');
+ }
+
+
// perfom login to the IMAP server and to the webmail service
function rcmail_login($user, $pass, $host=NULL)
{
@@ -447,7 +469,7 @@ function rcube_list_languages()
if (!sizeof($sa_languages))
{
- @include_once($INSTLL_PATH.'program/localization/index.inc');
+ @include($INSTLL_PATH.'program/localization/index.inc');
if ($dh = @opendir($INSTLL_PATH.'program/localization'))
{
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index c0df2e585..edf19b66e 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -29,6 +29,7 @@ class rcube_html_page
var $scripts_path = '';
var $script_files = array();
var $scripts = array();
+ var $charset = 'ISO-8859-1';
var $script_tag_file = "<script type=\"text/javascript\" src=\"%s%s\"></script>\n";
var $script_tag = "<script type=\"text/javascript\">\n<!--\n%s\n\n//-->\n</script>\n";
@@ -82,6 +83,11 @@ class rcube_html_page
}
+ function set_charset($charset)
+ {
+ $this->charset = $charset;
+ }
+
function write($templ='', $base_path='')
{
@@ -94,6 +100,11 @@ class rcube_html_page
// replace specialchars in content
$__page_title = rep_specialchars_output($this->title, 'html', 'show', FALSE);
$__page_header = $__page_body = $__page_footer = '';
+
+
+ // include meta tag with charset
+ if (!empty($this->charset))
+ $__page_header = '<meta http-equiv="content-type" content="text/html; charset='.$this->charset.'" />'."\n";;
// definition of the code to be placed in the document header and footer
@@ -1031,7 +1042,7 @@ function rcube_browser()
// get text in the desired language from the language file
function rcube_label($attrib)
{
- global $sess_user_lang, $INSTALL_PATH;
+ global $sess_user_lang, $INSTALL_PATH, $OUTPUT;
static $sa_text_data, $s_language, $utf8_decode;
// extract attributes
@@ -1195,7 +1206,7 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
{
if (!$html_encode_arr)
{
- $html_encode_arr = get_html_translation_table(HTML_ENTITIES);
+ $html_encode_arr = get_html_translation_table(HTML_ENTITIES); // HTML_SPECIALCHARS
$html_encode_arr[chr(128)] = '&euro;';
unset($html_encode_arr['?']);
unset($html_encode_arr['&']);