{@inheritdoc}

@return boolean
@throws General\ArgumentIsEmptyException
@throws LanguageException\RemoveMainLanguageException
@throws LanguageException\LanguageExistsException

@api
425609
public function delete()
    {
        if (null === $this->alLanguage) {
            throw new General\ArgumentIsEmptyException('exception_no_languages_selected_delete_skipped');
        }

        if ($this->alLanguage->getMainLanguage() == 1) {
            throw new LanguageException\RemoveMainLanguageException('exception_website_main_languages_cannot_be_delete');
        }

        $this->dispatchBeforeOperationEvent(
                '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Language\BeforeLanguageDeletingEvent',
                LanguageEvents::BEFORE_DELETE_LANGUAGE,
                array(),
                'exception_language_deleting_aborted'
        );

        try {
            $this->languageRepository->startTransaction();
            $result = $this->languageRepository
                            ->setRepositoryObject($this->alLanguage)
                            ->delete();

            if ($result) {
                $eventName = LanguageEvents::BEFORE_DELETE_LANGUAGE_COMMIT;
                $result = !$this->eventsHandler
                                ->createEvent($eventName, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Language\BeforeDeleteLanguageCommitEvent', array($this, array()))
                                ->dispatch()
                                ->getEvent($eventName)
                                ->isAborted();
            }

            if (false !== $result) {
                $this->languageRepository->commit();

                $this->eventsHandler
                     ->createEvent(LanguageEvents::AFTER_DELETE_LANGUAGE, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Language\AfterLanguageDeletedEvent', array($this))
                     ->dispatch();

                return $result;
            }

            $this->languageRepository->rollBack();

            return $result;
        } catch (\Exception $e) {
            if (isset($this->languageRepository) && $this->languageRepository !== null) {
                $this->languageRepository->rollBack();
            }

            throw $e;
        }
    }
601700
public function exists($language, $basePath = ANPATH_BASE)
	{
        $directory = $this->getLanguagePath($basePath, $language);
        return is_dir($directory);
	}
369681
public static function setLanguage($language)
    {
        if (in_array($language, self::$languages)) {
            self::$language = $language;
            self::$strings = self::loadLanguage();
            return true;
        }

        return false;
    }
1106588
public function translationExists($lang, $alias) {
		$tree = $this->getTree($lang);

		foreach ($tree as $branch) {
			if (isset($branch[$alias])) return true;
		}
		return false;
	}
11098
public function deleteLanguage($id)
    {
        try {
            return $this->innerGateway->deleteLanguage($id);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
292396
public function set($lang) {
		if ($this->isValid($lang)) {
			$this->_language = $lang;
			$this->_l10n = $this->getL10n();

			// switch the locales
			$this->setLocale($this->_l10n['keys']);

			// clear content because language has changed
			$this->_content = null;
			return true;
		}
		return false;
	}
729597
protected function removeActiveLanguages(LanguageRepositoryInterface $languageRepository)
    {
        try {
            $languages = $languageRepository->activeLanguages();
            foreach ($languages as $language) {
                $language->delete();
            }

            return true;
        } catch (\Exception $ex) {
            $this->errorMessage = "An error occoured during the removing of existing languages. The reported error is: " . $ex->getMessage();

            return false;
        }
    }
659931
public function validLang($lang)
    {
        if (in_array($lang, $this->validLanguages)) {
            return $lang;
        }
        if ($this->defaultLanguage) {
            return $this->defaultLanguage;
        }
        return false;
    }
847862
public function validateAlias()
    {
        $dirty = $this->getDirtyAttributes(['alias']);
        if (!isset($dirty['alias'])) {
            return true;
        }

        if (!$this->verifyAlias($this->alias, $this->lang_id)) {
            return false;
        }
    }
1326556
public function hasTranslation($language = null)
    {
        $translation = $this->getTranslation($language);
        return $translation && $this->isTranslationActive($translation);
    }
980604
function removeTranslation( $languageID )
    {
        $language = eZContentLanguage::fetch( $languageID );

        if ( !$language )
        {
            return false;
        }

        // check if it is not the initial language
        $classInitialLanguageID = $this->attribute( 'initial_language_id' );
        if ( $classInitialLanguageID == $languageID )
        {
            return false;
        }

        $db = eZDB::instance();
        $db->begin();

        $classID = $this->attribute( 'id' );
        $languageID = $language->attribute( 'id' );

        // change language_mask of the object
        $languageMask = (int) $this->attribute( 'language_mask' );
        $languageMask = (int) $languageMask & ~ (int) $languageID;
        $this->setAttribute( 'language_mask', $languageMask );

        // Remove all names in the language
        $db->query( "DELETE FROM ezcontentclass_name
                     WHERE contentclass_id='$classID'
                       AND language_id='$languageID'" );

        $languageLocale = $language->attribute( 'locale' );
        $this->NameList->removeName( $languageLocale );
        $this->DescriptionList->removeName( $languageLocale );

        $this->store();

        // Remove names for attributes in the language
        $attributes = $this->fetchAttributes();
        foreach ( $attributes as $attribute )
        {
            $attribute->removeTranslation( $languageLocale );
            $attribute->store();
        }

        $db->commit();

        return true;
    }
1047796
protected function setLang() 
    {
        $array = explode(",", $this->_accept_language);
        $ca = count($array);
        for($i = 0; $i < $ca; $i++) 
        {
            //Konqueror
            $array[$i] = str_replace(" ", null, $array[$i]);
            $array[$i] = substr($array[$i], 0, 2);
            $array[$i] = strtolower($array[$i]);
        }
        $array = array_unique($array);
        $this->_lang = strtoupper($array[0]);
        if(empty($this->_lang) || strlen($this->_lang) < 2) 
        {
        	$this->_lang = 'Unknown';
        }
        return true;
    }
1115361
public function deleteTranslation($key, $language = null) {
		if($language === null) {
			$languages = $this->getLanguageList();
		}
		else {
			$languages = array($language);
		}
		foreach ($languages as $language) {
			$messageFile = $this->getMessageFile($language);
			$messageFile->deleteMessage($key);
			$messageFile->save();
			
			unset($this->messages[$language][$key]);
		}
	}
125563
public function hasTranslation($language = null)
    {
        $language = $language ?: Yii::$app->language;

        foreach ($this->getModelTranslations() as $translation) {
            if ($translation->getAttribute($this->translationLanguageAttrName) === $language) {
                return true;
            }
        }

        return false;
    }
200643
public function removeFromCache($domain = null, $locale = null) {
		if ($this->cache === null) {
			return true;
		}
		
		if ($domain === null) {
			$domain = $this->domain;
		}
		
		if ($locale === null) {
			$locale = $this->getLocale();
		}
		
		return $this->cache->removeCatalogs($locale, $domain);
	}
906541
public function actionDelete()
    {
        
        $this->outVerbose("Deleting language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
    	
    	$dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
        if (!tao_helpers_File::remove($dir, true)) {
        	$this->err("Could not delete language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "'.", true);	
        }
        
        $this->outVerbose("Language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' successfully deleted.");
        
    }
895320
public function uninstall_language($lang) {
        global $CFG;

        $dest1 = $CFG->dataroot.'/lang/'.$lang;
        $dest2 = $CFG->dirroot.'/lang/'.$lang;
        $rm1 = false;
        $rm2 = false;
        if (file_exists($dest1)) {
            $rm1 = remove_dir($dest1);
        }
        if (file_exists($dest2)) {
            $rm2 = remove_dir($dest2);
        }

        if ($rm1 or $rm2) {
            $this->info[] = get_string('langpackremoved', 'tool_langimport', $lang);
            event\langpack_removed::event_with_langcode($lang)->trigger();
            return true;
        } else {    // Nothing deleted, possibly due to permission error.
            $this->errors[] = get_string('langpacknotremoved', 'tool_langimport', $lang);
            return false;
        }
    }