private $longid;
private $name;
private $abbrev;
- private $flag;
const DEFAULT_LANG = 'fr_FR';
$this->longid = $lang['long'];
$this->name = $lang['longname'];
$this->abbrev = $lang['shortname'];
- $this->flag = $lang['flag'];
}
/**
}
}
- /**
- * Gets the language flag from its ID
- *
- * @param string $id the language identifier
- *
- * @return string path to flag for specified language identifier
- */
- public function getFlagFromId($id)
- {
- $path = null;
- if (!isset($this->langs[$id])) {
- Analog::log(
- str_replace(
- '%lang',
- $id,
- _T('Unknown lang (%lang)')
- ),
- Analog::INFO
- );
- } else {
- if (defined('GALETTE_THEME_DIR')) {
- $path = GALETTE_THEME_DIR . 'images/flags/' . $this->langs['id']['flag'];
- } else {
- $path = GALETTE_THEME . 'images/flags/' . $this->langs[$id]['flag'];
- }
- }
- return $path;
- }
-
/**
* Get current id
*
return $this->abbrev;
}
- /**
- * Get current flag
- *
- * @return string path to the current language flag image
- */
- public function getFlag()
- {
- if (defined('GALETTE_THEME_DIR')) {
- return GALETTE_THEME_DIR . 'images/flags/' . $this->flag;
- } else {
- return GALETTE_THEME . 'images/flags/' . $this->flag;
- }
- }
-
/**
* Is a string seem to be UTF-8 one ?
*
public function guessLangs()
{
$dir = new \DirectoryIterator($this->path);
- $flags_dir = GALETTE_ROOT . 'webroot/themes/default/images/flags/';
$langs = [];
foreach ($dir as $fileinfo) {
if ($fileinfo->isDir() && !$fileinfo->isDot()) {
$lang = $fileinfo->getFilename();
$real_lang = str_replace('.utf8', '', $lang);
$parsed_lang = \Locale::parseLocale($lang);
- $flag = (file_exists($flags_dir . $real_lang . '.svg') ?
- $real_lang . '.svg' :
- 'default.svg');
$langs[$real_lang] = [
'long' => $lang,
'longname' => \Locale::getDisplayLanguage(
$lang,
$lang
- ),
- 'flag' => $flag
+ )
];
}
}