Skip to content

Commit 3a31442

Browse files
committed
add angular material and transloco
1 parent e7e26ee commit 3a31442

10 files changed

Lines changed: 2465 additions & 786 deletions

File tree

package-lock.json

Lines changed: 2372 additions & 782 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,31 @@
1111
},
1212
"private": true,
1313
"dependencies": {
14-
"browserlist": "^1.0.1",
1514
"@angular/animations": "~8.2.14",
15+
"@angular/cdk": "~8.2.3",
1616
"@angular/common": "~8.2.14",
1717
"@angular/compiler": "~8.2.14",
1818
"@angular/core": "~8.2.14",
1919
"@angular/forms": "~8.2.14",
20+
"@angular/material": "^8.2.3",
2021
"@angular/platform-browser": "~8.2.14",
2122
"@angular/platform-browser-dynamic": "~8.2.14",
2223
"@angular/router": "~8.2.14",
24+
"@ngneat/transloco": "^2.13.5",
25+
"browserlist": "^1.0.1",
26+
"hammerjs": "^2.0.8",
2327
"rxjs": "~6.4.0",
2428
"tslib": "^1.10.0",
2529
"zone.js": "~0.9.1"
2630
},
2731
"devDependencies": {
28-
"@angular-devkit/build-angular": "~0.803.21",
32+
"@angular-devkit/build-angular": "^0.803.23",
2933
"@angular/cli": "~8.3.21",
3034
"@angular/compiler-cli": "~8.2.14",
3135
"@angular/language-service": "~8.2.14",
32-
"@types/node": "~8.9.4",
3336
"@types/jasmine": "~3.3.8",
3437
"@types/jasminewd2": "~2.0.3",
38+
"@types/node": "~8.9.4",
3539
"codelyzer": "^5.0.0",
3640
"jasmine-core": "~3.4.0",
3741
"jasmine-spec-reporter": "~4.2.1",

src/app/app.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ import { NgModule } from '@angular/core';
33

44
import { AppRoutingModule } from './app-routing.module';
55
import { AppComponent } from './app.component';
6+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7+
import { HttpClientModule } from '@angular/common/http';
8+
import { TranslocoRootModule } from './transloco-root.module';
69

710
@NgModule({
811
declarations: [
912
AppComponent
1013
],
1114
imports: [
1215
BrowserModule,
13-
AppRoutingModule
16+
AppRoutingModule,
17+
BrowserAnimationsModule,
18+
HttpClientModule,
19+
TranslocoRootModule
1420
],
1521
providers: [],
1622
bootstrap: [AppComponent]

src/app/transloco-root.module.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { HttpClient } from '@angular/common/http';
2+
import {
3+
TRANSLOCO_LOADER,
4+
Translation,
5+
TranslocoLoader,
6+
TRANSLOCO_CONFIG,
7+
translocoConfig,
8+
TranslocoModule
9+
} from '@ngneat/transloco';
10+
import { Injectable, NgModule } from '@angular/core';
11+
import { environment } from '../environments/environment';
12+
13+
@Injectable({ providedIn: 'root' })
14+
export class TranslocoHttpLoader implements TranslocoLoader {
15+
constructor(private http: HttpClient) {}
16+
17+
getTranslation(lang: string) {
18+
return this.http.get<Translation>(`/assets/i18n/${lang}.json`);
19+
}
20+
}
21+
22+
@NgModule({
23+
exports: [ TranslocoModule ],
24+
providers: [
25+
{
26+
provide: TRANSLOCO_CONFIG,
27+
useValue: translocoConfig({
28+
availableLangs: ['en', 'es'],
29+
defaultLang: 'en',
30+
// Remove this option if your application doesn't support changing language in runtime.
31+
reRenderOnLangChange: true,
32+
prodMode: environment.production,
33+
})
34+
},
35+
{ provide: TRANSLOCO_LOADER, useClass: TranslocoHttpLoader }
36+
]
37+
})
38+
export class TranslocoRootModule {}

src/assets/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/assets/i18n/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<base href="/">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<link rel="icon" type="image/x-icon" href="favicon.ico">
9+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
10+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
911
</head>
1012
<body>
1113
<app-root></app-root>

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'hammerjs';
12
import { enableProdMode } from '@angular/core';
23
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
34

src/styles.scss

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1+
2+
// Custom Theming for Angular Material
3+
// For more information: https://material.angular.io/guide/theming
4+
@import '~@angular/material/theming';
5+
// Plus imports for other components in your app.
6+
7+
// Include the common styles for Angular Material. We include this here so that you only
8+
// have to load a single css file for Angular Material in your app.
9+
// Be sure that you only ever include this mixin once!
10+
@include mat-core();
11+
12+
// Define the palettes for your theme using the Material Design palettes available in palette.scss
13+
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
14+
// hue. Available color palettes: https://material.io/design/color/
15+
$angular-v8-primary: mat-palette($mat-indigo);
16+
$angular-v8-accent: mat-palette($mat-pink, A200, A100, A400);
17+
18+
// The warn palette is optional (defaults to red).
19+
$angular-v8-warn: mat-palette($mat-red);
20+
21+
// Create the theme object (a Sass map containing all of the palettes).
22+
$angular-v8-theme: mat-light-theme($angular-v8-primary, $angular-v8-accent, $angular-v8-warn);
23+
24+
// Include theme styles for core and each component used in your app.
25+
// Alternatively, you can import and @include the theme mixins for each component
26+
// that you are using.
27+
@include angular-material-theme($angular-v8-theme);
28+
129
/* You can add global styles to this file, and also import other style files */
30+
31+
html, body { height: 100%; }
32+
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }

transloco.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
rootTranslationsPath: 'src/assets/i18n/',
3+
langs: ['en', 'es'],
4+
keysManager: {}
5+
};

0 commit comments

Comments
 (0)