From f7f73f0ead3171eeda3618f3f897f1b4cd08ff8d Mon Sep 17 00:00:00 2001 From: mauriziovitale84 Date: Tue, 10 May 2016 17:55:01 +0100 Subject: [PATCH] AlfrescoTranslationLoader --- demo-shell-ng2/app/main.ts | 7 ++- .../ng2-alfresco-core/services.d.ts | 4 +- ng2-components/ng2-alfresco-core/services.js | 32 ++++++++-- .../ng2-alfresco-core/services.js.map | 2 +- ng2-components/ng2-alfresco-core/services.ts | 12 +++- .../services/AlfrescoTranslationService.js | 62 +++++++++++++++++++ .../AlfrescoTranslationService.js.map | 1 + .../services/AlfrescoTranslationService.ts | 39 ++++++++++++ 8 files changed, 149 insertions(+), 10 deletions(-) create mode 100644 ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js create mode 100644 ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js.map create mode 100644 ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.ts diff --git a/demo-shell-ng2/app/main.ts b/demo-shell-ng2/app/main.ts index b35060163f..c4f5d7308b 100644 --- a/demo-shell-ng2/app/main.ts +++ b/demo-shell-ng2/app/main.ts @@ -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 ]); diff --git a/ng2-components/ng2-alfresco-core/services.d.ts b/ng2-components/ng2-alfresco-core/services.d.ts index c836811c0d..13d810e400 100644 --- a/ng2-components/ng2-alfresco-core/services.d.ts +++ b/ng2-components/ng2-alfresco-core/services.d.ts @@ -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]; diff --git a/ng2-components/ng2-alfresco-core/services.js b/ng2-components/ng2-alfresco-core/services.js index 643b604cd9..6eda976d4a 100644 --- a/ng2-components/ng2-alfresco-core/services.js +++ b/ng2-components/ng2-alfresco-core/services.js @@ -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 ]); } } diff --git a/ng2-components/ng2-alfresco-core/services.js.map b/ng2-components/ng2-alfresco-core/services.js.map index c769577080..3fa0b1c17e 100644 --- a/ng2-components/ng2-alfresco-core/services.js.map +++ b/ng2-components/ng2-alfresco-core/services.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-core/services.ts b/ng2-components/ng2-alfresco-core/services.ts index ab4a13de39..681ff83dc8 100644 --- a/ng2-components/ng2-alfresco-core/services.ts +++ b/ng2-components/ng2-alfresco-core/services.ts @@ -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 ]; diff --git a/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js b/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js new file mode 100644 index 0000000000..17498ca170 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js @@ -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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js.map b/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js.map new file mode 100644 index 0000000000..ce1b86bd87 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.js.map @@ -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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.ts b/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.ts new file mode 100644 index 0000000000..dcc83848a5 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.ts @@ -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 { + 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())); + } +} \ No newline at end of file