Inpsyde\MultilingualPress\Common\Type\AliasAwareLanguage::name PHP Method

name() public method

Returns the language name (or code) according to the given argument.
Since: 3.0.0
public name ( string $output = 'native' ) : string
$output string Optional. Output type. Defaults to 'native'. TODO: Check/Adapt formatting to provide best possible readibility for both inline and rendered documentation. Possible values: * native: Native name of the language (default, e.g., "Deutsch" for German). * english: English name of the language. * custom: Language name as defined in the site settings. * text: Alias for "custom". * http: HTTP code of the language (e.g., "de-DE"). * language_long: Alias for "http". * language_short: First part of "http" (e.g., "de" for "de-DE"). * lang: Alias for "language_short". * wp_locale: WordPress locale representing the language. * none: No text output (e.g,. for displaying the flag icon only).
return string Language name (or code) according to the given argument.
    public function name($output = 'native')
    {
        if (!empty($this->names[$output])) {
            return (string) $this->names[$output];
        }
        if (!empty($this->names["{$output}_name"])) {
            return (string) $this->names["{$output}_name"];
        }
        if (in_array($output, ['language_short', 'lang'], true)) {
            return strtok($this->names['http_name'], '-');
        }
        if ('language_long' === $output) {
            return (string) $this->names['http_name'];
        }
        if ('none' === $output) {
            return '';
        }
        // Since the given output type is either empty or invalid, return the native or English language name, if set.
        foreach (['native_name', 'english_name'] as $key) {
            if (!empty($this->names[$key])) {
                return (string) $this->names[$key];
            }
        }
        return '';
    }