Insert language key

@param string $app  = NULL
@param mixed  $key
@param string $data = NULL

@return bool
169658
public function do(String $app, $key, String $data = NULL) : Bool
    {
        $datas = [];

        $createFile = $this->_langFile($app);

        if( ! is_file($createFile) )
        {
            file_put_contents($createFile, json_encode([]));
        }

        $datas = json_decode(file_get_contents($createFile), true);

        if( ! empty($datas) )
        {
            $json = $datas;
        }

        if( ! is_array($key) )
        {
            $json[$key] = $data;
        }
        else
        {
            foreach( $key as $k => $v )
            {
                $json[$k] = $v;
            }
        }

        if( $json !== $datas )
        {
            return file_put_contents($createFile, json_encode($json, JSON_UNESCAPED_UNICODE));
        }
        else
        {
            return false;
        }
    }
888660
public function translate(string $key, ?string $lang = null): ?string
    {
        try {
            // Validate key
            $key = strtolower($key);
            if (!preg_match('/^[a-z0-9\.\-\_]+$/', $key)) {
                throw new TranslatorException('Invalid translation key');
            }

            // Get current language
            $language = $this->_language($lang);
            $translation = $language->get($key);

            if ($translation) { // Translation found
                return $translation;
            }

            // Fallback
            try {
                $fallback = $this->_fallback();
            } catch (LanguageException $e) {
                throw new LanguageException('[Fallback] ' . $e->getMessage());
            }

            if ($fallback && $fallback->name() !== $language->name()) {
                $translation = $fallback->get($key);
                if ($translation) {
                    return $translation;
                }
            }
        } catch (TranslatorException $e) {
            trigger_error(sprintf('Translation error [%s]: %s', $key, $e->getMessage()), E_USER_WARNING);
        }

        return null;
    }
1074148
public function add($key, $data)
    {
        $toInsert = $this->getDocumentData($data);

        $result = $this->collection->insertOne($toInsert);

        $data->_id = $result->getInsertedId();
    }
680596
protected function syntax(string $key, array $data)
    {
        foreach ($data['directives'] ?? [] as $_key => $directive)
        {
            $this->data($_key, $directive ?: []);
        }

        $this->closed[$key] = $data['closed'] ?? false;
        $this->properties($data['properties'] ?? []);

        $syntax = [];

        foreach ($data['syntax'] ?? [] as $text)
        {
            $tokens = $this->lexer()->tokens($text);
            $vars   = $tokens[Lexer::PRINTER] ?? [];
            $code   = \str_replace(
                ['\\(', '\\)', ','],
                ['\\( ', ' \\)', ' ,'],
                $text
            );

            foreach ($vars as $var)
            {
                $code = \str_replace(
                    $var['code'],
                    $this->fragment($var['fragment']),
                    $code
                );
            }

            $syntax[] = [
                'vars'   => $vars,
                'regexp' => '~^' . $key . ' ' . $code . '$~ui'
            ];
        }

        return $syntax;
    }
746994
public function put($key, $data) {
        if ($this->capacity <= 0) { return false; }
        if (isset($this->hashmap[$key]) && !empty($this->hashmap[$key])) {
            $node = $this->hashmap[$key];
            // update data
            $this->detach($node);
            $this->attach($this->head, $node);
            $node->setData($data);
        }
        else {
            $node = new Node($key, $data);
            $this->hashmap[$key] = $node;
            $this->attach($this->head, $node);

            // check if cache is full
            if (count($this->hashmap) > $this->capacity) {
                // we're full, remove the tail
                $nodeToRemove = $this->tail->getPrevious();
                $this->detach($nodeToRemove);
                unset($this->hashmap[$nodeToRemove->getKey()]);
            }
        }
        return true;
    }
644428
private function createEntity(array $key, array $data)
    {
        list($partitonKey, $rowKey) = array_values($key);

        $entity = new Entity();
        $entity->setPartitionKey((string) $partitonKey);
        $entity->setRowKey((string) $rowKey);

        foreach ($data as $variable => $value) {
            $type = $this->getPropertyType($value);
            $entity->addProperty($variable, $type, $value);
        }

        return $entity;
    }
1025485
public function put($key, $data)
    {

        $key = $this->getKeyCode($key);
        $data = json_encode($data);
        $this->memcacheObj->set($key, $data);
    }
546977
private function add_record($key, $data)
    {
        if ($this->type == 'memcache') {
            $result = $this->db->replace($key, $data, MEMCACHE_COMPRESSED, $this->ttl);

            if (!$result) {
                $result = $this->db->set($key, $data, MEMCACHE_COMPRESSED, $this->ttl);
            }
        }
        else if ($this->type == 'apc') {
            if (apc_exists($key)) {
                apc_delete($key);
            }

            $result = apc_store($key, $data, $this->ttl);
        }

        if ($this->debug) {
            $this->debug('set', $key, $data, $result);
        }

        return $result;
    }
1310873
public function verifySign($data, $key)
    {
        $prestr = $data['prestr'];
        $sign = $data['sign'];
        $prestr = $prestr . $key;
        $mysgin = md5($prestr);

        if($mysgin == $sign) {
            return true;
        }

        return false;
    }
592870
public function encrypt($data, Key $key)
	{
		// Validate key.
		if ($key->type != 'simple')
		{
			throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '.  Expected simple.');
		}

		$encrypted = '';
		$tmp = $key->private;

		// Split up the input into a character array and get the number of characters.
		$chars = preg_split('//', $data, -1, PREG_SPLIT_NO_EMPTY);
		$charCount = count($chars);

		// Repeat the key as many times as necessary to ensure that the key is at least as long as the input.
		for ($i = 0; $i < $charCount; $i = strlen($tmp))
		{
			$tmp = $tmp . $tmp;
		}

		// Get the XOR values between the ASCII values of the input and key characters for all input offsets.
		for ($i = 0; $i < $charCount; $i++)
		{
			$encrypted .= $this->_intToHex(ord($tmp[$i]) ^ ord($chars[$i]));
		}

		return $encrypted;
	}
1198427
public function toExt($data, $key = null, $array = false)
	{
		return $this->to(self::EXT, $data, $key, $array);
	}
810618
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('language.add.before', $data, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        if (!empty($data['default'])) {
            $this->setDefault($data['code']);
        }

        $default = $this->getDefaultData();
        $data += $default;

        if (empty($data['name'])) {
            $data['name'] = $data['code'];
        }

        if (empty($data['native_name'])) {
            $data['native_name'] = $data['name'];
        }

        $languages = $this->config->select('languages', array());
        $languages[$data['code']] = array_intersect_key($data, $default);

        $result = $this->config->set('languages', $languages);
        $this->hook->attach('language.add.after', $data, $result, $this);
        return (bool) $result;
    }
1012098
protected function _putData($key, $data)
    {
        $bool = $this->_validateDataKey($key, $data);
        if (!$bool) {
            return $this;
        }

        $hasData = $this->has($key);
        if ($this->_setPreparationOn) {
            $data = $this->_dataPreparation(
                $key,
                $data,
                $this->_dataPreparationCallbacks
            );
        }

        if (!$hasData
            || ($hasData && $this->_comparator($this->_DATA[$key], $data, '!=='))
        ) {
            $this->_changeData($key, $data, $hasData);
        }

        return $this;
    }
1313834
public static function push($key, $data)
    {
        if (is_callable($data)) {
            $content = $data();
        } else {
            $content = $data;
        }

        static::$with_meta = true;

        $cache = static::get($key);

        static::$with_meta = false;

        if (is_array($cache['content'])) {
            array_push($cache['content'], $content);
        } else {
            $cache['content'] .= $content;
        }

        return (bool) file_put_contents(
            static::makeHashFilename($key),
            serialize($cache)
        );
    }
1212759
public boolean disapproveTranslation(String appid, String langCode, String key) {
		if (StringUtils.isBlank(langCode) || key == null || getDefaultLanguageCode().equals(langCode)) {
			return false;
		}
		Sysprop s = dao.read(appid, keyPrefix.concat(langCode));
		if (s != null) {
			String value = getDefaultLanguage(appid).get(key);
			s.addProperty(key, value);
			dao.update(appid, s);
			if (LANG_CACHE.containsKey(langCode)) {
				LANG_CACHE.get(langCode).put(key, value);
			}
			updateTranslationProgressMap(appid, langCode, MINUS);
			return true;
		}
		return false;
	}
13549
public function data( $key )
    {

        // string, key clause
        if( is_scalar( $key ) ) {

            $dataTypes = $this->dataTypesGet( DataType::PRIMARY_KEYS );
            try {
                $key = array_combine(
                    array_keys( $dataTypes ),
                    explode( Base::KEY_SEPARATOR, $key )
                );
            } catch ( \Exception $e ) {
                throw new BadKeyException(
                    sprintf(
                        "Passed key `%s` needs %d fragments; it has %d",
                        $key,
                        count( $dataTypes ),
                        count( explode( Base::KEY_SEPARATOR, $key ) )
                    )
                );
            }

        // is array
        } elseif( is_array( $key ) and count( $key ) > 0 ) {

            $dataTypes = $this->dataTypesGet( array_keys( $key ) );

        // bad argument
        } else {
            throw new \InvalidArgumentException("Can't lookup data for entity with this argument -> " . print_r( $key, true ) );
        }

        // we got the right amount of keyFragments?
        if( count($key) !== count($dataTypes) ) {
            throw new \InvalidArgumentException(
                sprintf(
                    "The passed key (%s) can't be married to the repository keys (%s). Epic fail.",
                    print_r($key, true),
                    implode(',', array_keys($dataTypes) )
                )
            );
        }

        // build where clause
        $where = array();
        foreach( $dataTypes as $name => $dataType ) {

            $where[] = sprintf(
                "%s = %s",
                $this->db->quoteIdent( $name ),
                $dataType->toQueryTag()
            );
            $data[$name] = $key[$name];

        }

        // build query
        $query = new Query(
            sprintf(
                "SELECT * FROM ONLY %s WHERE %s",
                $this->db->quoteIdent( $this->__get('table') ),
                implode( ' AND ', $where )
            ),
            $data
        );

        $result = $this->db->query( $query );
        $data = $result->fetch( Result::FETCH_SINGLE | Result::FLATTEN_PREVENT );

        return $data;

    }
746926
public static function translate($key, $params = [], $language = null, Viewmodel $viewmodel = null) {
		
		$identifier = null;

		if(null !== $viewmodel) {
			$identifier = static :: load($viewmodel);
		}

		if(null === $key) {
			$key = '';
		}

		//Check if key is a string
		if(false === is_string($key)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
		}

		//Check if params is an array
		if(null !== $params && false === is_array($params)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
		}

		//Check if language is a string
		if(null !== $language && false === is_string($language)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($language)), E_USER_ERROR);
		}

		//Set default language if non given
		if(null === $language) {
			$language = static :: $language;
		}

		//If identifier is known (usually with a viewmodel as last param)
		if(null !== $identifier) {

			if(true === isset(static :: $translations[$identifier], static :: $translations[$identifier][$language])) {

				if(true === isset(static :: $translations[$identifier][$language][$key])) {
					return vsprintf(static :: $translations[$identifier][$language][$key], $params);
				}
			}
		}

		//Check the full resource for the translation
		foreach(static :: $translations as $translation) {

			if(true === isset($translation[$language][$key])) {
				return vsprintf($translation[$language][$key], $params);
			}
		}

		//No translation found
		return vsprintf($key, $params);
	}