Save translate.

@param string $identification
@param        $message
@param null   $idLocale
@return string
@throws \Dibi\Exception
5062
protected function saveTranslate(string $identification, $message, $idLocale = null): string
    {
        $values = [
            'id_locale' => $idLocale ?: $this->locale->getIdDefault(),   // linked to locale
            'id_ident'  => $this->getIdIdentification($identification), // linked to indentity
            'translate' => $message,
        ];
        //TODO bacha na NULL hodnoty!
        $this->connection->insert($this->tableTranslate, $values)->onDuplicateKeyUpdate('%a', $values)->execute();

        $this->dictionary[$identification] = $message;   // add to dictionary

        // internal clean cache
        $this->cleanCache();

        return $message;    // return message
    }
1097752
public void send(final long identifier, final SpecificRecord message) {
    if (sender != null) {
      sender.onNext(serializer.write(message, identifier));
    } else {
      final String msgClassName = message.getClass().getCanonicalName();
      LOG.log(Level.SEVERE, "Attempt to send message [{0}] before network is initialized", msgClassName);
      throw new RuntimeException("NetworkTransport not initialized: failed to send " + msgClassName);
    }
  }
21312
private function trans(string $message, array $params, string $domain = 'FormTheme'): ?string
    {
        if (isset($params['transChoice'])) {
            $transChoice = intval($params['transChoice']);
            unset($params['transChoice']);
            $x = $this->translator->transChoice($message, $transChoice, $params, $domain);
            return $x;
        }
        return $this->translator->trans($message, $params, $domain);
    }
858304
public function t($message, $param = [], $name = 'app') {
        return Factory::i18n()->translate($message, $param, $name);
    }
729299
public function translate($message, $textDomain = 'default', $locale = null)
    {
        $textDomain = $textDomain !== 'default' ? $textDomain : $this->domain();
        $locale = $locale ?: (string) $this->currentLanguage();

        return $this->translationService()->translate($message, $textDomain, $locale);
    }
240308
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
    {
        @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED);

        if (!$this->formatter instanceof ChoiceMessageFormatterInterface) {
            throw new LogicException(sprintf('The formatter "%s" does not support plural translations.', \get_class($this->formatter)));
        }

        if (null === $domain) {
            $domain = 'messages';
        }

        $id = (string) $id;
        $catalogue = $this->getCatalogue($locale);
        $locale = $catalogue->getLocale();
        while (!$catalogue->defines($id, $domain)) {
            if ($cat = $catalogue->getFallbackCatalogue()) {
                $catalogue = $cat;
                $locale = $catalogue->getLocale();
            } else {
                break;
            }
        }

        if ($this->hasIntlFormatter && $catalogue->defines($id, $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
            return $this->formatter->formatIntl($catalogue->get($id, $domain), $locale, ['%count%' => $number] + $parameters);
        }

        return $this->formatter->choiceFormat($catalogue->get($id, $domain), $number, $locale, $parameters);
    }
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);
            }
        }
    }
993536
public function actionSave($id = null, $languageId)
    {
        if (!empty($languageId)) {
            if (!empty($id)) {

                $model = $this->findModel($id);
                if (empty($model)) {
                    throw new NotFoundHttpException;
                }
                $modelTranslation = $this->findModelTranslation($id, $languageId);
                if (empty($modelTranslation)) {
                    $modelTranslation = new ProductAvailabilityTranslation();
                }
            }
            else {
                $model = new ProductAvailability();
                $modelTranslation = new ProductAvailabilityTranslation();
            }
        }
        else throw new BadRequestHttpException();


        if ($modelTranslation->load(Yii::$app->request->post())) {

            $model->save(false);

            $modelTranslation->availability_id = $model->id;
            $modelTranslation->language_id = $languageId;
            if ($modelTranslation->validate()) {

                $modelTranslation->save();
                $this->trigger(self::EVENT_AFTER_CREATE_OR_UPDATE_PRODUCT_AVAILABILITY,
                    new ProductAvailabilityEvent(['availability' => $model]));

                return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]);
            }
        }
        return $this->render('save', [
            'model' => $model,
            'modelTranslation' => $modelTranslation,
            'languages' => Language::find()->all(),
            'selectedLanguage' => Language::findOne($languageId)
        ]);

    }
302281
private function saveI18nValues($firstResult, $requestParams, &$locale) {
       // file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);
        if(!$this->entity instanceof AbstractI18nEntity || is_null($locale)) {
            
            return;
        }
       // file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);
        
        $parsedLocales = $locale;//$this->parseJson($locale); 
       
        foreach($parsedLocales as $parsedLocale => $row) {
  
            $params = array($this->entity->getI18nIdentifier() => $firstResult, 'locale' => $parsedLocale);

            //need to add this, since it is what associates us to the parent table
            $row[$this->entity->getI18nIdentifier()] = $firstResult;
            $row['locale'] = $parsedLocale;
            $this->getQueryBuilder()->setValues($row);
            //file_put_contents('/var/www/db-repo/logs/test.log', "i18nquery:row ".print_r($row, true) ."\r\n", FILE_APPEND);
        
            $this->getQueryBuilder()->where($params);
            $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::SAVE_QUERY, QueryBuilder::CHILD_ONLY);

            $this->query($query);
           
        }

    }
1336512
protected function getTranslation($id, $domain, $locale, $fallbacks) {
		// Is initialize of the catalog need ?
		if (! isset($this->initializedCatalogs[$locale][$domain])) {
			$this->initCatalogs($locale, $domain);
		}
		
		// Is failure occurred ?
		if (! isset($this->catalogs[$locale][$domain][$id])) {
			if (empty($fallbacks)) {
				return;
			}
			
			$fallbackLocale = array_shift($fallbacks);
			
			return $this->getTranslation($id, $domain, $fallbackLocale, $fallbacks);
		}
		
		return $this->catalogs[$locale][$domain][$id];
	}
750560
protected function translateMessage($message, array $parameters = array())
    {
        return $this->translator->trans($message, $parameters, $this->transDomain);
    }
738690
protected function translate($message, $parameters = array())
    {
        return $this->translator->trans($message, $parameters, $this->translationDomain);
    }
158915
public function trans($id, array $parameters = [], $domain = null, $locale = null)
    {
        if (null === $domain) {
            $domain = 'messages';
        }

        $format = $this->getCatalogue($locale)->get((string) $id, $domain);

        if ($format instanceof Closure) {
            // @codeCoverageIgnoreStart
            try {
                $count = (new ReflectionFunction($format))->getNumberOfRequiredParameters();
            } catch (ReflectionException $exception) {
                $count = 0;
            }
            // @codeCoverageIgnoreEnd

            return $format(
                ...array_values($parameters),
                ...array_fill(0, max(0, $count - count($parameters)), null)
            );
        }

        return parent::trans($id, $parameters, $domain, $locale);
    }
1110434
public function addMessage( $message, $instance = null )
	{
		$sql = <<<SQL
INSERT INTO
	i18n_messages
SET
	message 	= ?,
	instance	= ?
SQL;

		return $this->Execute( $sql, array(
		                                  'tag' => 'Add message',
		                                  $message,
		                                  $instance
		                             ) );
	}
921432
public function getTranslation($id, $parameters = [], $locale = null)
    {
        $parameters = array_merge($this->replacementPatterns, $parameters);

        return $this->translator->trans($id, $parameters, null, $locale);
    }
345934
public function trans($id, array $parameters = [], $domain = 'messages', $locale = null)
    {
        $line = Arr::get($this->lines, $id);

        if (is_null($line)) {
            return $id;
        }

        return $this->makeReplacements($line, $parameters);
    }
849143
public function getTranslation($iso, $id)
    {

        $id_element = $this->model->hasBeenTranslated($this->model->getTable(), $id, $iso);
        if (!empty($id_element)) {
            return redirect()->to(action($this->getControllerNameForAction().'@getEdit', $id_element));
        }

        $model = (!empty($id) || $id === "0") ? $this->model->withoutTranslation()->findOrFail($id) : $this->model;
        $form  = FormBuilder::create(get_class($this->form), [
            'model' => $model
        ])
            ->remove('id')
            ->add('translation_iso', 'hidden', ['default_value' => $iso])
            ->add('translation_id_source', 'hidden', ['default_value' => $id])
            ->add('local_override', 'hidden', ['default_value' => $iso]);

        $form_content = view('form-builder::form.components.formgenerator.full', [
            'form' => $form
        ]);

        $this->layoutManager->add([
            'content' => view('expendable::admin.form.state.form', [
                'form' => $form_content
            ])
        ]);

        return $this->layoutManager->render();
    }