1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-11 23:54:10 +02:00

Monstra MultiLanguage Development Init Commit

This commit is contained in:
Awilum
2016-04-10 20:42:34 +03:00
parent 5f1746d62e
commit dc8ef1c489
17 changed files with 282 additions and 68 deletions

View File

@@ -221,4 +221,38 @@ class Site
return __('Powered by', 'system').' <a href="http://monstra.org" target="_blank">Monstra</a> ' . Monstra::VERSION;
}
/**
*
*/
public static function getLocales() {
$language_files = File::scan(PLUGINS_BOX . DS . 'system' . DS . 'languages' . DS, '.lang.php');
foreach ($language_files as $language) {
$parts = explode('.', $language);
$languages_array[$parts[0]] = I18n::$locales[$parts[0]];
}
return $languages_array;
}
/**
*
*/
public static function getDefaultSiteLocale() {
return Option::get('site_language');
}
/**
*
*/
public static function getCurrentSiteLocale() {
$site_locales = Site::getLocales();
if (Uri::segment(0) && array_key_exists(Uri::segment(0), $site_locales)) {
return Uri::segment(0);
} else {
$site_locale = Cookie::get('site_locale');
return !empty($site_locale) ? $site_locale : Option::get('site_language');
}
}
}