Adding a lot of stuff, langauge thingi, website.html default thing, config.inc.php, main.inc.php, index.php, default construct of all things, the ability to saying hello world...
This commit is contained in:
74
language.class.inc.php
Normal file
74
language.class.inc.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class language
|
||||
*
|
||||
* 1xx Error codes
|
||||
*/
|
||||
|
||||
|
||||
class language
|
||||
{
|
||||
public static $languages = array(
|
||||
'de_DE' => 'German',
|
||||
'en_EN' => 'English',
|
||||
|
||||
);
|
||||
|
||||
public const
|
||||
TITLE = 'TITLE',
|
||||
MAIN_TITLE = 'MAIN_TITLE',
|
||||
DESCRIPTION = 'DESCRIPTION',
|
||||
PROJECT_DESCRIPTION = 'PROJECT_DESCRIPTION',
|
||||
HELP_US = 'HELP_US',
|
||||
REQUEST_MORE = 'REQUEST_MORE',
|
||||
SOCIAL_MEDIA = 'SOCIAL_MEDIA',
|
||||
JOIN_DISCORD = 'JOIN_DISCORD'
|
||||
;
|
||||
|
||||
public static $lang_file;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public static $lang;
|
||||
|
||||
|
||||
public static function checkLanguage ( ): void
|
||||
{
|
||||
// Check cookie
|
||||
if( isset( $_GET['lang'] ) )
|
||||
{
|
||||
if( isset( $languages[$_GET['lang']] ) )
|
||||
{
|
||||
self::setLangauge( $_GET['lang'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
self::setLangauge();
|
||||
}
|
||||
}
|
||||
else if ( isset( $_COOKIE['lang'], self::$languages[$_COOKIE['lang']] ) )
|
||||
{
|
||||
self::setLangauge( $_COOKIE['lang'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
self::setLangauge();
|
||||
}
|
||||
}
|
||||
|
||||
private static function setLangauge ( $a_language = 'en_en' )
|
||||
{
|
||||
self::$lang = $a_language;
|
||||
setcookie( 'lang', $a_language, 0 );
|
||||
try
|
||||
{
|
||||
self::$lang_file = parse_ini_file( LANG_DIRECTORY . $a_language . '.ini' );
|
||||
|
||||
} catch( Exception $e )
|
||||
{
|
||||
throw new RuntimeException( 'Cannot load the language file!', 101 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user