mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
e4687a60f9
commit
4cef333add
@ -708,12 +708,44 @@ class Module
|
|||||||
*/
|
*/
|
||||||
protected function registerLocales()
|
protected function registerLocales()
|
||||||
{
|
{
|
||||||
if (file_exists($this->localedir) && is_dir($this->localedir)) {
|
if ($this->hasLocales()) {
|
||||||
Translator::registerDomain($this->name, $this->localedir);
|
Translator::registerDomain($this->name, $this->localedir);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return bool Whether this module has translations
|
||||||
|
*/
|
||||||
|
public function hasLocales()
|
||||||
|
{
|
||||||
|
return file_exists($this->localedir) && is_dir($this->localedir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all available locales
|
||||||
|
*
|
||||||
|
* return array Locale list
|
||||||
|
*/
|
||||||
|
public function listLocales()
|
||||||
|
{
|
||||||
|
$locales = array();
|
||||||
|
if (! $this->hasLocales()) {
|
||||||
|
return $locales;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dh = opendir($this->localedir);
|
||||||
|
while (false !== ($file = readdir($dh))) {
|
||||||
|
$filename = $this->localedir . DIRECTORY_SEPARATOR . $file;
|
||||||
|
if (preg_match('/^[a-z]{2}_[A-Z]{2}$/', $file) && is_dir($filename)) {
|
||||||
|
$locales[] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($dh);
|
||||||
|
sort($locales);
|
||||||
|
return $locales;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register web integration
|
* Register web integration
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user