make sure that the current user is a translator
497109
def validate_current_translator
      if tr8n_current_user_is_translator? and tr8n_current_translator.blocked?
        trfe("Your translation privileges have been revoked. Please contact the site administrator for more details.")
        return redirect_to(Tr8n::Config.default_url)
      end

      return if Tr8n::Config.current_user_is_translator?

      redirect_to("/tr8n/translator/registration")
    end
541362
def addTranslation(self,translation):
        '''
        '''
        if isinstance(translation, Translation):
            self.translations.append(translation)
        else:
            raise(TranslationError,
                   'translation Type should be Translation, not %s' % type(
                    translation)
                   )
484906
public function initialize() {
        if (!$this->isEnabled()) {
            return;
        }

        $current = null;

        // Determine via cookie
        if (!empty($_COOKIE['locale']) && isset($this->_locales[$_COOKIE['locale']])) {
            $current = $_COOKIE['locale'];

        // Determine locale based on HTTP headers
        } else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            $header = mb_strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']);

            if (mb_strpos($header, ';') !== false) {
                $header = mb_strstr($header, ';', true);
            }

            $header = explode(',', $header);

            if (count($header) > 0) {
                foreach ($header as $key) {
                    if (isset($this->_locales[$key])) {
                        $current = $key;
                        break;
                    }
                }
            }
        }

        // Set current to the fallback if none found
        if ($current === null) {
            $current = $this->_fallback->getCode();
        }

        // Check for a translator
        if (!$this->_translator) {
            throw new MissingTranslatorException('A translator is required for G11n message parsing');
        }

        $this->emit('g11n.onInit', [$this, &$current]);

        // Apply the locale
        $this->useLocale($current);
    }
1191719
function doUserLanguage(Userinfo $userinfo, Userinfo &$existinguser)
	{
		$changed = false;
		//Update the user language with the current used in Joomla or the one existing from an other plugin
		if (empty($userinfo->language)) {
			$user_lang = '';
			if (!empty($userinfo->params)) {
				$params = new Registry($userinfo->params);
				$user_lang = $params->get('language');
			}
			$userinfo->language = !empty($user_lang) ? $user_lang : Factory::getLanguage()->getTag();
		}
		if (!empty($userinfo->language) && isset($existinguser->language) && !empty($existinguser->language) && $userinfo->language != $existinguser->language) {
			try {
				$this->updateUserLanguage($userinfo, $existinguser);
				$existinguser->language = $userinfo->language;
				$this->debugger->addDebug(Text::_('LANGUAGE_UPDATED') . ' : ' . $existinguser->language . ' -> ' . $userinfo->language);

				$changed = true;
			} catch (Exception $e) {
				$this->debugger->addError(Text::_('LANGUAGE_UPDATED_ERROR') . ' ' . $e->getMessage());
			}
		} else {
			//return a debug to inform we skipped this step
			$this->debugger->addDebug(Text::_('LANGUAGE_NOT_UPDATED'));
		}
		return $changed;
	}
294031
private function checkDisableInput()
    {
        
        $this->checkAuthInput();
        $defaults = array('language' => null);
        $this->options = array_merge($defaults, $this->options);
        if ($this->options['language'] == null){
            $this->err("Please provide the 'language' parameter.", true);
        }
        
    }
539376
protected function registerTraslator()
    {
        $this->app->singleton('translator', function ($app) {
            $loader = $app['translation.loader'];

            // When registering the translator component, we'll need to set the default
            // locale as well as the fallback locale. So, we'll grab the application
            // configuration so we can easily get both of these values from there.
            $locale = $app['config']['app.locale'];

            $trans = new Translator($loader, $locale);

            $trans->setFallback($app['config']['app.fallback_locale']);

            return $trans;
        });
    }
782559
private function checkAdminUser($wtname, $wtuser, $wtpass, $wtemail): string
    {
        if ($wtname === '' || $wtuser === '' || $wtpass === '' || $wtemail === '') {
            return I18N::translate('You must enter all the administrator account fields.');
        }

        if (mb_strlen($wtpass) < 6) {
            return I18N::translate('The password needs to be at least six characters long.');
        }

        return '';
    }
164862
def ensure_user(data)
      if @users.include?(data['id'].to_i)
        @users[data['id'].to_i]
      else
        @users[data['id'].to_i] = User.new(data, self)
      end
    end
901216
async def get_user_locale(self, action: str, args: Tuple[Any]) -> str:
        
        user: types.User = types.User.get_current()
        locale: Locale = user.locale

        if locale:
            *_, data = args
            language = data['locale'] = locale.language
            return language
1135728
protected function approveTranslation($access, TranslationEntity $translation, UserEntity $user, $packageVersionID)
    {
        if ($access < Access::ADMIN) {
            throw new UserMessageException(t('Access denied'));
        }
        if ($translation->isCurrent()) {
            throw new UserMessageException(t('The selected translation is already the current one'));
        }
        $translationID = $translation->getID();
        $translations = $this->convertTranslationToGettext($translation, false);
        $importer = $this->app->make(Importer::class);
        $importer->import($translations, $translation->getLocale(), $user, ImportOptions::forAdministrators());
        $this->getEntityManager()->clear();
        $translation = $this->app->make(TranslationRepository::class)->find($translationID);
        $result = $this->app->make(Editor::class)->getTranslations($translation->getLocale(), $translation->getTranslatable());

        return $this->app->make(ResponseFactoryInterface::class)->json($result);
    }
1239130
def enable(ctx):
    """"""

    if ctx.obj['username'] is None:
        log('Specify the username with "iso db user --username ..."')
        return

    change_user = ctx.obj['db'].objectmodels['user'].find_one({
        'name': ctx.obj['username']
    })

    change_user.active = True
    change_user.save()
    log('Done')
1194946
public static function bootTranslatable()
    {
        static::addGlobalScope(new TranslatableScope);
        try {
            $observer = app(TranslatableObserverContract::class);
            static::observe($observer);
        } catch (\Exception $exception) {}
    }
956352
def translated(self, value, type):
        
        if value is not None:
            resolved = type.resolve()
            return resolved.translate(value)
        else:
            return value
26221
function translate( $context, $source, $comment = null )
    {
        $msg = $this->findMessage( $context, $source, $comment );
        if ( $msg !== null )
        {
            return $msg["translation"];
        }

        return null;
    }
506860
function(user) {
      if (Parse.User._currentUser !== user) {
        Parse.User.logOut();
      }
      user._isCurrentUser = true;
      Parse.User._currentUser = user;
      Parse.User._currentUserMatchesDisk = true;

      var json = user.toJSON();
      json._id = user.id;
      json._sessionToken = user._sessionToken;
      Parse.localStorage.setItem(
          Parse._getParsePath(Parse.User._CURRENT_USER_KEY),
          JSON.stringify(json));
    }
981643
def get_translator (domain, directory, languages=None,
                    translatorklass=Translator, fallback=False,
                    fallbackklass=NullTranslator):
    """"""
    translator = gettext.translation(domain, localedir=directory,
            languages=languages, class_=translatorklass, fallback=fallback)
    if not isinstance(translator, gettext.GNUTranslations) and fallbackklass:
        translator = fallbackklass()
    return translator
631007
protected function updateLanguage()
    {
        $this->controlAccess('language_edit');

        if ($this->language->update($this->data_language['code'], $this->getSubmitted())) {
            $this->redirect('admin/settings/language', $this->text('Language has been updated'), 'success', true);
        }

        $this->redirect('', $this->text('Language has not been updated'), 'warning', true);
    }