Fill a translation key in all languages.

@return void
977286
private function fillKey()
    {
        $languages = $this->manager->languages();

        if ($this->languageKey) {
            if (! in_array($this->languageKey, $languages)) {
                $this->error(sprintf('Language (%s) could not be found!', $this->languageKey));

                return;
            }

            // If a language key was specified then we prompt for it only.
            $languages = [$this->languageKey];
        }

        $values = $this->collectValues($languages);

        $this->manager->fillKeys(
            str_replace($this->packageName.'::', '', $this->fileName),
            [$this->key => $values]
        );

        foreach ($values as $languageKey => $value) {
            $this->line("<fg=yellow>{$this->fileName}.{$this->key}:{$languageKey}</> was set to \"<fg=yellow>{$value}</>\" successfully.");
        }
    }
505812
protected function refreshLanguage()
    {
        $this->controlToken('refresh');

        $code = $this->getQuery('refresh');
        if (!empty($code) && $this->access('language_edit') && $this->translation->refresh($code)) {
            $this->redirect('', $this->text('Language has been refreshed'), 'success');
        }
    }
1367512
public function setTranslations($key, array $translations)
    {
        $this->guardAgainstNonTranslatableAttribute($key);

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

        return $this;
    }
970758
protected function setLanguages()
    {
        if ((count($this->languages) === 0) && ! empty($_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ])) {
            $this->languages = explode(
                ',',
                preg_replace(
                    '/(;\s?q=[0-9\.]+)|\s/i',
                    '',
                    strtolower(trim($_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ]))
                )
            );
        }

        if (count($this->languages) === 0) {
            $this->languages = ['Undefined'];
        }
    }
1181816
public function getTranslationsForKey($key) {
		$this->getAllTranslationByLanguage();
		$translations = [];
		foreach ($this->messages as $language => $messages) {
			foreach ($messages as $messageKey => $message) {
				if($key == $messageKey) {
					$translations[$language] = $message;
				}
			}
		}
		return $translations;
	}
253753
private function renameKey()
    {
        try {
            list($file, $key) = explode('.', $this->argument('oldKey'), 2);
        } catch (\ErrorException $e) {
            $this->error('Could not recognize the key you want to rename.');

            return;
        }

        if (Str::contains($this->argument('newKey'), '.')) {
            $this->error('Please provide the new key must not contain a dot.');

            return;
        }

        $newKey = preg_replace('/(\w+)$/i', $this->argument('newKey'), $key);

        $files = $this->manager->files()[$file];

        $currentValues = [];

        foreach ($files as $languageKey => $filePath) {
            $content = Arr::dot($this->manager->getFileContent($filePath));

            $currentValues[$languageKey] = isset($content[$key]) ? $content[$key] : '';
        }

        $this->manager->removeKey($file, $key);

        $this->manager->fillKeys(
            $file,
            [$newKey => $currentValues]
        );
    }
685529
public function loadTranslations($languages)
    {
        $languages = (array)$languages;

        foreach ($languages as $language) {
            $this->getTranslation($language);
        }
    }
202676
protected function searchDefaultTranslate()
    {
        // call in: loadInternalData()
        if ($this->searchContent) {
            $this->listAllDefaultTranslate = $this->searchContent->getList();

            if ($this->dictionary && $this->listAllDefaultTranslate) {
                // if define dictionary
                foreach ($this->listAllDefaultTranslate as $identification => $item) {
                    if ($item['type'] == 'translation') {
                        $message = $item['value'];
                        // save only not exist identification and only string message or identification is same like dictionary index (default translate)
//                        if ((!isset($this->dictionary[$identification]) && !is_array($message)) || $this->dictionary[$identification] == $identification) {
                        if (!isset($this->dictionary[$identification]) || $this->dictionary[$identification] == $identification) {
                            // call only save default value load from files
                            $this->saveTranslate($identification, $message);
                        }
                    }
                }
            }
        }
    }
56567
public function fillKeyField(array &$fields)
    {
        $model   = $this->config->getDataModel();
        $keyName = $model->getKeyName();

        //add the primary key field, which will be uneditable, but part of the data model
        if ($this->config->getType() === 'model' && !isset($fields[$keyName])) {
            $keyField         = $this->make($keyName, array('visible' => false));
            $fields[$keyName] = $keyField->getOptions();
        }
    }
573884
protected function configure()
    {
        $this
            ->setName('chill:main:languages:populate')
            ->setDescription('Load or update languages in db. This command does not delete existing '.
                'languages, but will update names according to available languages')
            ->addOption(
                    self::INCLUDE_REGIONAL_VERSION,
                    null,
                    InputOption::VALUE_NONE,
                    'Include the regional languages. The regional languages are languages with code containing _ excepted '
                        . implode(',', $this->regionalVersionToInclude) . '.')
            ->addOption(
                    self::INCLUDE_ANCIENT,
                    null,
                    InputOption::VALUE_NONE,
                    'Include the ancient languages that are languages with code '
                        . implode(', ', $this->ancientToExclude) . '.')
            ;
    }
966530
private function _initTranslation()
    {
        $module = Yii::$app->getModule('translatemanager');

        if ($module->checkAccess() && $this->_checkRoles($module->roles)) {
            Yii::$app->session->set(Module::SESSION_KEY_ENABLE_TRANSLATE, true);
        }
    }
468899
public static function registerTranslations()
    {
        if (!isset(Yii::$app->i18n->translations[static::getThemePath() . '/*']) && !isset(Yii::$app->i18n->translations[static::getThemePath()])) {
            Yii::$app->i18n->translations[static::getThemePath() . '/*'] = [
                'class' => 'yii\i18n\PhpMessageSource',
                'sourceLanguage' => 'en-US',
                'basePath' => static::getThemePath() . '/messages',
                'fileMap' => [
                    static::getThemePath() . '/message' => 'message.php',
                ],
            ];
        }
    }
1095574
protected function translate($key)
  {
    $key = strtoupper($key);
    if ( isset(self::$translations[$key]) ){
      return self::$translations[$key];
    }
    
    return $key;
  }
1075965
protected function setLanguage()
	{
		$matches = array();
		if ($this->owner->user->hasState('__locale'))
			$language = $this->owner->user->getState('__locale');
		else if (preg_match('/^\/([a-z]{2}(?:_[a-z]{2})?)\//i',
			substr($this->owner->request->url, strlen($this->owner->baseUrl)), $matches) !== false
			&& isset($matches[1], $this->languages[$matches[1]]))
			$language = $matches[1];
		else
			$language = $this->defaultLanguage;

		$this->owner->language = $language;
	}
115390
protected function addLanguage()
    {
        $this->controlAccess('language_add');

        if ($this->language->add($this->getSubmitted())) {
            $this->redirect('admin/settings/language', $this->text('Language has been added'), 'success');
        }

        $this->redirect('', $this->text('Language has not been added'), 'warning');
    }
161629
public function translate($key, $translation, $locale = null) {
        $locale = $this->locale($locale);

        return Lang::get($key, null, $locale);
    }
738528
protected function registerTranslationBindings()
    {
        $this->singleton('translator', function () {
            $this->configure('app');

            $this->instance('path.lang', $this->getLanguagePath());

            $this->register('Orchestra\Translation\TranslationServiceProvider');

            return $this->make('translator');
        });
    }