Source
_('You are not able to choose some of the languages, because locales for them are not installed on the web server.')
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* @var CView $this
*/
$this->includeJsFile('administration.gui.edit.js.php');
$html_page = (new CHtmlPage())
->setTitle(_('GUI'))
->setTitleSubmenu(getAdministrationGeneralSubmenu())
->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_GUI_EDIT));
// Append languages to form list.
$lang_select = (new CSelect('default_lang'))
->setId('default_lang')
->setValue($data['default_lang'])
->setFocusableElementId('label-default-lang')
->setAttribute('autofocus', 'autofocus');
$all_locales_available = true;
foreach (getLocales() as $localeid => $locale) {
if (!$locale['display']) {
continue;
}
/*
* Checking if this locale exists in the system. The only way of doing it is to try and set one
* trying to set only the LC_MONETARY locale to avoid changing LC_NUMERIC.
*/
$locale_available = ($localeid === ZBX_DEFAULT_LANG || setlocale(LC_MONETARY, zbx_locale_variants($localeid)));
$lang_select->addOption((new CSelectOption($localeid, $locale['name']))->setDisabled(!$locale_available));
if (!$locale_available) {
$all_locales_available = false;
}
}
// Restoring original locale.
setlocale(LC_MONETARY, zbx_locale_variants($data['default_lang']));
$language_error = null;
if (!function_exists('bindtextdomain')) {
$language_error = makeErrorIcon('Translations are unavailable because the PHP gettext module is missing.');
$lang_select->setReadonly();