diff --git a/lang/lang-de.ini b/lang/de.ini similarity index 100% rename from lang/lang-de.ini rename to lang/de.ini diff --git a/lang/lang-en.ini b/lang/en.ini similarity index 100% rename from lang/lang-en.ini rename to lang/en.ini diff --git a/lang/lang-pl.ini b/lang/pl.ini similarity index 100% rename from lang/lang-pl.ini rename to lang/pl.ini diff --git a/system/htmly.php b/system/htmly.php index 1a6bcf8..777a7f7 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -3,16 +3,8 @@ // Load the configuration file config('source', $config_file); -// Settings for the language -if ( config('language') === "de" ) { - i18n('source', 'lang/lang-de.ini'); // Load the German language file - $date_format = '%d. %B %Y'; // Date format German style - setlocale(LC_TIME, 'de_DE', 'de_DE.utf8', "German"); // Change time format to German -} else { // Default: English ("en") - i18n('source', 'lang/lang-en.ini'); // Load the English language file - $date_format = '%B %d, %Y'; // Date format English style - setlocale(LC_TIME, 'en_US', 'en_US.utf8', "English"); // Change time format to English -} +// Load the language file +get_language(); // Set the timezone if (config('timezone')) { diff --git a/system/includes/functions.php b/system/includes/functions.php index 3fbfabb..d9f1a85 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -3201,3 +3201,26 @@ function replace_href($string, $tag, $class, $url) return preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\s*~i', '', utf8_decode($doc->saveHTML($doc->documentElement))); } + +function get_language() +{ + + $langID = config('language'); + $langFile = 'lang/'. $langID . '.ini'; + $local = strtolower($langID); + + // Settings for the language + if (!isset($langID) || config('language') === 'en') { + i18n('source', 'lang/en.ini'); // Load the English language file + setlocale(LC_ALL, 'en_US'); // Change time format to English + } else { + if (file_exists($langFile)) { + i18n('source', 'lang/' . $langID . '.ini'); + setlocale(LC_ALL, $local); + } else { + i18n('source', 'lang/en.ini'); // Load the English language file + setlocale(LC_ALL, 'en_US'); // Change time format to English + } + } + +}