mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Resolved merge conflicts.
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
"js.clone": "0.0.3",
|
"js.clone": "0.0.3",
|
||||||
"methods": "~1.1.2",
|
"methods": "~1.1.2",
|
||||||
"morgan": "^1.7.0",
|
"morgan": "^1.7.0",
|
||||||
|
"ng2-translate": "~4.0.1",
|
||||||
"preboot": "~4.5.2",
|
"preboot": "~4.5.2",
|
||||||
"rxjs": "5.0.0-beta.12",
|
"rxjs": "5.0.0-beta.12",
|
||||||
"webfontloader": "^1.6.26",
|
"webfontloader": "^1.6.26",
|
||||||
|
13
resources/i18n/en.json
Normal file
13
resources/i18n/en.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"title": "DSpace Universal",
|
||||||
|
|
||||||
|
"nav": {
|
||||||
|
"home": "Home"
|
||||||
|
},
|
||||||
|
|
||||||
|
"example": {
|
||||||
|
"with": {
|
||||||
|
"data": "{{greeting}}, {{recipient}}!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,9 +1,11 @@
|
|||||||
<h3>DSpace</h3>
|
<h3>{{ 'title' | translate }}</h3>
|
||||||
<nav>
|
<nav>
|
||||||
<a routerLinkActive="router-link-active" routerLink="home">Home</a>
|
<a routerLinkActive="router-link-active" routerLink="home">{{ 'nav.home' | translate }}</a>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<main>
|
<main>
|
||||||
|
<p>{{ 'example.with.data' | translate:data }}</p>
|
||||||
|
<p>{{ example }}</p>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
|
import { Component, ChangeDetectionStrategy, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
|
|
||||||
|
import { TranslateService } from 'ng2-translate';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
changeDetection: ChangeDetectionStrategy.Default,
|
changeDetection: ChangeDetectionStrategy.Default,
|
||||||
@@ -7,5 +9,34 @@ import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/
|
|||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.scss']
|
styleUrls: ['./app.component.scss']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnDestroy, OnInit {
|
||||||
|
|
||||||
|
example: string;
|
||||||
|
|
||||||
|
data: any = {
|
||||||
|
greeting: 'Hello',
|
||||||
|
recipient: 'World'
|
||||||
|
}
|
||||||
|
|
||||||
|
private registerSubscription: any;
|
||||||
|
|
||||||
|
constructor(public translate: TranslateService) {
|
||||||
|
// this language will be used as a fallback when a translation isn't found in the current language
|
||||||
|
translate.setDefaultLang('en');
|
||||||
|
// the lang to use, if the lang isn't available, it will use the current loader to get them
|
||||||
|
translate.use('en');
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.registerSubscription = this.translate.get('example.with.data', { greeting: 'Hello', recipient: 'DSpace' }).subscribe((translation: string) => {
|
||||||
|
this.example = translation;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
if (this.registerSubscription) {
|
||||||
|
this.registerSubscription.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,9 @@ import { NgModule, ModuleWithProviders } from '@angular/core';
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import { TranslateModule } from 'ng2-translate/ng2-translate';
|
||||||
|
|
||||||
import { ApiService } from './api.service';
|
import { ApiService } from './api.service';
|
||||||
import { ModelService } from './model/model.service';
|
import { ModelService } from './model/model.service';
|
||||||
|
|
||||||
@@ -9,6 +12,7 @@ const MODULES = [
|
|||||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||||
CommonModule,
|
CommonModule,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
|
TranslateModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
];
|
];
|
||||||
|
@@ -1,9 +1,12 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Http } from '@angular/http';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { UniversalModule, isBrowser, isNode, AUTO_PREBOOT } from 'angular2-universal/browser'; // for AoT we need to manually split universal packages
|
import { UniversalModule, isBrowser, isNode, AUTO_PREBOOT } from 'angular2-universal/browser'; // for AoT we need to manually split universal packages
|
||||||
import { IdlePreload, IdlePreloadModule } from '@angularclass/idle-preload';
|
import { IdlePreload, IdlePreloadModule } from '@angularclass/idle-preload';
|
||||||
|
|
||||||
|
import { TranslateLoader, TranslateModule, TranslateStaticLoader } from 'ng2-translate';
|
||||||
|
|
||||||
import { AppModule, AppComponent } from './app/app.module';
|
import { AppModule, AppComponent } from './app/app.module';
|
||||||
import { SharedModule } from './app/shared/shared.module';
|
import { SharedModule } from './app/shared/shared.module';
|
||||||
import { CacheService } from './app/shared/cache.service';
|
import { CacheService } from './app/shared/cache.service';
|
||||||
@@ -14,6 +17,10 @@ import { Meta } from './angular2-meta';
|
|||||||
|
|
||||||
// import * as LRU from 'modern-lru';
|
// import * as LRU from 'modern-lru';
|
||||||
|
|
||||||
|
export function createTranslateLoader(http: Http) {
|
||||||
|
return new TranslateStaticLoader(http, './assets/i18n', '.json');
|
||||||
|
}
|
||||||
|
|
||||||
export function getLRU(lru?: any) {
|
export function getLRU(lru?: any) {
|
||||||
// use LRU for node
|
// use LRU for node
|
||||||
// return lru || new LRU(10);
|
// return lru || new LRU(10);
|
||||||
@@ -35,7 +42,12 @@ export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
imports: [
|
imports: [
|
||||||
// MaterialModule.forRoot() should be included first
|
TranslateModule.forRoot({
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useFactory: (createTranslateLoader),
|
||||||
|
deps: [Http]
|
||||||
|
}),
|
||||||
|
|
||||||
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
|
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
|
||||||
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Http } from '@angular/http';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { UniversalModule, isBrowser, isNode } from 'angular2-universal/node'; // for AoT we need to manually split universal packages
|
import { UniversalModule, isBrowser, isNode } from 'angular2-universal/node'; // for AoT we need to manually split universal packages
|
||||||
|
|
||||||
|
import { TranslateLoader, TranslateModule, TranslateStaticLoader } from 'ng2-translate';
|
||||||
|
|
||||||
import { AppModule, AppComponent } from './app/app.module';
|
import { AppModule, AppComponent } from './app/app.module';
|
||||||
import { SharedModule } from './app/shared/shared.module';
|
import { SharedModule } from './app/shared/shared.module';
|
||||||
import { CacheService } from './app/shared/cache.service';
|
import { CacheService } from './app/shared/cache.service';
|
||||||
@@ -11,6 +14,10 @@ import { CacheService } from './app/shared/cache.service';
|
|||||||
// see https://github.com/angular/angular/pull/12322
|
// see https://github.com/angular/angular/pull/12322
|
||||||
import { Meta } from './angular2-meta';
|
import { Meta } from './angular2-meta';
|
||||||
|
|
||||||
|
export function createTranslateLoader(http: Http) {
|
||||||
|
return new TranslateStaticLoader(http, './assets/i18n', '.json');
|
||||||
|
}
|
||||||
|
|
||||||
export function getLRU() {
|
export function getLRU() {
|
||||||
return new Map();
|
return new Map();
|
||||||
}
|
}
|
||||||
@@ -27,7 +34,12 @@ export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
imports: [
|
imports: [
|
||||||
// MaterialModule.forRoot() should be included first
|
TranslateModule.forRoot({
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useFactory: (createTranslateLoader),
|
||||||
|
deps: [Http]
|
||||||
|
}),
|
||||||
|
|
||||||
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
|
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
|
||||||
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
|
@@ -2,6 +2,7 @@ var webpack = require('webpack');
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
var clone = require('js.clone');
|
var clone = require('js.clone');
|
||||||
var webpackMerge = require('webpack-merge');
|
var webpackMerge = require('webpack-merge');
|
||||||
|
let CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
|
|
||||||
export var commonPlugins = [
|
export var commonPlugins = [
|
||||||
new webpack.ContextReplacementPlugin(
|
new webpack.ContextReplacementPlugin(
|
||||||
@@ -13,6 +14,11 @@ export var commonPlugins = [
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
|
new CopyWebpackPlugin([{
|
||||||
|
from: path.join(__dirname, 'resources', 'i18n'),
|
||||||
|
to: path.join('assets', 'i18n')
|
||||||
|
}]),
|
||||||
|
|
||||||
// Loader options
|
// Loader options
|
||||||
new webpack.LoaderOptionsPlugin({
|
new webpack.LoaderOptionsPlugin({
|
||||||
options: {
|
options: {
|
||||||
|
Reference in New Issue
Block a user