<?php
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: PN boys and girls band
// Purpose of file: language API
// ----------------------------------------------------------------------
// language init traiement
// =======================
if (isset($newlang))
{
if (file_exists("language/$newlang/global.php"))
{
setcookie("lang",$newlang,time()+31536000);
include("language/$newlang/global.php");
$currentlang = $newlang;
}
else
{
setcookie("lang",$language,time()+31536000);
include("language/$language/global.php");
$currentlang = $language;
}
}
elseif (isset ($lang) && file_exists("language/$lang/global.php"))
{
include("language/$lang/global.php");
$currentlang = $lang;
}
else
{
// language file not found, use site default
setcookie("lang",$language,time()+31536000);
include("language/$language/global.php");
$currentlang = $language;
}
// Make common language selection dropdown (from Tim Litwiller)
// =======================================
function lang_dropdown()
{
global $currentlang;
echo "<select name=\"alanguage\" class=\"pn-text\">";
$lang = languagelist();
print "<option value=\"\">"._ALL.'</option>';
$handle = opendir('language');
while ($f = readdir($handle))
{
if (is_dir("language/$f") && @$lang[$f])
{
$langlist[$f] = $lang[$f];
}
}
asort($langlist);
foreach ($langlist as $k=>$v)
{
echo '<option value="'.$k.'"';
if ( $currentlang == $k)
{
echo ' selected';
}
echo '>'. $v . '</option> ';
}
echo "</select>";
}
// Loads the required language file for module (from Patrick Kellum <hide@address.com>)
// ===========================================
function modules_get_language($script = 'global')
{
global $ModName, $currentlang;
if (file_exists("modules/$ModName/lang/$currentlang/$script.php"))
{
@include "modules/$ModName/lang/$currentlang/$script.php";
}
elseif (!empty($language))
{
if (file_exists("modules/$ModName/lang/$language/$script.php"))
{
@include "modules/$ModName/lang/$language/$script.php";
}
}
else
{
@include "modules/$ModName/lang/eng/$script.php";
}
return ;
}
// Loads the required language file for themes (from Patrick Kellum <hide@address.com>)
// ===========================================
function themes_get_language($script = 'global')
{
global $Default_Theme,$currentlang,$thename;
if (file_exists($file="themes/$thename/lang/$currentlang/$script.php"))
@include $file;
elseif (file_exists($file="themes/$thename/lang/eng/$script.php"))
@include $file;
elseif (file_exists($file="themes/$Default_Theme/lang/$currentlang/$script.php"))
@include $file;
elseif (file_exists($file="themes/$Default_Theme/lang/eng/$script.php"))
@include $file;
}
// list of all availabe languages (from Patrick Kellum <hide@address.com>)
// ==============================
function languagelist()
{
// All entries use ISO 639-2/T
$lang['ara'] = _LANGUAGE_ARA; // Arabic
$lang['bul'] = _LANGUAGE_BUL; // Bulgarian
$lang['zho'] = _LANGUAGE_ZHO; // Chinese
$lang['ces'] = _LANGUAGE_CES; // Czech
$lang['cro'] = _LANGUAGE_CRO; // Croatian
$lang['dan'] = _LANGUAGE_DAN; // Danish
$lang['nld'] = _LANGUAGE_NLD; // Dutch
$lang['eng'] = _LANGUAGE_ENG; // English
$lang['epo'] = _LANGUAGE_EPO; // Esperanto
$lang['est'] = _LANGUAGE_EST; // Estonian
$lang['fin'] = _LANGUAGE_FIN; // Finnish
$lang['fra'] = _LANGUAGE_FRA; // French
$lang['deu'] = _LANGUAGE_DEU; // German
$lang['ell'] = _LANGUAGE_ELL; // Greek, Modern (1453-)
$lang['heb'] = _LANGUAGE_HEB; // Hebrew
$lang['hun'] = _LANGUAGE_HUN; // Hungarian
$lang['isl'] = _LANGUAGE_ISL; // Icelandic
$lang['ind'] = _LANGUAGE_IND; // Indonesian
$lang['ita'] = _LANGUAGE_ITA; // Italian
$lang['jpn'] = _LANGUAGE_JPN; // Japanese
$lang['kor'] = _LANGUAGE_KOR; // Korean
$lang['lav'] = _LANGUAGE_LAV; // Latvian
$lang['lit'] = _LANGUAGE_LIT; // Lithuanian
$lang['mas'] = _LANGUAGE_MAS; // Malay
$lang['nor'] = _LANGUAGE_NOR; // Norwegian
$lang['pol'] = _LANGUAGE_POL; // Polish
$lang['por'] = _LANGUAGE_POR; // Portuguese
$lang['ron'] = _LANGUAGE_RON; // Romanian
$lang['rus'] = _LANGUAGE_RUS; // Russian
$lang['x_rus_koi8r'] = _LANGUAGE_X_RUS_KOI8R; // Russian KOI8-R
$lang['slv'] = _LANGUAGE_SLV; // Slovenian
$lang['spa'] = _LANGUAGE_SPA; // Spanish
$lang['swe'] = _LANGUAGE_SWE; // Swedish
$lang['tha'] = _LANGUAGE_THA; // Thai
$lang['tur'] = _LANGUAGE_TUR; // Turkish
$lang['ukr'] = _LANGUAGE_UKR; // Ukrainian
$lang['yid'] = _LANGUAGE_YID; // Yiddish
// Non-ISO entries are written as x_[language name]
$lang['x_all'] = _ALL; // all languages
$lang['x_brazilian_portuguese'] = _LANGUAGE_X_BRAZILIAN_PORTUGUESE; // Brazilian Portuguese
$lang['x_klingon'] = _LANGUAGE_X_KLINGON; // Klingon
// end of list
return $lang;
}
// format a time/date according to current language settings (from Volodymyr Metenchuk <hide@address.com>)
function ml_ftime($datefmt, $timestamp = -1)
{
if ($timestamp == -1)
{
$timestamp = time();
}
$day_of_week_short = explode(' ', _DAY_OF_WEEK_SHORT);
$month_short = explode(' ', _MONTH_SHORT);
$day_of_week_long = explode(' ', _DAY_OF_WEEK_LONG);
$month_long = explode(' ', _MONTH_LONG);
$ml_date = ereg_replace('%a',$day_of_week_short[(int)strftime('%w',$timestamp)],$datefmt);
$ml_date = ereg_replace('%A',$day_of_week_long[(int)strftime('%w',$timestamp)],$ml_date);
$ml_date = ereg_replace('%b',$month_short[(int)strftime('%m',$timestamp)-1],$ml_date);
$ml_date = ereg_replace('%B',$month_long[(int)strftime('%m',$timestamp)-1],$ml_date);
return strftime($ml_date,$timestamp);
}
?>