Deletes a language
436817
protected function deleteLanguage()
    {
        $this->controlAccess('language_delete');

        if ($this->language->delete($this->data_language['code'])) {
            $this->redirect('admin/settings/language', $this->text('Language has been deleted'), 'success');
        }

        $this->redirect('', $this->text('Language has not been deleted'), 'warning');
    }
596217
public function delete($id)
    {
        $this->loadModel('Locale.Languages');
        $language = $this->Languages->get($id);

        if (!in_array($language->code, [CORE_LOCALE, option('default_language')])) {
            if ($this->Languages->delete($language)) {
                $this->Flash->success(__d('locale', 'Language successfully removed!'));
            } else {
                $this->Flash->danger(__d('locale', 'Language could not be removed, please try again.'));
            }
        } else {
            $this->Flash->danger(__d('locale', 'You cannot remove this language as it still in use.'));
        }

        $this->title(__d('locale', 'Delete Language'));
        $this->redirect($this->referer());
    }
978890
function _removeWishIdFromEnteredMagicWords(id) {
  function removeIdFromWishes(charObj, parent, charObjName) {
    _each(charObj, (childProp, propName) => {
      if (propName === 'wishes') {
        const index = childProp.indexOf(id)
        if (index !== -1) {
          childProp.splice(index, 1)
        }
        if (!childProp.length) {
          delete charObj[propName]
        }
      } else {
        removeIdFromWishes(childProp, charObj, propName)
      }
    })
    const keepCharObj = _getPropFromPosterity(charObj, 'wishes').length > 0
    if (!keepCharObj && parent && charObjName) {
      delete parent[charObjName]
    }
  }
  removeIdFromWishes(_enteredMagicWords)
}
390480
public function delete($lang, $id)
    {
        if(!User::hasAccess('Language', 'delete')) {
            return $this->noPermission();
        }
        $language = Language::find($id);

        if($language) {
            if ($language->isDefault) {
                return $this->response("You can't delete the default language!", 403);
            }

            if($language->delete()) {
                // create virutal column for slug of every post type in the created language
                $allPostTypes = PostType::all();
                foreach ($allPostTypes as $postType){
                    AccioQuery::deleteColumn($postType->slug, "slug_".$language->slug);
                }

                $this->deleteDirectory($language->slug);
                return $this->response('The Language was deleted');
            }
        }

        return $this->response('The Language was not deleted. Please try again later', 500);
    }
566323
function removeTranslation( $languageCode )
    {

        $versionNum = $this->attribute( 'version' );

        $contentObjectAttributes = $this->contentObjectAttributes( $languageCode );

        $db = eZDB::instance();
        $db->begin();
        foreach ( $contentObjectAttributes as $attribute )
        {
            $attribute->removeThis( $attribute->attribute( 'id' ), $versionNum );
        }
        $db->commit();

        $this->updateLanguageMask();
    }
1183274
public function canDeleteLanguage($id)
    {
        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcobj_state')
        )->where(
            $query->expr->lOr(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('default_language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->dbHandler->quoteColumn('language_mask'),
                        $query->bindValue($id, null, \PDO::PARAM_INT)
                    ),
                    0
                )
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcobj_state_group')
        )->where(
            $query->expr->lOr(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('default_language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->dbHandler->quoteColumn('language_mask'),
                        $query->bindValue($id, null, \PDO::PARAM_INT)
                    ),
                    0
                )
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcobj_state_group_language')
        )->where(
            $query->expr->gt(
                $query->expr->bitAnd(
                    $this->dbHandler->quoteColumn('language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                0
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcobj_state_language')
        )->where(
            $query->expr->gt(
                $query->expr->bitAnd(
                    $this->dbHandler->quoteColumn('language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                0
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcontentclass')
        )->where(
            $query->expr->lOr(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('initial_language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->dbHandler->quoteColumn('language_mask'),
                        $query->bindValue($id, null, \PDO::PARAM_INT)
                    ),
                    0
                )
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcontentclass_name')
        )->where(
            $query->expr->gt(
                $query->expr->bitAnd(
                    $this->dbHandler->quoteColumn('language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                0
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcontentobject')
        )->where(
            $query->expr->lOr(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('initial_language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->dbHandler->quoteColumn('language_mask'),
                        $query->bindValue($id, null, \PDO::PARAM_INT)
                    ),
                    0
                )
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcontentobject_attribute')
        )->where(
            $query->expr->gt(
                $query->expr->bitAnd(
                    $this->dbHandler->quoteColumn('language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                0
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcontentobject_name')
        )->where(
            $query->expr->gt(
                $query->expr->bitAnd(
                    $this->dbHandler->quoteColumn('language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                0
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezcontentobject_version')
        )->where(
            $query->expr->lOr(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('initial_language_id'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->dbHandler->quoteColumn('language_mask'),
                        $query->bindValue($id, null, \PDO::PARAM_INT)
                    ),
                    0
                )
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        if ($statement->fetchColumn() > 0) {
            return false;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->alias($query->expr->count('*'), 'count')
        )->from(
            $this->dbHandler->quoteTable('ezurlalias_ml')
        )->where(
            $query->expr->gt(
                $query->expr->bitAnd(
                    $this->dbHandler->quoteColumn('lang_mask'),
                    $query->bindValue($id, null, \PDO::PARAM_INT)
                ),
                0
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchColumn() == 0;
    }
1095081
function removeThis()
    {
        $contentobjectID = $this->attribute( 'contentobject_id' );
        $versionNum = $this->attribute( 'version' );

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

        // Ensure no one else deletes this version while we are doing it.
        $db->query( 'SELECT * FROM ezcontentobject_version
                         WHERE id=' . $this->attribute( 'id' ) . ' FOR UPDATE' );

        $contentObjectTranslations = $this->translations();

        foreach ( $contentObjectTranslations as $contentObjectTranslation )
        {
            /** @var eZContentObjectAttribute $attribute */
            foreach ( $contentObjectTranslation->objectAttributes() as $attribute )
            {
                $attribute->removeThis( $attribute->attribute( 'id' ), $versionNum );
            }
        }
        $db->query( "DELETE FROM ezcontentobject_link
                         WHERE from_contentobject_id=$contentobjectID AND from_contentobject_version=$versionNum" );
        $db->query( "DELETE FROM eznode_assignment
                         WHERE contentobject_id=$contentobjectID AND contentobject_version=$versionNum" );

        $db->query( 'DELETE FROM ezcontentobject_version
                         WHERE id=' . $this->attribute( 'id' ) );

        $contentobject = $this->attribute( 'contentobject' );
        if ( is_object( $contentobject ) )
        {
            if ( !$contentobject->hasRemainingVersions() )
            {
                $contentobject->purge();
            }
            else
            {
                $version = $contentobject->CurrentVersion;
                if ( $contentobject->CurrentVersion == $versionNum ) //will assign another current_version in contentObject.
                {
                   //search for version that will be current after removing of this one.
                   $candidateToBeCurrent = $db->arrayQuery( "SELECT version
                                                     FROM ezcontentobject_version
                                                     WHERE contentobject_id={$contentobject->ID} AND
                                                           version!={$contentobject->CurrentVersion}
                                                     ORDER BY modified DESC",
                                                 array( 'offset' => 0, 'limit' => 1 ) );

                   if ( isset($candidateToBeCurrent[0]['version']) && is_numeric($candidateToBeCurrent[0]['version']) )
                   {
                       $contentobject->CurrentVersion = $candidateToBeCurrent[0]['version'];
                       $contentobject->store();
                   }
               }
            }
        }
        $db->query( "DELETE FROM ezcontentobject_name
                         WHERE contentobject_id=$contentobjectID AND content_version=$versionNum" );

        $db->commit();
    }
683403
def invalidate(self):
        """"""

        cache.delete(self.PAGE_LANGUAGES_KEY % (self.id))
        cache.delete('PAGE_FIRST_ROOT_ID')
        self._languages = None
        self._complete_slug = None
        self._content_dict = dict()

        p_names = [p.name for p in get_placeholders(self.get_template())]
        if 'slug' not in p_names:
            p_names.append('slug')
        if 'title' not in p_names:
            p_names.append('title')
        # delete content cache, frozen or not
        for name in p_names:
            # frozen
            cache.delete(PAGE_CONTENT_DICT_KEY % (self.id, name, 1))
            # not frozen
            cache.delete(PAGE_CONTENT_DICT_KEY % (self.id, name, 0))

        cache.delete(self.PAGE_URL_KEY % (self.id))
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;
        }
    }
405020
public static function deleteEmptyAreas()
    {
        $app = Application::getFacadeApplication();
        $siteService = $app->make(SiteService::class);
        $multilingualSectionIDs = [];
        $sites = $siteService->getList();
        foreach ($sites as $site) {
            $multilingualSectionIDs = array_merge(MultilingualSection::getIDList($site));
        }
        $multilingualSections = [];
        foreach (array_unique($multilingualSectionIDs) as $multilingualSectionID) {
            $multilingualSections[] = MultilingualSection::getByID($multilingualSectionID);
        }

        $stackList = new StackList();
        $stackList->filterByGlobalAreas();

        /** @var \Concrete\Core\Page\Stack\Stack[] $globalAreaStacks */
        $globalAreaStacks = $stackList->getResults();

        foreach ($globalAreaStacks as $stack) {
            $stackAlternatives = [];
            if ($stack->isNeutralStack()) {
                $stackAlternatives[] = $stack;
            } else {
                $stackAlternatives[] = $stack->getNeutralStack();
            }
            foreach ($multilingualSections as $multilingualSection) {
                $stackAlternative = $stackAlternatives[0]->getLocalizedStack($multilingualSection);
                if ($stackAlternative !== null) {
                    $stackAlternatives[] = $stackAlternative;
                }
            }
            $hasBlocks = false;
            foreach ($stackAlternatives as $stackAlternative) {
                // get list of all available page versions, we only delete areas if they never had any content
                $versionList = new VersionList($stackAlternative);
                $versions = $versionList->get();

                foreach ($versions as $version) {
                    $pageVersion = Page::getByID($version->getCollectionID(), $version->getVersionID());
                    $totalBlocks = count($pageVersion->getBlockIDs());

                    if ($totalBlocks > 0) {
                        $hasBlocks = true;
                        break 2;
                    }
                }
            }

            if (!$hasBlocks) {
                $stackAlternatives[0]->delete();
            }
        }
    }
468366
private function removeLanguageMiddleware()
    {
        $this->info("Removing the Language middleware...");
        $this->helper->deleteFile($this->config->paths->project->LanguageMiddleware);
        $this->bar->advance();
    }
592792
public function deleteLanguage($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        try {
            $lang=SnippetLanguage::get()->byID(intval($data->id));
            if(!empty($lang) && $lang!==false && $lang->ID!=0) {
                if($lang->canDelete()==false) {
                    $response['status']='EROR';
                    $response['message']=_t('CodeBankAPI.LANGUAGE_DELETE_ERROR', '_Language cannot be deleted, it is either not a user language or has snippets attached to it');
                    
                    return $response;
                }
            }else {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.LANGUAGE_NOT_FOUND', '_Language not found');
                
                return $response;
            }
            
            
            $lang->delete();
            
            
            $response['status']='HELO';
            $response['message']="Language deleted successfully";
        }catch (Exception $e) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
        }
        
        return $response;
    }
572461
def delete_translations_for_item_and_its_children(self, item, languages=None):
        

        self.log('--- Deleting translations ---')

        if not self.master:
            self.set_master(item)

        object_name = '{} - {}'.format(item._meta.app_label.lower(), item._meta.verbose_name)
        object_class = item.__class__.__name__
        object_pk = item.pk

        filter_by = {
            'object_class': object_class,
            'object_name': object_name,
            'object_pk': object_pk,
            'done': False
        }
        if languages:
            filter_by.update({'language__code__in': languages})
        TransTask.objects.filter(**filter_by).delete()

        # then process child objects from main
        children = self.get_translatable_children(item)
        for child in children:
            self.delete_translations_for_item_and_its_children(child, languages)
494749
public function popLanguage(): void
  {
    array_pop($this->stack);
    $this->language = $this->stack[count($this->stack) - 1];
  }
1015453
protected function translateDelete()
    {
        $build = 'delete from ' . $this->escapeTable(false);

        // build the where statements
        if ($wheres = $this->attr('wheres'))
        {
            $build .= $this->translateWhere($wheres);
        }
    
        // build offset and limit
        if ($this->attr('limit'))
        {
             $build .= $this->translateLimit();
        }

        return $build;
    }
1278203
public function reset()
    {
        $this->currentLanguage = $this->getDefaultLanguage();
        $this->directories = array(PIWIK_INCLUDE_PATH . '/lang');
        $this->translations = array();
    }
1187613
def destroy
      @category = @translation_key.category
      @translation_key_id = @translation_key.id
      @key_status = @translation_key.status(session[:lang_to])
      @translation_key.destroy
  
      respond_to do |format|
        format.js
        format.html {redirect_to @category, notice: I18n.t('translation_center.translation_keys.destroyed_successfully')}
      end
    end