Refine the item properties

@param array $properties Properties
@param string $lang      Item language

@return array Refined properties
420589
protected static function createProperties(array $properties, &$lang)
    {
        // Extract the language (if present)
        $properties = self::createLanguage($properties, $lang);

        $mfProperties = [];
        foreach ($properties as $propertyName => $propertyValues) {
            // Process property values
            if (is_array($propertyValues)) {
                $mfProperties[] = (object)[
                    'profile' => self::MF2_PROFILE_URI,
                    'name'    => $propertyName,
                    'values'  => self::createProperty($propertyValues)
                ];
            }
        }

        return $mfProperties;
    }
389213
public function buildPropertiesString(array $properties)
    {
        $chunks = array();

        foreach ($properties as $property) {
            $chunks[] = $property->toString();
        }

        return implode(' ', $chunks);
    }
58739
public function getTranslatedProperties(core_kernel_classes_Resource $instance, $lang)
    {
        $returnValue = array();

        try {
            foreach ($instance->getTypes() as $clazz) {
                foreach ($clazz->getProperties(true) as $property) {
                    if ($property->isLgDependent() || $property->getUri() == OntologyRdfs::RDFS_LABEL) {
                        $collection = $instance->getPropertyValuesByLg($property, $lang);
                        if ($collection->count() > 0) {
                            if ($collection->count() == 1) {
                                $returnValue[$property->getUri()] = (string)$collection->get(0);
                            } else {
                                $propData = array();
                                foreach ($collection->getIterator() as $collectionItem) {
                                    $propData[] = (string)$collectionItem;
                                }
                                $returnValue[$property->getUri()] = $propData;
                            }
                        }
                    }
                }
            }
        } catch (\Exception $e) {
            print $e;
        }

        return (array) $returnValue;
    }
543196
public function export($lang = null)
    {
        $lang = $lang ? $this->lang($lang) : $this->default;

        if (!isset($this->imported[$lang])) {
            return [];
        }

        return $this->imported[$lang];
    }
263658
public function getTranslatedPropertyNameAssoc($locale, $mapping)
    {
        return [
            'property'   => $this->getTranslatedPropertyName($locale, $mapping['property']),
            'assoc'      => $this->getTranslatedPropertyName($locale, $mapping['assoc']),
            'assocNulls' => $this->getTranslatedPropertyName($locale, $mapping['assocNulls']),
        ];
    }
1349662
public function setLocale($lang, $territory = null)
    {
        $lang = strtolower($lang);

        $this->setObject(
            'locale',
            (isset($territory) ? $lang . '_' . strtoupper($territory) : $lang)
        );

        return $this;
    }
438178
protected function split_lang($lang)
	{
		if ( ! isset($this->_fallback_paths[$lang]))
		{
			$splits = array();
			$lang_parts = explode('-', $lang);
			while ($lang_parts)
			{
				$splits[] = implode('-', $lang_parts);
				array_pop($lang_parts);
			}
			$this->_fallback_paths[$lang] = $splits;
		}
		return $this->_fallback_paths[$lang];
	}
346856
protected function setLabelsProperty(array $properties)
    {
        $labels = $this->getLabelsFromProperties($properties);

        foreach ($labels as $label) {
            $this->addLabel($label->text, $label->isPlain, $label->lang);
        }

        return $this;
    }
537240
public function setActive($lang)
    {
        if ($this->validate($lang)) {
            $this->active = $lang;

            return $lang;
        }

        return false;
    }
157689
private function translateWithLang($key, $lang) {
        if (!isset($this->translations[$lang]) || !isset($this->translations[$lang][$key])) {
            return null;
        }

        return $this->translations[$lang][$key];
    }
325199
private function getTranslations($lang) {
    if (!isset($this->translations[$lang])) {
      $messageFile = $this->localeDir."/messages_".$lang.".php";
      if (file_exists($messageFile)) {
        require_once($messageFile);
        // store for later reference
        $this->translations[$lang] = ${"messages_$lang"};
      }
      else {
        $this->translations[$lang] = [];
      }
    }
    return $this->translations[$lang];
  }
1023735
public static function setLanguage($lang)
    {
        static::$_appLanguage = Yii::$app->language;

        Yii::$app->language = $lang;
    }
396742
public function getBranchesOfType($refName, $lang = null)
    {
        $this->initNodeVersions();

        $lang = null !== $lang ? $lang : $this->currentLocale->getCurrentLocale();

        return array_filter($this->branches, function (Branch $branch) use ($refName, $lang) {
            return $refName === $branch->getRefName() && $lang /* don’t use identity! */ == $branch->getLang();
        });
    }
142633
final protected static function get_property_error_message($property) {
        $properties = static::properties_definition();
        if (!isset($properties[$property]['message'])) {
            return new lang_string('invaliddata', 'error');
        }
        return $properties[$property]['message'];
    }
365993
public static function change($lang)
    {
        exception_if(!in_array($lang, self::$supported), LanguageNotSupportedException::class, $lang);

        self::$lang = $lang;
        self::$words = [];

        self::load();

        return true;
    }
440979
protected function parseProperties(array $properties)
    {
        $parsed = [];

        foreach ($properties as $propertyString) {
            if (!mb_strpos($propertyString, ':')) {
                list($key, $value) = $this->parseBooleanShortcut($propertyString);
                $parsed[Type::camelCase($key)] = $value;
                continue;
            }


            list($key, $value) = explode(':', $propertyString, 2);


            if (!$this->isNestedShortCut($value)) {
                $parsed[Type::camelCase($key)] = $value;
                continue;
            }

            $type = $this->stringToType(trim($value, '[]'));

            $parsed[Type::camelCase($key)] = $type;
        }

        return $parsed;
    }
1001078
protected function makeModelLabel($key, array $properties, $isPlain, $lang)
    {
        $text = $properties['text'];

        $this->replaceModelName($text, $this->modelName);

        $localeKey = sprintf('%s.%s', $this->localeGroup, $key);

        $label = new Label($text, $localeKey, $isPlain, $lang, $key);
        $label->template = $properties['template'];
        $label->isInFunction = $this->isInFunction($properties);

        return $label;
    }