load the translated data of an instance regarding the given lang

@throws common_exception_BadRequest
@throws common_exception_Error
@throws tao_models_classes_MissingRequestParameterException

@return void
967134
public function getTranslatedData()
    {
        if(!$this->isXmlHttpRequest()){
            throw new common_exception_BadRequest('wrong request mode');
        }
        $data = array();
        if($this->hasRequestParameter('lang')){
            $data = tao_helpers_Uri::encodeArray(
                $this->getClassService()->getTranslatedProperties(
                    $this->getCurrentInstance(),
                    $this->getRequestParameter('lang')
                ),
                tao_helpers_Uri::ENCODE_ARRAY_KEYS);
        }
        $this->returnJson($data);
    }
124631
public function call() {
	    if (!$this->hasRequestParameter('ltiConsumerUri')) {
	        throw new common_exception_MissingParameter('ltiConsumerUri', get_class($this));
	    }
		if (!$this->hasRequestParameter('ltiLaunchUrl')) {
	        throw new common_exception_MissingParameter('ltiLaunchUrl', get_class($this));
	    }
	    $ltiConsumer = new tao_models_classes_oauth_Credentials($this->getRequestParameter('ltiConsumerUri'));
	    $launchUrl =  $this->getRequestParameter('ltiLaunchUrl');
	    
	    $serviceCallId = $this->getServiceCallId().'_c';
	    
	    $session = common_session_SessionManager::getSession();
	    
	    $roles = array();
	    foreach ($session->getUserRoles() as $role) {
	        foreach (LtiUtils::mapTaoRole2LTIRoles($role) as $ltiRole) {
	            $roles[] = $ltiRole;
	        }
	    }
	    
	    $ltiData = array(
	        'lti_message_type' => 'basic-lti-launch-request',
	        'lti_version' => 'LTI-1p0',
	        
	        'resource_link_id' => rand(0, 9999999),
	        'resource_link_title' => 'Launch Title',
	        'resource_link_label' => 'Launch label',
	        
	        'context_id' => $serviceCallId,
	        'context_title' => 'Launch Title',
	        'context_label' => 'Launch label',
	        
	        'user_id' => $session->getUserUri(),
	        'roles' => implode(',',$roles),
	        'lis_person_name_full' => $session->getUserLabel(),
	        
	        'tool_consumer_info_product_family_code' => PRODUCT_NAME,
	        'tool_consumer_info_version' => TAO_VERSION
        );
	    
	    // @todo add:
	    /*
	    user_id:
	    roles:
	    
	    lis_person_name_full:
	    lis_person_name_family:
	    lis_person_name_given:
	    lis_person_contact_email_primary:
	    lis_person_sourcedid:
	    
	    tool_consumer_info_product_family_code:
	    tool_consumer_info_version:
	    tool_consumer_instance_guid:
	    tool_consumer_instance_description:
	    */
	    $request = new common_http_Request($launchUrl, common_http_Request::METHOD_POST, $ltiData);
	    $service = new tao_models_classes_oauth_Service();
	    $signedRequest = $service->sign($request, $ltiConsumer);
	    
	    $this->setData('launchUrl', $launchUrl);
	    $this->setData('ltiData', $signedRequest->getParams());
            $this->setData('client_config_url', $this->getClientConfigUrl());
	    $this->setView('ltiConsumer.tpl');
	}
1198782
public function loadConfig() {
        $this->allLocales = config('app.all_locales');
        $this->defaultLocales = config('app.fallback_locale');
        $this->usePrefixForDefault = config('routelocale.default_prefix');
    }
571043
def _get_any_translated_model(self, meta=None):
        
        if meta is None:
            meta = self._parler_meta.root

        tr_model = meta.model
        local_cache = self._translations_cache[tr_model]
        if local_cache:
            # There is already a language available in the case. No need for queries.
            # Give consistent answers if they exist.
            check_languages = [self._current_language] + self.get_fallback_languages()
            try:
                for fallback_lang in check_languages:
                    trans = local_cache.get(fallback_lang, None)
                    if trans and not is_missing(trans):
                        return trans
                return next(t for t in six.itervalues(local_cache) if not is_missing(t))
            except StopIteration:
                pass

        try:
            # Use prefetch if available, otherwise perform separate query.
            prefetch = self._get_prefetched_translations(meta=meta)
            if prefetch is not None:
                translation = prefetch[0]  # Already a list
            else:
                translation = self._get_translated_queryset(meta=meta)[0]
        except IndexError:
            return None
        else:
            local_cache[translation.language_code] = translation
            _cache_translation(translation)
            return translation
333357
public function boot()
    {
        $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'instance-validator');

        $this->publishes([
            __DIR__ . '/../../resources/lang' => resource_path('lang/vendor/instance-validator'),
        ]);

        Validator::extend('instance_of', function ($attribute, $value, $parameters, $validator)
        {
            if (count($parameters) != 1)
            {
                throw new Exception("The 'instance_of' validator requires a single type to be specified.");
            }

            return $value instanceof $parameters[0];
        });

        Validator::replacer('instance_of', function ($message, $attribute, $rule, $parameters)
        {
            $msg = Lang::trans('instance-validator::' . $message);
            $msg = str_replace([':attribute', ':type'], [$attribute, $parameters[0]], $msg);
            return $msg;
        });

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Validator::extend('collection_of', function ($attribute, $value, $parameters, $validator)
        {
            if (count($parameters) != 1)
            {
                throw new Exception("The 'collection_of' validator requires a single type to be specified.");
            }

            if(!$value instanceof Collection)
            {
                throw new Exception("The 'collection_of' validator requires a Collection instance.");
            }

            if ($value->isEmpty()) return true;

            $itemIsCorrectType = $value[0] instanceof $parameters[0] || (strtolower($parameters[0]) === 'string' && is_string($value[0]));

            return $itemIsCorrectType;
        });

        Validator::replacer('collection_of', function ($message, $attribute, $rule, $parameters)
        {
            $msg = Lang::trans('instance-validator::' . $message);
            $msg = str_replace([':attribute', ':type'], [$attribute, $parameters[0]], $msg);
            return $msg;
        });

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Validator::extend('paginator_of', function ($attribute, $value, $parameters, $validator)
        {
            if (count($parameters) != 1)
            {
                throw new Exception("The 'paginator_of' validator requires a single type to be specified.");
            }

            if(!$value instanceof LengthAwarePaginator)
            {
                throw new Exception("The 'paginator_of' validator requires a LengthAwarePaginator instance.");
            }

            if ($value->isEmpty()) return true;

            $itemIsCorrectType = $value->items()[0] instanceof $parameters[0] || (strtolower($parameters[0]) === 'string' && is_string($value->items()[0]));

            return $itemIsCorrectType;
        });

        Validator::replacer('paginator_of', function ($message, $attribute, $rule, $parameters)
        {
            $msg = Lang::trans('instance-validator::' . $message);
            $msg = str_replace([':attribute', ':type'], [$attribute, $parameters[0]], $msg);
            return $msg;
        });
    }
1076742
public function login()
    {
        try {

            if (!$this->hasRequestParameter('successCallback')) {
                throw new \common_exception_MissingParameter ('Internal error, please retry in few moment');
            }

            if ($this->isRequestPost()) {
                $authorizationService = $this->getServiceLocator()->get(Authorization::SERVICE_ID);

                if (!$authorizationService instanceof RequireUsername) {
                    throw new InvalidCallException('Authenticator need to be call by requireusername');
                }

                if ($authorizationService->validateLogin($this->getRequestParameter('login'))) {
                    $baseUrl = $this->getServiceLocator()
                        ->get(\common_ext_ExtensionsManager::SERVICE_ID)
                        ->getExtensionById('taoClientDiagnostic')
                        ->getConstant('BASE_URL');
                    $elements = parse_url($baseUrl);
                    $this->setCookie('login', $this->getRequestParameter('login'), null, $elements['path']);
                    $this->redirect($this->getRequestParameter('successCallback'));
                }
            }

        } catch (InvalidLoginException $e) {
            $this->setData('errorMessage', $e->getUserMessage());
        }

        $this->setData('successCallback', $this->getRequestParameter('successCallback'));
        $this->setData('client_config_url', $this->getClientConfigUrl());
        $this->setData('content-controller', 'taoClientDiagnostic/controller/Authenticator/login');
        $this->setData('content-template', 'Authenticator' . DIRECTORY_SEPARATOR . 'login.tpl');
        $this->setView('index.tpl');
    }
646350
protected function loadTranslationMetadata($className, $config)
    {
        if (! isset($config[$className])
            || ! isset($config[$className]['prezent'])
            || ! array_key_exists('translatable', $config[$className]['prezent'])
        ) {
            return;
        }

        $classMetadata = new TranslationMetadata($className);

        $translatable = $config[$className]['prezent']['translatable'] ?: array();

        $propertyMetadata = new PropertyMetadata(
            $className,
            // defaults to translatable
            isset($translatable['field']) ? $translatable['field'] : 'translatable'
        );

        $targetEntity = 'Translation' === substr($className, -11) ? substr($className, 0, -11) : null;

        $classMetadata->targetEntity = isset($translatable['targetEntity']) ? $translatable['targetEntity']: $targetEntity;
        $classMetadata->translatable = $propertyMetadata;
        $classMetadata->addPropertyMetadata($propertyMetadata);

        $locale = isset($translatable['locale']) ? $translatable['locale'] : 'locale';
        $propertyMetadata = new PropertyMetadata($className, $locale);
        $classMetadata->locale = $propertyMetadata;
        $classMetadata->addPropertyMetadata($propertyMetadata);

        return $classMetadata;
    }
1369664
public function loadWithTranslations($data, $languages, $formName = null, $translationFormName = null)
    {
        if ($this->owner->load($data, $formName)) {
            if (!$languages) {
                throw new InvalidParamException('Languages must be set.');
            }
            foreach ($languages as $language) {
                $modelI18n = static::getTranslation($language);
                $modelI18n->load($data, $translationFormName);
            }
            return true;
        }
        return false;
    }
699654
private function translateData(): void
    {
        foreach ($this->db->data as $key => $value) {
            $this->data[$key] = $value;
        }
    }
1134374
protected function _load()
    {
        $file = new File($this->_file, "r");

        $data = @parse_ini_string($file->read(), true);
        if ($data === false) {
            throw new Exception\ParserErrorException(
                "Error parsing configuration file {$this->_file}"
            );
        }
        $this->_data = $data;
    }
441267
public function load() {
        if ($this->_loaded) return;
        $factory = HTMLPurifier_LanguageFactory::instance();
        $factory->loadLanguage($this->code);
        foreach ($factory->keys as $key) {
            $this->$key = $factory->cache[$this->code][$key];
        }
        $this->_loaded = true;
    }
162186
public function addPropertyIndex()
    {
        if(!$this->isXmlHttpRequest()){
            throw new common_exception_BadRequest('wrong request mode');
        }
        if(!$this->hasRequestParameter('uri')){
            throw new Exception("wrong request Parameter");
        }
        $uri = $this->getRequestParameter('uri');

        $clazz = $this->getCurrentClass();

        $index = 1;
        if($this->hasRequestParameter('index')){
            $index = $this->getRequestParameter('index');
        }

        $propertyIndex = 1;
        if($this->hasRequestParameter('propertyIndex')){
            $propertyIndex = $this->getRequestParameter('propertyIndex');
        }

        //create and attach the new index property to the property
        $property = $this->getProperty(tao_helpers_Uri::decode($uri));
        $class = $this->getClass("http://www.tao.lu/Ontologies/TAO.rdf#Index");

        //get property range to select a default tokenizer
        /** @var core_kernel_classes_Class $range */
        $range = $property->getRange();
        //range is empty select item content
        $tokenizer = null;
        if (is_null($range)) {
            $tokenizer = $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer');
        } else {
            $tokenizer = $range->getUri() === OntologyRdfs::RDFS_LITERAL
                ? $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#RawValueTokenizer')
                : $this->getResource('http://www.tao.lu/Ontologies/TAO.rdf#LabelTokenizer');
        }

        $indexClass = $this->getClass('http://www.tao.lu/Ontologies/TAO.rdf#Index');
        $i = 0;
        $indexIdentifierBackup = preg_replace('/[^a-z_0-9]/','_',strtolower($property->getLabel()));
        $indexIdentifierBackup = ltrim(trim($indexIdentifierBackup, '_'),'0..9');
        $indexIdentifier = $indexIdentifierBackup;
        do{
            if($i !== 0){
                $indexIdentifier = $indexIdentifierBackup.'_'.$i;
            }
            $resources = $indexClass->searchInstances(array(OntologyIndex::PROPERTY_INDEX_IDENTIFIER => $indexIdentifier), array('like' => false));
            $count = count($resources);
            $i++;
        }while($count !== 0);

        $indexProperty = $class->createInstanceWithProperties(array(
                OntologyRdfs::RDFS_LABEL => preg_replace('/_/',' ',ucfirst($indexIdentifier)),
                OntologyIndex::PROPERTY_INDEX_IDENTIFIER => $indexIdentifier,
                OntologyIndex::PROPERTY_INDEX_TOKENIZER => $tokenizer,
                OntologyIndex::PROPERTY_INDEX_FUZZY_MATCHING => GenerisRdf::GENERIS_TRUE,
                OntologyIndex::PROPERTY_DEFAULT_SEARCH  => GenerisRdf::GENERIS_FALSE,
            ));

        $property->setPropertyValue($this->getProperty(OntologyIndex::PROPERTY_INDEX), $indexProperty);

        //generate form
        $indexFormContainer = new tao_actions_form_IndexProperty(new OntologyIndex($indexProperty), $propertyIndex.$index);
        $myForm = $indexFormContainer->getForm();
        $form = trim(preg_replace('/\s+/', ' ', $myForm->renderElements()));
        $this->returnJson(array('form' => $form));
    }
1252381
public function load() {
        $this->dictProvider->setLangsPath($this->path);
        $dict = $this->dictProvider->load($this->getUserLangs());
        $this->loadedLang = $this->dictProvider->getLoadedLang();

        if ($dict === null) {
            throw new CantLoadDictionaryException(CantLoadDictionaryException::NO_MATCHING_FILES);
        }

        $this->setlocale();

        return $dict;
    }
732594
protected function load_messages(){
        if($this->messages == NULL || $this->locale != $this->messagesLocale){
            if($this->locale != NULL){
                if(file_exists($this->dir_content . "_$this->locale" . '.txt')){
                    $this->messages= file($this->dir_content . "_$this->locale" . '.txt');
                    $this->messages= $this->parse_properties($this->messages);
                    $this->messagesLocale= $this->locale;
                }
            }
            if($this->messages == NULL){
                $this->messages= file($this->dir_content . '.txt');
                $this->messages= $this->parse_properties($this->messages);
                $this->messagesLocale= NULL;
            }
        }
    }
1042011
private void setRequestLanguages(WbGetEntitiesActionData properties) {
		if (this.filter.excludeAllLanguages()
				|| this.filter.getLanguageFilter() == null) {
			return;
		}
		properties.languages = ApiConnection.implodeObjects(this.filter
				.getLanguageFilter());
	}
631977
def save_translations(self, instance, translated_data):
        
        for meta in self.Meta.model._parler_meta:
            translations = translated_data.get(meta.rel_name, {})
            for lang_code, model_fields in translations.items():
                translation = instance._get_translated_model(lang_code, auto_create=True, meta=meta)
                for field, value in model_fields.items():
                    setattr(translation, field, value)

        # Go through the same hooks as the regular model,
        # instead of calling translation.save() directly.
        instance.save_translations()
69700
public function loadAllMessages() {
		$files = glob(ROOT_PATH.$this->i18nMessagePath.'message*.php');

		$defaultFound = false;
		foreach ($files as $file) {
			$base = basename($file);
			if ($base == "message.php") {
				$messageFile = new FineMessageLanguage();
				$messageFile->loadAllFile(ROOT_PATH.$this->i18nMessagePath);
				$this->messages['default'] = $messageFile;
				$defaultFound = true;
			} else {
				if(strpos($base, '_custom') === false) {
					$phpPos = strpos($base, '.php');
					$language = substr($base, 8, $phpPos-8);
					$messageLanguage = new FineMessageLanguage();
					$messageLanguage->loadAllFile(ROOT_PATH.$this->i18nMessagePath, $language);
					$this->messages[$language] = $messageLanguage;
				}
			}
		}
		if (!$defaultFound) {
			$messageFile = new FineMessageLanguage();
			$messageFile->loadAllFile(ROOT_PATH.$this->i18nMessagePath);
			$this->messages['default'] = $messageFile;
		}
	}