fix translate

This commit is contained in:
Mario Romano
2016-05-19 19:39:13 +01:00
parent 40d8cff331
commit 3e54eaf5fe
22 changed files with 172 additions and 108 deletions

View File

@@ -18,13 +18,11 @@
import { Component } from 'angular2/core';
import { ControlGroup, FormBuilder, Validators } from 'angular2/common';
import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login';
import { MDL } from 'ng2-alfresco-core/material';
import { FilesComponent } from './components/files/files.component';
import { AlfrescoLoginComponent } from 'ng2-alfresco-login/ng2-alfresco-login';
import { AlfrescoLoginComponent, AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login';
import { AuthRouterOutlet } from './components/router/AuthRouterOutlet';
import { AlfrescoSettingsService } from 'ng2-alfresco-core/services';
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
import { UploadButtonComponent } from 'ng2-alfresco-upload/ng2-alfresco-upload';
import { DataTableDemoComponent } from './components/datatable/datatable-demo.component';
import { AlfrescoSearchComponent } from 'ng2-alfresco-search/ng2-alfresco-search';
@@ -35,7 +33,7 @@ declare var document: any;
selector: 'my-app',
templateUrl: 'app/app.component.html',
directives: [ROUTER_DIRECTIVES, AuthRouterOutlet, MDL],
pipes: [TranslatePipe]
pipes: [AlfrescoPipeTranslate]
})
@RouteConfig([
{path: '/home', name: 'Home', component: FilesComponent},
@@ -52,7 +50,7 @@ export class AppComponent {
constructor(private _fb: FormBuilder,
public auth: AlfrescoAuthenticationService,
public router: Router,
translate: TranslateService,
translate: AlfrescoTranslationService,
alfrescoSettingsService: AlfrescoSettingsService) {
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
@@ -60,7 +58,7 @@ export class AppComponent {
searchTerm: ['', Validators.compose([Validators.required, Validators.minLength(3)])]
});
this.translationInit(translate);
translate.translationInit('');
}
isActive(instruction: any[]): boolean {
@@ -83,18 +81,6 @@ export class AppComponent {
this.translate.use(lang);
}
translationInit(translate: TranslateService) {
this.translate = translate;
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
this.translate.setDefaultLang('en');
this.translate.currentLoader.addComponentList('');
this.translate.getTranslation(userLang);
this.translate.use(userLang);
}
hideDrawer() {
// todo: workaround for drawer closing
document.querySelector('.mdl-layout').MaterialLayout.toggleDrawer();

View File

@@ -15,22 +15,21 @@
* limitations under the License.
*/
import {Component} from 'angular2/core';
import {TranslatePipe} from 'ng2-translate/ng2-translate';
import { Component } from 'angular2/core';
import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
import {
ALFRESCO_DATATABLE_DIRECTIVES,
ObjectDataTableAdapter, DataSorting
} from 'ng2-alfresco-datatable/ng2-alfresco-datatable';
declare let __moduleName:string;
declare let __moduleName: string;
@Component({
moduleId: __moduleName,
selector: 'datatable-demo',
templateUrl: './datatable-demo.component.html',
directives: [ALFRESCO_DATATABLE_DIRECTIVES],
pipes: [TranslatePipe]
pipes: [AlfrescoPipeTranslate]
})
export class DataTableDemoComponent {
data: ObjectDataTableAdapter;
@@ -45,19 +44,19 @@ export class DataTableDemoComponent {
this.data = new ObjectDataTableAdapter(
[
{ id: 1, name: 'Name 1', createdBy: createdBy, icon: 'material-icons://folder_open' },
{ id: 2, name: 'Name 2', createdBy: createdBy, icon: 'material-icons://accessibility' },
{ id: 3, name: 'Name 3', createdBy: createdBy, icon: 'material-icons://alarm' },
{ id: 4, name: 'Image 1', createdBy: createdBy, icon: imageUrl }
{id: 1, name: 'Name 1', createdBy: createdBy, icon: 'material-icons://folder_open'},
{id: 2, name: 'Name 2', createdBy: createdBy, icon: 'material-icons://accessibility'},
{id: 3, name: 'Name 3', createdBy: createdBy, icon: 'material-icons://alarm'},
{id: 4, name: 'Image 1', createdBy: createdBy, icon: imageUrl}
],
[
{ type: 'image', key: 'icon', title: '', srTitle: 'Thumbnail' },
{ type: 'text', key: 'id', title: 'Id', sortable: true},
{ type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true },
{ type: 'text', key: 'createdBy.name', title: 'Created By', sortable: true }
{type: 'image', key: 'icon', title: '', srTitle: 'Thumbnail'},
{type: 'text', key: 'id', title: 'Id', sortable: true},
{type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true},
{type: 'text', key: 'createdBy.name', title: 'Created By', sortable: true}
]
);
this.data.setSorting(new DataSorting('name', 'asc'));
}
}

View File

@@ -23,7 +23,7 @@ import {
} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist';
import { MDL } from 'ng2-alfresco-core/material';
import { ALFRESCO_ULPOAD_COMPONENT } from 'ng2-alfresco-upload/ng2-alfresco-upload';
import { TranslatePipe } from 'ng2-translate/ng2-translate';
import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
declare let __moduleName: string;
@@ -33,7 +33,7 @@ declare let __moduleName: string;
templateUrl: './files.component.html',
directives: [DOCUMENT_LIST_DIRECTIVES, MDL, ALFRESCO_ULPOAD_COMPONENT],
providers: [DOCUMENT_LIST_PROVIDERS],
pipes: [TranslatePipe]
pipes: [AlfrescoPipeTranslate]
})
export class FilesComponent {
breadcrumb: boolean = false;

View File

@@ -16,7 +16,7 @@
*/
import { ElementRef, DynamicComponentLoader, Directive, Attribute } from 'angular2/core';
import { Router, RouterOutlet, ComponentInstruction } from 'angular2/router';
import {AlfrescoAuthenticationService} from 'ng2-alfresco-login/ng2-alfresco-login';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login';
@Directive({selector: 'auth-router-outlet'})
export class AuthRouterOutlet extends RouterOutlet {
@@ -24,11 +24,9 @@ export class AuthRouterOutlet extends RouterOutlet {
publicRoutes: Array<string>;
private router: Router;
constructor(
_elementRef: ElementRef, _loader: DynamicComponentLoader,
_parentRouter: Router, @Attribute('name') nameAttr: string,
private authentication: AlfrescoAuthenticationService
) {
constructor(_elementRef: ElementRef, _loader: DynamicComponentLoader,
_parentRouter: Router, @Attribute('name') nameAttr: string,
private authentication: AlfrescoAuthenticationService) {
super(_elementRef, _loader, _parentRouter, nameAttr);
this.router = _parentRouter;

View File

@@ -19,17 +19,13 @@ import { bootstrap } from 'angular2/platform/browser';
import { AppComponent } from './app.component';
import { ROUTER_PROVIDERS } from 'angular2/router';
import { HTTP_PROVIDERS } from 'angular2/http';
import { 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';
import { ALFRESCO_CORE_PROVIDERS, AlfrescoTranslationService } from 'ng2-alfresco-core/services';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
provide(TranslateLoader, {useClass: AlfrescoTranslationLoader}),
TranslateService,
AlfrescoTranslationService,
ALFRESCO_AUTHENTICATION,
ALFRESCO_CORE_PROVIDERS
]);

View File

@@ -53,7 +53,6 @@
"ng2-alfresco-login": "^0.1.0",
"ng2-alfresco-search": "^0.1.1",
"ng2-alfresco-upload": "^0.1.0",
"ng2-translate": "^1.11.2",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.26",

View File

@@ -19,11 +19,10 @@
// map tells the System loader where to look for things
var map = {
'ng2-uploader': 'node_modules/ng2-uploader',
'ng2-alfresco-core': 'node_modules/ng2-alfresco-core',
'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist',
'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable/dist',
'ng2-alfresco-documentlist': 'node_modules/ng2-alfresco-documentlist/dist',
'ng2-alfresco-login': 'node_modules/ng2-alfresco-login',
'ng2-alfresco-login': 'node_modules/ng2-alfresco-login/dist',
'ng2-alfresco-search': 'node_modules/ng2-alfresco-search/dist',
'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/dist',
'ng2-translate': 'node_modules/ng2-translate',
@@ -36,7 +35,6 @@
format: 'register',
defaultExtension: 'js'
},
'ng2-uploader': {defaultExtension: 'js'},
'ng2-alfresco-core': {defaultExtension: 'js'},
'ng2-alfresco-datatable': {defaultExtension: 'js'},
'ng2-alfresco-documentlist': {defaultExtension: 'js'},