src/Controller/LanguageController.php
public function getTranslationsAction()
    {
        // Get the current language
        $container = new Container('meliscore');
        $locale = $container['melis-lang-locale'];


        $translator = $this->getServiceLocator()->get('translator');
        $melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation');

        // Set the headers of this route
        $response = $this->getResponse();
        $response->getHeaders()
            ->addHeaderLine('Content-Type', 'text/javascript; charset=utf-8');

        $translationCompilation = '';
        foreach($melisTranslation->getTranslationMessages($locale) as $transKey => $transValue)
        {
            $translationCompilation .= "translations['".$transKey."'] = '" . $transValue . "';".PHP_EOL;
        }

        $scriptContent = '';
        $scriptContent .= 'var melisLangId = "' . $locale . '";' . PHP_EOL;
        $scriptContent .= 'var melisDateFormat = "'. $melisTranslation->getDateFormat($locale) . '";'. PHP_EOL;
        $scriptContent .= 'var translations = new Object();'. PHP_EOL;
        $scriptContent .= $translationCompilation;
        $response->setContent($scriptContent);


        $view = new ViewModel();
        $view->setTerminal(true);
        $view->contentHeaders = $response->getContent();
        return $view;
    }
public function getTranslationsAction()
    {
        // Get the current language
        $container = new Container('meliscore');
        $locale = $container['melis-lang-locale'];


        $translator = $this->getServiceLocator()->get('translator');
        $melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation');

        // Set the headers of this route
        $response = $this->getResponse();
        $response->getHeaders()
            ->addHeaderLine('Content-Type', 'text/javascript; charset=utf-8');

        $translationCompilation = '';
        foreach($melisTranslation->getTranslationMessages($locale) as $transKey => $transValue)
        {
            $translationCompilation .= "translations['".$transKey."'] = '" . $transValue . "';".PHP_EOL;
        }

        $scriptContent = '';
        $scriptContent .= 'var melisLangId = "' . $locale . '";' . PHP_EOL;
        $scriptContent .= 'var melisDateFormat = "'. $melisTranslation->getDateFormat($locale) . '";'. PHP_EOL;
        $scriptContent .= 'var translations = new Object();'. PHP_EOL;
        $scriptContent .= $translationCompilation;
        $response->setContent($scriptContent);


        $view = new ViewModel();
        $view->setTerminal(true);
        $view->contentHeaders = $response->getContent();
        return $view;
    }
public function getTranslationsAction ( ) { // Get the current language $ container = new Container ( 'meliscore' ) ; $ locale = $ container [ 'melis-lang-locale' ] ; $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ melisTranslation = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTranslation' ) ; // Set the headers of this route $ response = $ this -> getResponse ( ) ; $ response -> getHeaders ( ) -> addHeaderLine ( 'Content-Type' , 'text/javascript; charset=utf-8' ) ; $ translationCompilation = '' ; foreach ( $ melisTranslation -> getTranslationMessages ( $ locale ) as $ transKey => $ transValue ) { $ translationCompilation .= "translations['" . $ transKey . "'] = '" . $ transValue . "';" . PHP_EOL ; } $ scriptContent = '' ; $ scriptContent .= 'var melisLangId = "' . $ locale . '";' . PHP_EOL ; $ scriptContent .= 'var melisDateFormat = "' . $ melisTranslation -> getDateFormat ( $ locale ) . '";' . PHP_EOL ; $ scriptContent .= 'var translations = new Object();' . PHP_EOL ; $ scriptContent .= $ translationCompilation ; $ response -> setContent ( $ scriptContent ) ; $ view = new ViewModel ( ) ; $ view -> setTerminal ( true ) ; $ view -> contentHeaders = $ response -> getContent ( ) ; return $ view ; }
Returns a Javascript format of Melis Translations
Returns a Javascript format of Melis Translations