giovedì 16 giugno 2016

PARTIAL LOADER

The Partial Loader extends the Static Files Loader to a [part] parameter. This parameter can be set manually, when certain parts of the application are loaded, e.g., a module or a controller. Additionally to the [lang] parameter, this value can be included in the request url. During configuration, the Partial Loader takes a url template. This template will be directly passed to the server, when the language is set or changed

ANGULAR TRANSLATE ASYNCHRONOUS LOADING OF PARTIAL LANGUAGE FILES

1. directory structure

        languages/
            it/
                static.json
                dynamic.json
            en/  
                static.json
                dynamic.json


2. dependencies:  <script src="../webjars/angular-translate-loader-partial/${angular-translate-loader-partial.version}/angular-translate-loader-partial.js"></script>



3. configuration: applying a template url path. (Now that we know how our data is structured, we can configure $translateProvider to use the partial loader with this pattern).
        Everything to do is to add in app.js:

        app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$translateProvider', '$translatePartialLoaderProvider',
          function ($stateProvider, $urlRouterProvider, $httpProvider, $translateProvider, $translatePartialLoaderProvider) {

            $translatePartialLoaderProvider.addPart('static');
            $translatePartialLoaderProvider.addPart('dynamic');
            $translateProvider.useLoader('$translatePartialLoader', {
              urlTemplate: 'languages/{lang}/{part}.json'
            })
                .preferredLanguage('en');


----------------

U can find a good demo here.
And other infos here:

https://angular-translate.github.io/docs/#/guide/12_asynchronous-loading 




https://technpol.wordpress.com/2013/11/02/adding-translation-using-angular-translate-to-an-angularjs-app/

https://github.com/angular-translate/angular-translate/issues/399

Nessun commento:

How to deploy Podman images to OpenShift Container Platform (CRC on localhost)

I have a microservice on localhost and I want to deploy its Podman image on OCP, which I am running using CRC on localhost.       1. Get the...