ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BBClone/trunk/lib/selectlang.php
Revision: 417
Committed: Wed Dec 21 11:27:14 2022 UTC (23 months, 1 week ago) by joku
File size: 4032 byte(s)
Log Message:
update Copyright 

File Contents

# Content
1 <?php
2 /* This file is part of BBClone (A PHP based Web Counter on Steroids)
3 *
4 * SVN FILE $Id$
5 *
6 * Copyright (C) 2001-2023, the BBClone Team (see doc/authors.txt for details)
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * See doc/copying.txt for details
19 */
20
21 ////////////////////////////////
22 // Detection & Setup Language //
23 ////////////////////////////////
24
25 if (is_readable($BBC_LIB_PATH."html.php")) require_once($BBC_LIB_PATH."html.php");
26 else exit(bbc_msg($BBC_LIB_PATH."html.php"));
27
28 // Initialising the HTML class
29 $BBC_HTML = new BBC_HTML;
30
31 if (is_readable($BBC_LANGUAGE_PATH.$BBC_HTML->lng.".php")) require_once($BBC_LANGUAGE_PATH.$BBC_HTML->lng.".php");
32 // When no detection, use English language as default
33 elseif (is_readable($BBC_LANGUAGE_PATH."en.php")) { require_once($BBC_LANGUAGE_PATH."en.php"); }
34 else exit(bbc_msg($BBC_LANGUAGE_PATH."en.php"));
35
36 /**
37 * Format date/time according to given format string, in the selected language.
38 * param1 $format date format, as per PHP specs
39 * param2 $timestamp the timestamp to format
40 * return String with formatted timestamp
41 */
42 function date_format_translated($format, $timestamp) {
43 global $translation;
44
45 $day_name_short = array($translation['tstat_su'], $translation['tstat_mo'], $translation['tstat_tu'], $translation['tstat_we'], $translation['tstat_th'], $translation['tstat_fr'], $translation['tstat_sa']);
46 $day_name_full = array($translation['tstat_full_su'], $translation['tstat_full_mo'], $translation['tstat_full_tu'], $translation['tstat_full_we'], $translation['tstat_full_th'], $translation['tstat_full_fr'], $translation['tstat_full_sa']);
47 $month_name_short = array($translation['tstat_jan'], $translation['tstat_feb'], $translation['tstat_mar'], $translation['tstat_apr'], $translation['tstat_may'], $translation['tstat_jun'],
48 $translation['tstat_jul'], $translation['tstat_aug'], $translation['tstat_sep'], $translation['tstat_oct'], $translation['tstat_nov'], $translation['tstat_dec']);
49 $month_name_full = array($translation['tstat_full_jan'], $translation['tstat_full_feb'], $translation['tstat_full_mar'], $translation['tstat_full_apr'], $translation['tstat_full_may'], $translation['tstat_full_jun'],
50 $translation['tstat_full_jul'], $translation['tstat_full_aug'], $translation['tstat_full_sep'], $translation['tstat_full_oct'], $translation['tstat_full_nov'], $translation['tstat_full_dec']);
51
52 // Loop char by char through php date format string, cacth the ones which need translating
53 //--- PHP 4 :-)--------------------------------
54 if(!function_exists('str_split')){
55 function str_split($str,$split_lengt=1){
56
57 $cnt = strlen($str);
58
59 for ($i=0;$i<$cnt;$i+=$split_lengt)
60 $rslt[]= substr($str,$i,$split_lengt);
61
62 return $rslt;
63 }
64 }
65 //----------------------------------------------
66 $result = "";
67 $format_chars = str_split($format, 1);
68 foreach ($format_chars as $format_char) {
69 if ($format_char == "l") {
70 $day_index = date("w", $timestamp);
71 $result = $result . $day_name_full[$day_index];
72 } else if ($format_char == "D") {
73 $day_index = date("w", $timestamp);
74 $result = $result . $day_name_short[$day_index];
75 } else if ($format_char == "F") {
76 $month_index = date("n", $timestamp) - 1;
77 $result = $result . $month_name_full[$month_index];
78 } else if ($format_char == "M") {
79 $month_index = date("n", $timestamp) - 1;
80 $result = $result . $month_name_short[$month_index];
81 } else {
82 $result = $result . date($format_char, $timestamp);
83 }
84 }
85
86 return $result;
87 }
88 ?>

Properties

Name Value
svn:keywords Id