Backend\Core\Language\Language::getLabel PHP Method

getLabel() public static method

Get a label from the language-file
public static getLabel ( string $key, string $module = null ) : string
$key string The key to get.
$module string The module wherein we should search.
return string
    public static function getLabel($key, $module = null)
    {
        // do we know the module
        if ($module === null) {
            $module = self::getCurrentModule();
        }
        $key = \SpoonFilter::toCamelCase((string) $key);
        $module = (string) $module;
        // check if the label exists
        if (isset(self::$lbl[$module][$key])) {
            return self::$lbl[$module][$key];
        }
        // check if the label exists in the Core
        if (isset(self::$lbl['Core'][$key])) {
            return self::$lbl['Core'][$key];
        }
        // otherwise return the key in label-format
        return '{$lbl' . \SpoonFilter::toCamelCase($module) . $key . '}';
    }

Usage Example

Beispiel #1
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // gender dropdown values
     $genderValues = array('male' => \SpoonFilter::ucfirst(BL::getLabel('Male')), 'female' => \SpoonFilter::ucfirst(BL::getLabel('Female')));
     // birthdate dropdown values
     $days = range(1, 31);
     $months = \SpoonLocale::getMonths(BL::getInterfaceLanguage());
     $years = range(date('Y'), 1900);
     // create form
     $this->frm = new BackendForm('add');
     // create elements
     $this->frm->addText('email')->setAttribute('type', 'email');
     $this->frm->addPassword('password');
     $this->frm->addText('display_name');
     $this->frm->addText('first_name');
     $this->frm->addText('last_name');
     $this->frm->addText('city');
     $this->frm->addDropdown('gender', $genderValues);
     $this->frm->addDropdown('day', array_combine($days, $days));
     $this->frm->addDropdown('month', $months);
     $this->frm->addDropdown('year', array_combine($years, $years));
     $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()));
     // set default elements dropdowns
     $this->frm->getField('gender')->setDefaultElement('');
     $this->frm->getField('day')->setDefaultElement('');
     $this->frm->getField('month')->setDefaultElement('');
     $this->frm->getField('year')->setDefaultElement('');
     $this->frm->getField('country')->setDefaultElement('');
 }
All Usage Examples Of Backend\Core\Language\Language::getLabel