Loads translation from a Translations instance, a file on an array.

@param Translations|string|array $translations

@return self
768192
public function loadTranslations($translations)
    {
        if (is_object($translations) && $translations instanceof Translations) {
            $translations = PhpArray::generate($translations, ['includeHeaders' => false]);
        } elseif (is_string($translations) && is_file($translations)) {
            $translations = include $translations;
        } elseif (!is_array($translations)) {
            throw new \InvalidArgumentException(
                'Invalid Translator: only arrays, files or instance of Translations are allowed'
            );
        }

        $this->addTranslations($translations);

        return $this;
    }
451155
public function addTranslation(\Haven\CmsBundle\Entity\TextContentTranslation $translations) {
        $translations->setParent($this);
        $this->translations[] = $translations;

        return $this;
    }
1047320
public function addTranslation(BlogContentTranslation $translations) {
        $translations->setParent($this);
        $this->translations[] = $translations;

        return $this;
    }
87159
private static function toArray(Translations $translations, $includeHeaders)
    {
        $messages = [];

        if ($includeHeaders) {
            $messages[''] = self::generateHeaders($translations);
        }

        foreach ($translations as $translation) {
            if ($translation->isDisabled()) {
                continue;
            }

            $messages[$translation->getOriginal()] = $translation->getTranslation();
        }

        return $messages;
    }
546330
public function load($files = [], $options = null)
    {
        if ($files != null) {
            $this->items = FileLoader::load($files, $options);
        }
        return $this;
    }
979100
public function setTranslations(Locale $locale, Translations $translations)
    {
        $this->translations[$locale->getID()] = [$locale, $translations];
    }
785378
public function initialize($translate)
	{
		$contexts = array();
		foreach ($translate as $order => $element)
		{
			$this->_validate_element($element, $order);
			$key = reset($element);
			if ($key === self::PARAMETER && count($element) === 2 && ($parameter = next($element)) && ! in_array($parameter, $contexts))
			{
				// Special case of 'parameter' definition without default value means that the
				// context is substituted.
				$contexts[] = $parameter;
			}
		}
		$this->_context_params = $contexts;
		$this->_translate = $translate;
		return $this;
	}
64538
public function addTranslation(\Haven\WebBundle\Entity\FaqTranslation $translations) {
        $translations->setParent($this);
        $this->translations[] = $translations;

        return $this;
    }
1018500
public function setTranslations() {
        $locales      = $this->getLocales();
        $translations = [];

        foreach($locales as $locale => $options) {
            $path = $this->getFileFullPath($locale);

            $contents = Support\get_file_contents($path);

            $translations[$locale] = $contents;
        }

        $this->translations = $this->loaded = $translations;

        return $this;
    }
1031606
public function loadTranslations($sFilePath, $sLanguage)
    {
        if(!file_exists($sFilePath))
        {
            return;
        }
        $aTranslations = require($sFilePath);
        if(!is_array($aTranslations))
        {
            return;
        }
        // Load the translations
        if(!array_key_exists($sLanguage, $this->aTranslations))
        {
            $this->aTranslations[$sLanguage] = [];
        }
        $this->_loadTranslations($sLanguage, '', $aTranslations);
    }
975371
public static function load(array $langs, $lang = null)
    {
        static::$langs = $langs;
        static::$lang = $lang ?: key($langs);
    }
901688
public function setTranslations(string $key, array $translations)
    {
        $this->guardAgainstUntranslatableAttribute($key);

        foreach ($translations as $locale => $translation) {
            $this->setTranslation($key, $locale, $translation);
        }

        return $this;
    }
590242
public function load($lang) {
        $langDir = MODULES_DIR . DS . RouteController::$currentModule . '/Views/lang/' . $lang;

        $files = glob($langDir . "/*.php");
        if (count($files) == 0) {
            throw new \Exception(ExceptionMessages::TRANSLATION_FILES_NOT_FOUND);
        }

        foreach ($files as $file) {
            $fileInfo = pathinfo($file);
            self::$translations[$fileInfo['filename']] = require_once $file;
        }
    }
783182
public function load($locale)
    {
        if (isset($this->cache[$locale])) {
            return $this->cache[$locale];
        }

        // New Translator array
        $trans = [];
        // Split the language: language, region, locale, etc
        $parts = string_split($locale, '-');

        do {
            // Create a path for this set of parts
            $path = implode(DS, $parts);

            // Remove the last part
            if ($files = $this->findLanguageFile($path)) {
                $trans = $this->loadMessages($files, $trans);
            }

            array_pop($parts);
        } while ($parts);

        // Cache the Translator table locally
        return $this->cache[$locale] = $trans;
    }
974033
private static function fromArray(array $messages, Translations $translations)
    {
        foreach ($messages as $original => $translation) {
            if ($original === '') {
                self::extractHeaders($translation, $translations);
                continue;
            }

            $translations->insert(null, $original)->setTranslation($translation);
        }
    }
632880
public function addTranslation(Translation $translation)
    {
        $key = "{$translation->language()}::{$translation->domain()}";
        $name = "{$translation->domain()}{$this->types[$translation->type()]}";
        $this->translationService()
            ->addTranslationFilePattern(
                $translation->type(),
                $translation->path(),
                "%s/{$name}",
                $translation->domain()
            );
        $this->translations[$key] = $translation;
        return $this;
    }
1278400
public function addTranslation(\Haven\PersonaBundle\Entity\EnterpriseTranslation $translations)
    {
        $translations->setParent($this);
        $this->translations[] = $translations;

        return $this;
    }