@param string $name
@param string $locale

@return AttributeValueTranslation
1343
protected function createAttributeValueTranslation($name, $locale)
    {
        $translation = new AttributeValueTranslation();
        $translation->setName($name);
        $translation->setLocale($locale);

        return $translation;
    }
970379
public function translate($entity, $locale)
    {
        $metadata = $this->metadataCollection->getMetadata($entity);
        if($metadata === null) {
            return null;
        }

        //translation data is stored inside the object
        if($locale === $this->defaultLocale) {
            return;
        }

        $accessor = PropertyAccess::createPropertyAccessor();   
        if($metadata !== null) {
            foreach($metadata->getProperties() as $property) {
                $strategy = $this->strategyResolver->getStrategy($property->getStrategy());
                $value = $strategy->getTranslation($entity, $property, $locale, $metadata);
                $accessor->setValue($entity, $property->getName(), $value);
            }
        }
    }
182272
public function getLocaleChain(Locale $locale)
    {
        $fallbackRule = $this->configuration->getFallbackRule();
        $localeChain = [(string)$locale => $locale];

        if ($fallbackRule['strict'] === true) {
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $localeChain[$localeIdentifier] = new Locale($localeIdentifier);
            }
        } else {
            $locale = $this->findBestMatchingLocale($locale);
            while ($locale !== null) {
                $localeChain[(string)$locale] = $locale;
                $locale = $this->getParentLocaleOf($locale);
            }
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $locale = new Locale($localeIdentifier);
                $locale = $this->findBestMatchingLocale($locale);
                while ($locale !== null) {
                    $localeChain[(string)$locale] = $locale;
                    $locale = $this->getParentLocaleOf($locale);
                }
            }
        }
        $locale = $this->configuration->getDefaultLocale();
        $localeChain[(string)$locale] = $locale;

        return $localeChain;
    }
778683
public function GetCulture( $locale )
	{
		if ( is_null( $locale ) || empty( $locale ) || $locale == XmlReservedNs::CollationCodepoint )
		{
			return null;
		}

		try
		{
			return Collator::create( $locale );
		}
		catch ( \Exception $ex )
		{
			throw new XPath2Exception( "XQST0076", Resources::XQST0076, $locale );
		}
	}
412794
private function parse($locale)
    {
        $parts = explode('_', $locale);

        $localization = new Localization();
        $localization->setLanguage($parts[0]);
        if (count($parts) > 1) {
            $localization->setCountry($parts[1]);
        }

        return $localization;
    }
130599
public static function setLocale($locale=null)
    {
        global $CFG, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD;

        // No internationalization support
        if ( isset($CFG->legacytranslation) ) {
            if ( ! function_exists('bindtextdomain') ) return;
            if ( ! function_exists('textdomain') ) return;
        }

        if ( isset($CFG->legacytranslation) && $locale && 
            strpos($locale, 'UTF-8') === false ) $locale = $locale . '.UTF-8';

        if ( $locale === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {

            if ( class_exists('\Locale') ) {
                try {
                    // Symfony may implement a stub for this function that throws an exception
                    $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
                } catch (exception $e) { }
            }
            if ($locale === null) { // Crude fallback if we can't use Locale::acceptFromHttp
                $pieces = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                $locale = $pieces[0];
            }
        }

        if ( $locale === null && isset($CFG->fallbacklocale) && $CFG->fallbacklocale ) {
            $locale = $CFG->fallbacklocale;
        }

        if ( $locale === null ) return;

        $locale = str_replace('-','_',$locale);
        if ( isset($CFG->legacytranslation) ) {
            putenv('LC_ALL='.$locale);
            setlocale(LC_ALL, $locale);
        }
        // error_log("setLocale=$locale");
        if ( $TSUGI_LOCALE != $locale ) $TSUGI_LOCALE_RELOAD = true;
        $TSUGI_LOCALE = $locale;
    }
650461
public function locale($locale = null)
    {
        if ($locale) {
            $this->_locale = $locale;
        }
        if ($this->_locale) {
            return $this->_locale;
        }
        if (isset($this->_params['locale'])) {
            return $this->_params['locale'];
        }
    }
505079
public function localizedSystemName($name, $locale)
    {
        if (null === $locale) {
            throw new InvalidLocaleException($locale);
        }

        return $this->formatLocalizedName('system_localized', $name, $locale);
    }
1322789
protected function getFormFieldName($locale = null)
    {
        if ( ! $locale) {
            return $this->field->key();
        }

        return $this->field->key() . '[' . $locale . ']';
    }
833637
public function setLocale(Locale $locale)
    {
        $this->currentLocale = $locale;
        $this->saveCurrentLocaleToSession();

        return $this->currentLocale;
    }
1226649
public function set($name, $value=null, $locale=null, $hook=true, $change=true, $silentException=false) {
		if(is_string($name))
			$name = strtolower($name);

		#setting multiple properties at once
		if(is_array($name)) {
			$vars = $name;
			$locale = $value;
			foreach($vars as $name=>$value)
				$this->set($name, $value, $locale, $hook);
			return $this;
		}

		#setting a property multiple translations at once
		if(is_array($locale)) {
			foreach($locale as $one)
				$this->set($name, $value[$one], $one, $hook);
			return $this;
		}

		$this->getDefinition()->processPreSet($this, $name, $value, $locale, $hook, $silentException);

		if($this->getDefinition()->hasProperty($name)) {
			if(!$locale)
				$locale = $this->getLocale();

			if($this->getDefinition()->property($name)->get('i18n') && $locale !== $this->getLocale()) {
				if($locale == 'all') {
					foreach($value as $locale => $v) {
						if(isset($this->data['translations'][$locale][$name]) && $v === $this->data['translations'][$locale][$name])
							continue;
						$this->data['translations'][$locale][$name] = $v;
						if($change) {
							if(!isset($this->translationschanged[$locale]))
								$this->translationschanged[$locale] = [];
							$this->translationschanged[$locale][$name] = true;
						}
					}
				}
				else {
					if(isset($this->data['translations'][$locale][$name]) && $value === $this->data['translations'][$locale][$name])
						return $this;
					$this->data['translations'][$locale][$name] = $value;
					if($change) {
						if(!isset($this->translationschanged[$locale]))
							$this->translationschanged[$locale] = [];
						$this->translationschanged[$locale][$name] = true;
					}
				}
			}
			else {
				if(isset($this->data['properties'][$name]) && $value === $this->data['properties'][$name])
					return $this;
				$this->data['properties'][$name] = $value;
				if($change) {
					if($this->getDefinition()->property($name)->get('i18n'))
						$this->translationschanged[$this->getLocale()][$name] = true;
					else
						$this->changed[$name] = true;
				}
			}
		}
		elseif($name !== 'translations' && $name !== 'properties') {
			if(is_array($value)) {
				$coll = new ManyCollection($this, $name);
				$value = $coll->setAll($value);
			}
			$this->data[$name] = $value;
		}

		return $this;
	}
597828
public function translateOrFirst($locale = null)
    {
        $translation = $this->translate($locale, true);

        if ( ! $translation)
        {
            $translation = $this->translations->first();
        }

        return $translation;
    }
86907
public function setTranslation(string $key, string $value = null, string $locale = null)
    {
        $this->throwExceptionIfAttributeIsNotTranslatable($key);

        $locale = $locale ?: config('app.locale');

        $translations = $this->getTranslations($key);

        if ($this->hasSetMutator($key)) {
            $value = $this->{'set'.Str::studly($key).'Attribute'}($value);
        }

        $translations[$locale] = $value;

        $this->attributes[$key] = json_encode($translations);

        return $this;
    }
81011
public function setLocale($locale)
    {
        if ($locale && !is_string($locale)) {
            throw new InvalidArgumentException("Invalid locale");
        }
        $this->locale = $locale;
        return $this;
    }
1153036
protected function getDefaultValue(\Asgard\Entity\Entity $entity, $name, $property, $locale) {
		if($entity->get($name, $locale) !== null)
			return $entity->get($name, $locale);
	}
118918
public function translate($locale = null)
    {
        if (!$locale) {
            $locale = \localizer\locale()->id();
        } else {
            $locale = (int)$locale;
        }

        return $this->getTranslation($locale);
    }
230089
public function setLocale($locale)
    {
        $this->locale = $locale;

        $this->getContentRoute()->setLocale($locale);

        return $this;
    }