Merge the comments of two translations.

@param Translation $from
@param Translation $to
@param int         $options
422485
public static function mergeComments(Translation $from, Translation $to, $options = self::DEFAULTS)
    {
        if ($options & self::COMMENTS_THEIRS) {
            $to->deleteComments();
        }

        if (!($options & self::COMMENTS_OURS)) {
            foreach ($from->getComments() as $comment) {
                $to->addComment($comment);
            }
        }
    }
230326
private function resolveTo($to, $from)
    {
        if (is_string($to)) {
            $to = strtolower($to);
        }

        if ($to === 'down') {
            $to = $this->versionCollection->getPreviousVersion($from);
        }

        if ($to === 'up') {
            $to = $this->versionCollection->getNextVersion($from);
        }

        if ($to === 'bottom') {
            $to = 0;
        }

        if ($to === 'top' || null === $to) {
            $to = $this->versionCollection->getLatestVersion();
        }

        if (0 !== $to && false === strtotime($to)) {
            throw new MigratorException(sprintf(
                'Unknown migration action "%s". Known actions: "%s"',
                $to,
                implode('", "', $this->actions)
            ));
        }

        if (0 !== $to && !$this->versionCollection->has($to)) {
            throw new MigratorException(sprintf(
                'Unknown version "%s"', $to
            ));
        }

        return $to;
    }
739221
public function rename($from, $to)
    {
        // TODO: add directories support

        $contents = self::cache()->get($from);
        if (false === $contents) {
            return false;
        }

        self::cache()->delete($from);
        self::cache()->set($to, $contents);

        return true;
    }
49102
public function move($from, $to)
    {
        $call = 'fileops/move';
        $params = array(
                'root' => $this->root,
                'from_path' => $this->normalisePath($from),
                'to_path' => $this->normalisePath($to),
        );
        $response = $this->fetch('POST', self::API_URL, $call, $params);
        return $response;
    }
573384
public function shift( $from, $to, $errorFlag = null )
	{
		if ( is_null( $errorFlag ) )
		{
			$this->println( "goto\tfrom state $from to $to" );
			return;
		}

		switch (errorFlag)
		{
			default:				// normally
				$this->println( "shift\tfrom state $from to $to" );
				break;
			case 0: case 1: case 2:	// in error recovery
				$this->println( "shift\tfrom state $from to $to\t$errorFlag left to recover" );
				break;
			case 3:					// normally
				$this->println( "shift\tfrom state $from to $to\ton error" );
				break;
		}
	}
167468
private function copyFromTo($from, $to)
    {
        $directory = dirname($to);
        if (!is_dir($directory)) {
            mkdir($directory, 0777, true);
        }

        copy($from, $to);
    }
969399
protected function moveUploadedFile($from, $to)
    {
        return $this->unitTest ? copy($from, $to) : @move_uploaded_file($from, $to);
    }
536129
public function moveFilesWildcard($from, $to)
    {
        coollect(glob($this->dataDir($from)))->each(function ($from) use ($to) {
            $this->mkDir($dir = $this->dataDir($to));

            rename($from, $dir.'/'.basename($from));
        });
    }
37471
public function mergeWith(Translations $translations, $options = Merge::DEFAULTS)
    {
        Merge::mergeHeaders($translations, $this, $options);
        Merge::mergeTranslations($translations, $this, $options);

        return $this;
    }
706724
protected function addRedirect($from, $to)
    {
        $fromLink = $this->stripLinkBase($from);
        $toLink = $this->stripLinkBase($to);

        // If the redirect "from" is already registered with a "to", don't override it. This ensures
        // that the first version processed is treated as the canonical version.
        if (!isset($this->redirects[$fromLink])) {
            $this->redirects[$fromLink] = $toLink;
        }
    }
177926
public function rename($from, $to) {
		return $this->getState()->rename($this->buildUrl($from), $this->buildUrl($to));
	}
362521
public function saveTranslationsAction($packageKey, $fromLang, $toLang, array $translationUnits) {
		$originalMatrix = $this->generateTranslationMatrix($packageKey, $fromLang, $toLang);
		$matrixToSave = array();

		foreach ($translationUnits as $translationUnit => $value) {
			if (isset($value[$toLang]) && $value[$toLang] != '') {
				$matrixToSave[$translationUnit] = $originalMatrix[$translationUnit];
				if (isset($matrixToSave[$translationUnit]['target'])) {
					$matrixToSave[$translationUnit]['oldTarget'] = $matrixToSave[$translationUnit]['target'];
				}
				$matrixToSave[$translationUnit]['target'] = $value[$toLang];
			}
		}

		// Create the Xliff file to be written to disk later on
		$xliffView = new \TYPO3\Fluid\View\TemplateView();
		$path = 'resource://Mrimann.XliffTranslator/Private/Templates/Standard/Xliff.xlf';

		$xliffView->setControllerContext($this->getControllerContext());
		$xliffView->setTemplatePathAndFilename($path);
 		$xliffView->assign('matrixToSave', $matrixToSave);

		// backup the original file before overwriting
		$this->backupXliffFile($packageKey, $toLang);

		// check if the file exists (or create an empty file in case these are the first translations)
		if (!is_dir(dirname($this->getFilePath($packageKey, $toLang)))) {
			mkdir(dirname($this->getFilePath($packageKey, $toLang)));
		}
		if (!is_file($this->getFilePath($packageKey, $toLang))) {
			touch($this->getFilePath($packageKey, $toLang));
		}

		// write the file
		$outputPath = $this->getFilePath($packageKey, $toLang);
		file_put_contents($outputPath, $xliffView->render());

		// redirect the user back to the translation page
		$this->addFlashMessage(
			'Your translations were successfully saved!',
			'Yippie!',
			'OK'
		);

		$this->redirect(
			'translate',
			'Standard',
			'Mrimann.XliffTranslator',
			array(
				'packageKey' => $packageKey,
				'fromLang' => $fromLang,
				'toLang' => $toLang
			)
		);
	}
471513
private function mergeForms(Form $to, Form $from)
    {
        foreach ($from->all() as $name => $field) {
            $fieldReflection = new \ReflectionObject($field);
            $nodeReflection  = $fieldReflection->getProperty('node');
            $valueReflection = $fieldReflection->getProperty('value');

            $nodeReflection->setAccessible(true);
            $valueReflection->setAccessible(true);

            $isIgnoredField = $field instanceof InputFormField &&
                in_array($nodeReflection->getValue($field)->getAttribute('type'), array('submit', 'button', 'image'), true);

            if (!$isIgnoredField) {
                $valueReflection->setValue($to[$name], $valueReflection->getValue($field));
            }
        }
    }
37580
public function translate(string $from, string $to) : Text
    {
        return $this->pipe(
            function (string $value) use ($from, $to) : string {
                return strtr($value, $from, $to);
            }
        );
    }
1248235
public function rename($from, $to): bool
    {
        $key = $this->search($from);

        if (\is_null($key)) {
            return false;
        }

        $this->items[$key] = $this->getKeyword($to)->getSlug();

        return true;
    }
253335
public function replace($from, $to)
    {
        if (\is_callable($to)) {
            $to = $to($from, $this->string);
        }

        $this->string = \str_replace($from, $to, $this->string);
        return $this;
    }
1287519
public static function convert($input, $from, $to)
    {
        if (!method_exists(self::class, $to)) {
            return $input;
        }
        
        if (in_array($from, ['camel', 'pascal'])) {
            $converted = self::$from($input);
            $converted = preg_replace('/([a-z])([A-Z])/', '$1 $2', $converted);
            $converted = preg_replace('/(\D)?(\d+)(\D)?/', '$1 $2 $3', $converted);
            return self::$to($converted);
        }
        
        if (method_exists(self::class, $from)) {
            return self::$to(self::$from($input));
        }
        
        return self::$to($input);
    }