Register function that creates the references and combines these with the translated strings

@param string $string_key
@param string $translation

@since 2.7.0
339402
private static function register( $string_key, $translation ) {

		/**
		 * Converts string into reference object variable
		 * Uses the same logic as JS to create the same references
		 */
		$ref = '__' . $string_key;

		// Add it to the strings localized
		self::$strings[ $ref ] = $translation;

		// Remove the old key
		unset( self::$strings[ $string_key ] );
	}
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;
    }
2104
private function saveStringToLocales()
    {
        $gettextEntries = $this->extractGettextStrings();

        $root = Strata::getRootPath();

        foreach ($gettextEntries as $translation) {
            $references = $translation->getReferences();
            $translation->deleteReferences();

            foreach ($references as $idx => $context) {
                $translation->addReference(str_replace($root, "~", $context[0]), $context[1]);
            }
        }

        foreach ($this->getLocales() as $locale) {
            $this->addGettextEntriesToLocale($locale, $gettextEntries);
        }
    }
1352855
private function copyKey(string $key): void
    {
        $source = $this->sourceDictionary->get($key);
        if ($source->isSourceEmpty()) {
            $this->logger->debug(
                '{key}: Is empty in source language and therefore skipped.',
                ['key' => $key]
            );
            return;
        }

        if (!$this->targetDictionary->has($key)) {
            $this->logger->log($this->logLevel, 'Adding key {key}.', ['key' => $key]);
            if ($this->dryRun) {
                return;
            }

            $this->targetDictionary->add($key);
        }
        $target = $this->targetDictionary->getWritable($key);

        $this->copySource($source, $target);
        $this->copyTarget($source, $target);
    }
456476
public void addTranslation (String oldname, String newname)
    {
        if (_translations == null) {
            _translations = Maps.newHashMap();
        }
        _translations.put(oldname, newname);
    }
1157605
public function addTranslation($locale, $group, $key)
    {
        if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return;

        // Extract the real key from the translation.
        if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) {
            $name = $match[1];
        } else {
            throw new TranslationException('Could not extract key from translation.');
        }

        $item = \DB::table('translations')
            ->where('locale', $locale)
            ->where('group', $group)
            ->where('name', $name)->first();

        $data = compact('locale', 'group', 'name');
        $data = array_merge($data, [
            'viewed_at' => date_create(),
            'updated_at' => date_create(),
        ]);

        if($item === null) {
            $data = array_merge($data, [
                'created_at' => date_create(),
            ]);
            \DB::table('translations')->insert($data);
        } else {
            if($this->_app['config']->get('translation-db.update_viewed_at')) {
                \DB::table('translations')->where('id', $item->id)->update($data);
            }
        }
    }
1291094
public function translate(string $key, array $args = [], string $lang = '')
    {
        if (!\is_string($key)) {
            throw new \InvalidArgumentException('The translate key must be a string.');
        }

        $key = \trim($key, ' ' . $this->separator);
        if ($key === '') { // '0' is equals False
            throw new \InvalidArgumentException('Cannot translate the empty key');
        }

        [$lang, $key] = $this->parseKey($key, $lang);

        // translate form current language. if not found, translate form fallback language.
        if (($value = $this->findTranslationText($key)) === null) {
            $value = $this->transByFallbackLang($key);

            // no translate text
            if ((string)$value === '') {
                if (!empty($args['__default'])) {
                    return $args['__default'];
                }

                return \ucfirst(Str::toSnake(\str_replace(['-', '_'], ' ', $key), ' '));
            }
        }

        return $args ? sprintf($value, ...$args) : $value;
    }
901688
public function setTranslations(string $key, array $translations)
    {
        $this->guardAgainstUntranslatableAttribute($key);

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

        return $this;
    }
981558
public function getTranslation($lang, $key, $array_support = false)
    {
        $translation = Grav::instance()['languages']->get($lang . '.' . $key, null);
        if (!$array_support && is_array($translation)) {
            return (string)array_shift($translation);
        }

        return $translation;
    }
552025
public function addTranslation(string $key, string $translation): MetaboxInterface
    {
        $this->l10n[$key] = $translation;

        return $this;
    }
981789
public function remove(string $key): void
    {
        if (null === $unit = $this->xliff->searchTranslationUnit($key)) {
            throw new TranslationNotFoundException($key, $this);
        }
        $unit->parentNode->removeChild($unit);

        $this->markChanged();
    }
979998
def translation_for(key, lang)
      self.translations.find_or_initialize_by(translation_key_id: key.id, lang: lang.to_s, translator_type: self.class.name)
    end
558005
public function addTranslation(Translation $translation)
    {
        if ($translation->getLanguage() === $this->masterLanguage) {
            throw new Exception('You cannot insert a new translation for master language');
        }

        $originalRepository = $translation
            ->getMasterTranslation()
            ->getRepository();

        $newRepositoryDirname = $originalRepository->getDirname();
        $newRepositoryDomain = $originalRepository->getDomain();
        $newRepositoryLanguage = $translation->getLanguage();

        /**
         * We check if this repository exists. If not, we create it.
         * Otherwise, we use existing one.
         */
        $expectedRepositories = array_filter(
            $this
                ->repositoryCollection
                ->getRepositories(),
            function (Repository $repository) use ($newRepositoryLanguage, $newRepositoryDomain, $newRepositoryDirname) {
                return
                    $repository->getDomain() === $newRepositoryDomain &&
                    $repository->getLanguage() === $newRepositoryLanguage &&
                    $repository->getDirname() === $newRepositoryDirname;
            }
        );

        $expectedRepository = reset($expectedRepositories);

        if (!($expectedRepository instanceof Repository)) {
            $newRepositoryPath = Repository::buildRepositoryPath(
                $newRepositoryDirname,
                $newRepositoryDomain,
                $newRepositoryLanguage
            );
            $expectedRepository = Repository::createEmptyByFilePath($newRepositoryPath);
            $this
                ->repositoryCollection
                ->addRepository($expectedRepository);
        }

        $expectedRepository->addTranslation($translation);
    }
730745
protected static function translate($key)
    {
        if (is_callable(static::getTranslatorFunction())) {
            $translated = call_user_func(static::getTranslatorFunction(), $key);
            if ($key !== $translated) {
                return $translated;
            } else {
                return '';
            }
        } else {
            return '';
        }
    }
1005198
protected function replace($translation, $replacement = []) {
        foreach ($replacement as $key => $value) {
            $translation = str_replace(':'.$key, $value, $translation);
        }

        return $translation;
    }
512686
private static void addTranslation(String text, int type) {
        TEXTS.put(type, text);
        LOOKUP.put(text, type);
    }
132835
private function createManyToOneRelation(array &$data, $key)
    {
        $uid = isset($data[$key]) ? (int)$data[$key] : 0;

        $data[$key] = ($uid > 0)
            ? \Tx_Oelib_MapperRegistry::get($this->relations[$key])->find($uid)
            : null;
    }