DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • May 19, 2013, 12:43:18 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: Question for non-English server admin  (Read 3941 times)
0 Members and 1 Guest are viewing this topic.
Hidehisa
Guest
« on: April 19, 2005, 11:39:01 PM »

# Attached file for this post is deleted, new version is attached to the replying post

How do you non-English (translated) lotgd server admins handle charset for HTML header ?

You can expect users to set appropriate charset setting or use "auto-detect"in their browser,  but I wanted to send HTML with charset setting to ensure players can see lotgd pages with correct charset setting.

I made a module to insert <meta> tag for charset in HTML (attached to this post). But it needs some new modulehook.

Are there any other way to modify existing page template/output from module?

Needed modification to use this module:
lib/pageparts.php line 56-58
1.0.2 original code:
Code:
  $header = $template['header'];
   $header=str_replace("{title}",$title,$header);
   $header.=tlbutton_pop();

modified:
Code:
  $header = $template['header'];
   $header = array_pop(modulehook("pageheader", array('header'=>$header)));   // Hidehisa
   $header=str_replace("{title}",$title,$header);
   $header.=tlbutton_pop();


lib/pageparts.php line 355-35
1.0.2 original code
Code:
  $header = $template['popuphead'];
   $header = array_pop(modulehook("popupheader", array('header'=>$header)));   // Hidehisa
   $header = str_replace("{title}", $title, $header);

modified code
Code:
  $header = $template['popuphead'];
   $header = array_pop(modulehook("popupheader", array('header'=>$header)));   // Hidehisa
   $header = str_replace("{title}", $title, $header);

« Last Edit: April 22, 2005, 01:30:25 AM by Hidehisa » Logged
Kendaer
Guest
« Reply #1 on: April 20, 2005, 07:54:58 AM »

Hidehisa,

These modifications are not necesary.

The correct solution is to write a module which sets the charset in the HTML header by modifying the $args['headscript'] (seems like the best choice) via the everyfooter hook to specify the meta tags in that way.

If you don't understand what this means, then perhaps one of the intrepid module coders here can help you (or can post a module which allows you to specify the charset).

Basically, in your module, hook on 'everyfooter' and 'footer-popup',
Then in your hook handler do
Code:
case "everyfooter":
case "footer-popup":
        if (!array_key_exists('headscript',$args) || !is_array($args['headscript'])){
            $args['headscript'] = array();
        }
        array_push($args['headscript'], "<meta ........>");
       return $args;
        break;

This lets you do what you want WITHOUT any new module hooks.    
Logged
Hidehisa
Guest
« Reply #2 on: April 20, 2005, 09:21:40 AM »

Thanks Kendaer for nice information.
everfooter and footer-popup hook work fine.

But, some template (Cupertino and redmond) have hardcoded meta tag for charset:
Code:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
So, with these templates, HTML ends up 2 content-type information and browser treats first content-type information and ignores second one.


If I use those hooks, I can't modify existing content, right?

Any other way to modify existing content, or should those templates better their content-type header removed?
Logged
Iwpg
Guest
« Reply #3 on: April 20, 2005, 09:29:55 AM »

Is this actually necessary?  With my unmodfied 1.0.2 install I was able to use all sorts of non-latin characters (including Greek, Cyrillic, Hebrew, Runic, Braille and various others - obviously this depends on having suitable fonts installed Wink ) in chat areas and some of the in-game text using the translator tool.  The places that didn't work seem to be the ones where colour codes are recognised - the characters get displayed as HTML numeric character references.  IMHO it would be better to fix this problem rather than mess around with modules and headers (and I wouldn't mind having a go myself if other people have more important things to do).

In fact, changing the character set might cause more problems without further modification - I'm pretty sure it was the cause of the problem in this thread in the lotgd.net forums.

EDIT: on further experimentation, it seems there are a few more problems - for example, the code to split long words in messages tends to split non-latin characters in the middle, since they're represented internally as character references.  For the same reason, a large page containing a lot of such characters would get pretty big, and may overflow the output field in the database.  Even so though, I still think it would be better to remove these limitations - perhaps by hard-coding UTF-8 as the character set, then making whatever other changes are needed to make that work?
« Last Edit: April 20, 2005, 09:43:45 AM by Iwpg » Logged
Kendaer
Guest
« Reply #4 on: April 20, 2005, 06:25:23 PM »

Thanks Kendaer for nice information.
everfooter and footer-popup hook work fine.

But, some template (Cupertino and redmond) have hardcoded meta tag for charset:
Code:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
So, with these templates, HTML ends up 2 content-type information and browser treats first content-type information and ignores second one.


If I use those hooks, I can't modify existing content, right?

Any other way to modify existing content, or should those templates better their content-type header removed?

Correct that you cannot modify the templates via those hooks.. those templates should have that meta tag removed Smiley
Logged
Hidehisa
Guest
« Reply #5 on: April 22, 2005, 01:30:30 AM »

Thanks for great info.
I removed Content-Type meta header line from Redmond and Cupertino templates and all fine.

Attached to this post is charset module 1.2.
This module works fine and I'm very pleased that I need to edit source code less every version up of LotGD.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
25 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search