AlfrescoTranslationLoader

This commit is contained in:
mauriziovitale84
2016-05-10 17:55:01 +01:00
parent 6af4054931
commit f7f73f0ead
8 changed files with 149 additions and 10 deletions

View File

@@ -19,14 +19,17 @@ import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
import {TRANSLATE_PROVIDERS} from 'ng2-translate/ng2-translate';
import {TRANSLATE_PROVIDERS, TranslateLoader, TranslateService} from 'ng2-translate/ng2-translate';
import {ALFRESCO_AUTHENTICATION} from 'ng2-alfresco-login/ng2-alfresco-login';
import {ALFRESCO_CORE_PROVIDERS} from 'ng2-alfresco-core/services';
import {AlfrescoTranslationLoader} from 'ng2-alfresco-core/services';
import {provide} from 'angular2/core';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
TRANSLATE_PROVIDERS,
provide(TranslateLoader, {useClass: AlfrescoTranslationLoader}),
TranslateService,
ALFRESCO_AUTHENTICATION,
ALFRESCO_CORE_PROVIDERS
]);

View File

@@ -15,10 +15,12 @@
* limitations under the License.
*/
import { AlfrescoSettingsService } from './services/AlfrescoSettingsService';
import { AlfrescoTranslationLoader } from './services/AlfrescoTranslationService';
export * from './services/AlfrescoSettingsService';
export * from './services/AlfrescoTranslationService';
declare var _default: {
directives: undefined[];
providers: typeof AlfrescoSettingsService[];
providers: (typeof AlfrescoSettingsService | typeof AlfrescoTranslationLoader)[];
};
export default _default;
export declare const ALFRESCO_CORE_PROVIDERS: [any];

View File

@@ -1,7 +1,23 @@
System.register(['./services/AlfrescoSettingsService'], function(exports_1, context_1) {
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
System.register(['./services/AlfrescoSettingsService', './services/AlfrescoTranslationService'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var AlfrescoSettingsService_1;
var AlfrescoSettingsService_1, AlfrescoTranslationService_1;
var ALFRESCO_CORE_PROVIDERS;
var exportedNames_1 = {
'ALFRESCO_CORE_PROVIDERS': true
@@ -18,14 +34,22 @@ System.register(['./services/AlfrescoSettingsService'], function(exports_1, cont
function (AlfrescoSettingsService_1_1) {
AlfrescoSettingsService_1 = AlfrescoSettingsService_1_1;
exportStar_1(AlfrescoSettingsService_1_1);
},
function (AlfrescoTranslationService_1_1) {
AlfrescoTranslationService_1 = AlfrescoTranslationService_1_1;
exportStar_1(AlfrescoTranslationService_1_1);
}],
execute: function() {
exports_1("default",{
directives: [],
providers: [AlfrescoSettingsService_1.AlfrescoSettingsService]
providers: [
AlfrescoSettingsService_1.AlfrescoSettingsService,
AlfrescoTranslationService_1.AlfrescoTranslationLoader
]
});
exports_1("ALFRESCO_CORE_PROVIDERS", ALFRESCO_CORE_PROVIDERS = [
AlfrescoSettingsService_1.AlfrescoSettingsService
AlfrescoSettingsService_1.AlfrescoSettingsService,
AlfrescoTranslationService_1.AlfrescoTranslationLoader
]);
}
}

View File

@@ -1 +1 @@
{"version":3,"file":"services.js","sourceRoot":"","sources":["services.ts"],"names":[],"mappings":";;;;QAwBa,uBAAuB;;;;;;;;;;;;;;;;;;YALpC,oBAAe;gBACX,UAAU,EAAE,EAAE;gBACd,SAAS,EAAE,CAAC,iDAAuB,CAAC;aACvC,EAAA;YAEY,qCAAA,uBAAuB,GAAU;gBAC1C,iDAAuB;aAC1B,CAAA,CAAC"}
{"version":3,"file":"services.js","sourceRoot":"","sources":["services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;QAgBU,uBAAuB;;;;;;;;;;;;;;;;;;;;;;YARpC,oBAAe;gBACX,UAAU,EAAE,EAAE;gBACd,SAAS,EAAE;oBACP,iDAAuB;oBACvB,sDAAyB;iBAC5B;aACJ,EAAA;YAEY,qCAAA,uBAAuB,GAAU;gBAC1C,iDAAuB;gBACvB,sDAAyB;aAC5B,CAAA,CAAC"}

View File

@@ -14,14 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {AlfrescoSettingsService} from './services/AlfrescoSettingsService';
import {AlfrescoTranslationLoader} from './services/AlfrescoTranslationService';
export * from './services/AlfrescoSettingsService';
export * from './services/AlfrescoTranslationService';
export default {
directives: [],
providers: [AlfrescoSettingsService]
providers: [
AlfrescoSettingsService,
AlfrescoTranslationLoader
]
}
export const ALFRESCO_CORE_PROVIDERS: [any] = [
AlfrescoSettingsService
AlfrescoSettingsService,
AlfrescoTranslationLoader
];

View File

@@ -0,0 +1,62 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
System.register(['angular2/core', 'angular2/http'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, http_1;
var AlfrescoTranslationLoader;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (http_1_1) {
http_1 = http_1_1;
}],
execute: function() {
AlfrescoTranslationLoader = (function () {
function AlfrescoTranslationLoader(http) {
this.http = http;
this.prefix = 'i18n';
this.suffix = '.json';
}
AlfrescoTranslationLoader.prototype.getTranslation = function (lang) {
return this.http.get('node_modules/ng2-alfresco-login/' + (this.prefix + "/" + lang + this.suffix))
.map(function (res) { return res.json(); })
.concat(this.http.get('node_modules/ng2-alfresco-upload/' + (this.prefix + "/" + lang + this.suffix))
.map(function (res) { return res.json(); }));
};
AlfrescoTranslationLoader = __decorate([
core_1.Injectable(),
__metadata('design:paramtypes', [http_1.Http])
], AlfrescoTranslationLoader);
return AlfrescoTranslationLoader;
}());
exports_1("AlfrescoTranslationLoader", AlfrescoTranslationLoader);
}
}
});
//# sourceMappingURL=AlfrescoTranslationService.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AlfrescoTranslationService.js","sourceRoot":"","sources":["AlfrescoTranslationService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YASH;gBAKI,mCAAoB,IAAU;oBAAV,SAAI,GAAJ,IAAI,CAAM;oBAHtB,WAAM,GAAW,MAAM,CAAC;oBACxB,WAAM,GAAW,OAAO,CAAC;gBAGjC,CAAC;gBAED,kDAAc,GAAd,UAAe,IAAY;oBACvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kCAAkC,GAAG,CAAG,IAAI,CAAC,MAAM,SAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAE,CAAC;yBAC5F,GAAG,CAAC,UAAC,GAAa,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC;yBAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,mCAAmC,GAAG,CAAG,IAAI,CAAC,MAAM,SAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAE,CAAC;yBAC9F,GAAG,CAAC,UAAC,GAAa,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,CAAC,CAAC;gBACjD,CAAC;gBAdL;oBAAC,iBAAU,EAAE;;6CAAA;gBAeb,gCAAC;YAAD,CAAC,AAdD,IAcC;YAdD,iEAcC,CAAA"}

View File

@@ -0,0 +1,39 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Injectable} from 'angular2/core';
import {Http, Response} from 'angular2/http';
import {TranslateLoader} from 'ng2-translate/ng2-translate';
import {Http, Response} from 'angular2/http';
@Injectable()
export class AlfrescoTranslationLoader implements TranslateLoader {
private prefix: string = 'i18n';
private suffix: string = '.json';
constructor(private http: Http) {
}
getTranslation(lang: string): Observable<any> {
return this.http.get('node_modules/ng2-alfresco-login/' + `${this.prefix}/${lang}${this.suffix}`)
.map((res: Response) => res.json())
.concat(this.http.get('node_modules/ng2-alfresco-upload/' + `${this.prefix}/${lang}${this.suffix}`)
.map((res: Response) => res.json()));
}
}