2013-05-02 22:20:06 +08:00
< ? php
//
2018-12-21 03:58:38 +08:00
// ZoneMinder web language file
2013-05-02 22:20:06 +08:00
// Copyright (C) 2001-2008 Philip Coombes
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// 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.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
2016-12-26 23:23:16 +08:00
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2013-05-02 22:20:06 +08:00
//
2020-02-28 06:40:31 +08:00
function translate ( $name ) {
2018-12-21 03:58:38 +08:00
global $SLANG ;
2020-02-28 06:40:31 +08:00
// The isset is more performant
if ( isset ( $SLANG [ $name ]) || array_key_exists ( $name , $SLANG ) )
2018-12-21 03:58:38 +08:00
return $SLANG [ $name ];
else
return $name ;
2015-05-10 21:10:30 +08:00
}
2020-02-28 06:40:31 +08:00
function loadLanguage ( $prefix = '' ) {
2018-12-21 03:58:38 +08:00
global $user ;
2013-05-02 22:20:06 +08:00
2018-12-21 03:58:38 +08:00
if ( $prefix )
$prefix = $prefix . '/' ;
2013-05-02 22:20:06 +08:00
2020-02-28 06:40:31 +08:00
if ( isset ( $user [ 'Language' ]) ) {
2018-12-21 03:58:38 +08:00
$userLangFile = $prefix . 'lang/' . $user [ 'Language' ] . '.php' ;
2013-05-02 22:20:06 +08:00
2020-02-28 06:40:31 +08:00
if ( file_exists ( $userLangFile ) ) {
return $userLangFile ;
} else {
ZM\Warning ( " User language file $userLangFile does not exist. " );
}
}
$systemLangFile = $prefix . 'lang/' . ZM_LANG_DEFAULT . '.php' ;
if ( file_exists ( $systemLangFile ) ) {
2018-12-21 03:58:38 +08:00
return $systemLangFile ;
2020-02-28 06:40:31 +08:00
} else {
ZM\Warning ( " System language file $systemLangFile does not exist. " );
}
$fallbackLangFile = $prefix . 'lang/en_gb.php' ;
if ( file_exists ( $fallbackLangFile ) ) {
2018-12-21 03:58:38 +08:00
return $fallbackLangFile ;
2020-02-28 06:40:31 +08:00
} else {
ZM\Error ( " Default language file $fallbackLangFile does not exist. " );
}
return false ;
2013-05-02 22:20:06 +08:00
}
2018-08-31 01:25:02 +08:00
if ( $langFile = loadLanguage () ) {
2018-12-21 03:58:38 +08:00
require_once ( $langFile );
require_once ( 'lang/default.php' );
foreach ( $DLANG as $key => $value ) {
2020-02-28 06:40:31 +08:00
if ( ! ( isset ( $SLANG [ $key ]) || array_key_exists ( $key , $SLANG )) )
2018-12-21 03:58:38 +08:00
$SLANG [ $key ] = $DLANG [ $key ];
}
2018-08-31 01:25:02 +08:00
}
2013-05-02 22:20:06 +08:00
2013-08-16 18:05:33 +08:00
//
// Date and time formats fallback, if not set up by the language file already
//
2018-12-21 03:58:38 +08:00
defined ( 'DATE_FMT_CONSOLE_LONG' ) or define ( 'DATE_FMT_CONSOLE_LONG' , 'D jS M, g:ia' ); // This is the main console date/time, date() or strftime() format
defined ( 'DATE_FMT_CONSOLE_SHORT' ) or define ( 'DATE_FMT_CONSOLE_SHORT' , '%H:%M' ); // This is the xHTML console date/time, date() or strftime() format
2013-08-16 18:05:33 +08:00
2018-12-21 03:58:38 +08:00
defined ( 'STRF_FMT_DATETIME' ) or define ( 'STRF_FMT_DATETIME' , '%c' ); // Strftime locale aware format for dates with times
defined ( 'STRF_FMT_DATE' ) or define ( 'STRF_FMT_DATE' , '%x' ); // Strftime locale aware format for dates without times
defined ( 'STRF_FMT_TIME' ) or define ( 'STRF_FMT_TIME' , '%X' ); // Strftime locale aware format for times without dates
2013-08-16 18:05:33 +08:00
2018-12-21 03:58:38 +08:00
defined ( 'STRF_FMT_DATETIME_SHORT' ) or define ( 'STRF_FMT_DATETIME_SHORT' , '%y/%m/%d %H:%M:%S' ); // Strftime shorter format for dates with time, not locale aware
defined ( 'STRF_FMT_DATETIME_SHORTER' ) or define ( 'STRF_FMT_DATETIME_SHORTER' , '%m/%d %H:%M:%S' ); // Strftime shorter format for dates with time, not locale aware, used where space is tight
2013-08-16 18:05:33 +08:00
2013-05-02 22:20:06 +08:00
?>