Firefox PHP

Language recognition

Posted by Ulf Dunkel 
Language recognition
August 15, 2005 08:17AM
As seen in Phorum 3, Phorum 5 still seems to have the same problems when one uses foreign languages in a setup of different Phorums. In my case, I offer 5 separate Phorums (cz, de, fr, nl and us). The Czech one caused problems as my Apache server sets the default charset to iso-8859-1. Thus, I had to recognize the current language of the Phorum myself (again). In Phorum 5, I did not find another smart way but evaluating the query string. This is, how I enhanced my /templates/myTemplate/header.tpl in order to avoid character garbage.

(Maybe someone knows a smarter but working way or someone can find this posting helpful.)

<?php
$forum_number = $_SERVER['QUERY_STRING'];
$forum_queries = explode(",",$forum_number);
if (!$forum_queries[0])
{
	$forum_queries[0] = $_POST['forum_id'];
}
switch($forum_queries[0])
{
case "8":
  $PHORUM['locale'] = "fr_FR";
  $xml_type = '<?xml version="1.0" encoding="iso-8859-1"?>';
  $lan = "fr"; break;
case "7":
  $PHORUM['locale'] = "CZ";
  $xml_type = '<?xml version="1.0" encoding="windows-1250"?>';
  $lan = "cz"; break;
case "3":
  $PHORUM['locale'] = "nl_NL";
  $xml_type = '<?xml version="1.0" encoding="iso-8859-1"?>';
  $lan = "nl"; break;
case "2":
  $PHORUM['locale'] = "en_EN";
  $xml_type = '<?xml version="1.0" encoding="iso-8859-1"?>';
  $lan = "us"; break;
case "1":
default:
  $PHORUM['locale'] = "de_DE";
  $xml_type = '<?xml version="1.0" encoding="iso-8859-1"?>';
  $lan = "de";
}
if($lan == "cz")
  header("Content-type: text/html;charset=windows-1250");
echo $xml_type;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "DTD/xhtml1-transitional.dtd">
<html lang="<?php echo $PHORUM['locale']; ?>">
<head>
<title>{HTML_TITLE}</title>
{if URL->REDIRECT}
<meta http-equiv="refresh" content="5; url={URL->REDIRECT}" />
{/if}
{LANG_META}
{HEAD_TAGS}
</head>
<body>
<?php
// use and output my own website's framework
include "../lib.php";
html_navigation_2005($lan,"forum");
?>
<div align="{forumalign}">
<div class="PDDiv">
{IF notice_all}
<div class="PhorumNotificationArea PhorumNavBlock">
{IF PRIVATE_MESSAGES->new}
<a class="PhorumNavLink" href="{PRIVATE_MESSAGES->inbox_url}">
{LANG->NewPrivateMessages}</a><br />{/IF}
{IF notice_messages}
<a class="PhorumNavLink" href="{notice_messages_url}">
{LANG->UnapprovedMessagesLong}</a><br />{/IF}
{IF notice_users}
<a class="PhorumNavLink" href="{notice_users_url}">
{LANG->UnapprovedUsersLong}</a><br />{/IF}
{IF notice_groups}
<a class="PhorumNavLink" href="{notice_groups_url}">
{LANG->UnapprovedGroupMembers}</a><br />{/IF}
</div>
{/IF}
{IF NAME}<span class="PhorumTitleText PhorumLargeFont">{NAME}:&nbsp;</span>{/IF}
{IF DESCRIPTION}<div class="PhorumFloatingText">{DESCRIPTION}</div>{/IF}

Regards, Ulf Dunkel
Sorry, only registered users may post in this forum.

Click here to login