mirror of
https://github.com/danpros/htmly.git
synced 2026-04-22 13:36:22 +05:30
Simplify the language file
We just need to creating the file and load it via config
This commit is contained in:
parent
a5a3d662a3
commit
73e103b8ab
5 changed files with 25 additions and 10 deletions
|
|
@ -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')) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue