Converts a locale ID to a language ID.
A language ID consists of only the first group of letters before an underscore or dash.
@param string $id the locale ID to be converted
@return string the language ID
@since 1.1.9
427265
public function getLanguageID($id)
	{
		// normalize id
		$id = $this->getCanonicalID($id);
		// remove sub tags
		if(($underscorePosition=strpos($id, '_'))!== false)
		{
			$id = substr($id, 0, $underscorePosition);
		}
		return $id;
	}
849143
public function getTranslation($iso, $id)
    {

        $id_element = $this->model->hasBeenTranslated($this->model->getTable(), $id, $iso);
        if (!empty($id_element)) {
            return redirect()->to(action($this->getControllerNameForAction().'@getEdit', $id_element));
        }

        $model = (!empty($id) || $id === "0") ? $this->model->withoutTranslation()->findOrFail($id) : $this->model;
        $form  = FormBuilder::create(get_class($this->form), [
            'model' => $model
        ])
            ->remove('id')
            ->add('translation_iso', 'hidden', ['default_value' => $iso])
            ->add('translation_id_source', 'hidden', ['default_value' => $id])
            ->add('local_override', 'hidden', ['default_value' => $iso]);

        $form_content = view('form-builder::form.components.formgenerator.full', [
            'form' => $form
        ]);

        $this->layoutManager->add([
            'content' => view('expendable::admin.form.state.form', [
                'form' => $form_content
            ])
        ]);

        return $this->layoutManager->render();
    }
79876
private function createPrefix($id)
    {
        $this->prefix = substr($id, self::PREFIX_START, self::PREFIX_LENGTH);
    }
422068
protected function identifierToGroupID($groupID)
    {
        if (is_numeric($groupID) && Group::get()->byID($groupID)) {
            return $groupID;
        } elseif (is_string($groupID) && $groupByCode = Group::get()->filter(['Code' => $groupID])->first()) {
            return $groupByCode->ID;
        } elseif ($groupID instanceof Group && $groupID->exists()) {
            return $groupID->ID;
        }
        return null;
    }
1144126
public static function getIdValue(array $id) 
    {
        self::formatScalarValues($id);
        if (\is_array($id)) {
            RecursiveDeleteHelper::deleteKeys($id, [Serializer::CLASS_IDENTIFIER_KEY]);
        }

        return $id;
    }
803007
public function toModelAttribute($id)
	{
		if ($id === null) {
			$id = self::VALUE_NULL;
		}

		if (! array_key_exists($id,	$this->_map) ) {
			throw new Exception('Conversion from SimpleWorkflow failed : no key found for id = '.$id);
		}
		$value = $this->_map[$id];
		return ($value === self::VALUE_NULL ? null : $value);
	}
1047012
public function setDefault($id)
    {
        $this->loadModel('Locale.Languages');
        $this->loadModel('System.Options');
        $language = $this->Languages->get($id);

        if ($language->status) {
            if ($this->Options->update('default_language', $language->code)) {
                $this->Flash->success(__d('locale', 'Default language changed!'));
            } else {
                $this->Flash->danger(__d('locale', 'Default language could not be changed.'));
            }
        } else {
            $this->Flash->danger(__d('locale', 'You cannot set as default a disabled language.'));
        }

        $this->title(__d('locale', 'Set Default Language'));
        $this->redirect($this->referer());
    }
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());
    }
54598
public static function getId($id) {
    $id = str_replace([' ', '_', '[', ']'], ['-', '-', '-', ''], Unicode::strtolower($id));

    // As defined in http://www.w3.org/TR/html4/types.html#type-name, HTML IDs can
    // only contain letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
    // colons (":"), and periods ("."). We strip out any character not in that
    // list. Note that the CSS spec doesn't allow colons or periods in identifiers
    // (http://www.w3.org/TR/CSS21/syndata.html#characters), so we strip those two
    // characters as well.
    $id = preg_replace('/[^A-Za-z0-9\-_]/', '', $id);

    // Removing multiple consecutive hyphens.
    $id = preg_replace('/\-+/', '-', $id);
    return $id;
  }
67468
public static function cleanId($id)
    {
        // Remove non allowed characters
        $id = preg_replace('/[^A-Za-z0-9\-\_\/~]/', '', $id);

        // Replace multiple slashes
        $id = preg_replace('/\/+/', '/', $id);

        return trim($id, '/');
    }
527544
public function getCacheId($id = null)
    {
        $id .= serialize($this->state->toArray());

        return sha1($id);
    }
1106379
protected function _idToFileName($id)
    {
        $instance = self::getInstance();
        $prefix = $instance->_options['file_name_prefix'];
        return $prefix . '---' . $id;
    }
1122169
public function actionExportLanguage($id)
    {
        $language = $this->em->find("WebCMS\Entity\Language", $id);

        $export = array(
            'name' => $language->getName(),
            'abbr' => $language->getAbbr(),
            'translations' => array(),
        );

        foreach ($language->getTranslations() as $translation) {
            if ($translation->getBackend()) {
                $export['translations'][] = array(
                'key' => $translation->getKey(),
                'translation' => $translation->getTranslation(),
                'backend' => $translation->getBackend(),
            );
            }
        }

        $export = json_encode($export);
        $filename = $language->getAbbr().'.json';

        $response = $this->getHttpResponse();
        $response->setHeader('Content-Description', 'File Transfer');
        $response->setContentType('text/plain', 'UTF-8');
        $response->setHeader('Content-Disposition', 'attachment; filename='.$filename);
        $response->setHeader('Content-Transfer-Encoding', 'binary');
        $response->setHeader('Expires', 0);
        $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
        $response->setHeader('Pragma', 'public');
        $response->setHeader('Content-Length', strlen($export));

        ob_clean();
        flush();
        echo $export;

        $this->terminate();
    }
1275750
public function setLanguageId( $id )
	{
		if ( $id === $this->getLanguageId() ) { return; }

		if ( $id !== null ) {
			if ( strlen($id) !== 2 || ctype_alpha($id) === false ) {
				throw new MShop_Product_Exception(sprintf('Invalid characters in ISO language code "%1$s"', $id));
			}

			$id = (string) $id;
		}

		$this->_values['langid'] = $id;
		$this->setModified();
	}
1333462
protected function prepareUniqueId($id)
    {
        if (preg_match('/\[(.*)\]/', $id, $matches)) {
            $id = $this->getValue($matches[1]);
        }

        if (strtolower($id) === 'null') {
            $id = null;
        }

        if (filter_var($id, FILTER_VALIDATE_INT) !== false) {
            $id = (int) $id;
        }

        return $id;
    }
562281
public function convertToCommunityId($id)
    {
        switch (self::getTypeOfId($id)) {
            case USER_ID_TYPE_COMMUNITY:
                return $id;
            case USER_ID_TYPE_VANITY:
                $api_interface = new ISteamUser();
                return $api_interface->ResolveVanityURL($id);
            case USER_ID_TYPE_STEAM:
                return self::steamIdToCommunityId($id);
            default:
                return FALSE;
        }
    }
882015
public function buildId($id)
    {
        $parts = explode(' ', $id, 2);
        if (count($parts) === 2) {
            return $this->buildIdWithAlias($parts[0], $parts[1]);
        }

        return $this->wrap($id);
    }