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
giovedì 16 giugno 2016
Iscriviti a:
Commenti sul post (Atom)
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...
-
Precondizione: La precondizione di un metodo e' una condizione che deve essere verificata prima che quel metodo sia invocato. Le preco...
-
My intent is to configure SSO on Keycloak and Liferay. I have createad a docker-compose environment with Keycloak: #####################...
Nessun commento:
Posta un commento