Skip to content

Commit de3cf39

Browse files
committed
fix translate module forChild and translate sidebar
1 parent 8ab1a12 commit de3cf39

File tree

10 files changed

+103
-10
lines changed

10 files changed

+103
-10
lines changed

src/app/app.routing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { MetaGuard } from '@ngx-meta/core';
44
import { WrapperComponent } from '@shared/layouts/wrapper/wrapper.component';
55

66
const routes: Routes = [
7+
{ path: '', redirectTo: 'home', pathMatch: 'full' },
78
{
89
path: '', component: WrapperComponent, children: [
910
{
10-
path: '', loadChildren: './home/home.module#HomeModule',
11+
path: 'home', loadChildren: './home/home.module#HomeModule',
1112
data: {
1213
// for override default meta
1314
meta: {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<footer>
2+
<span class="footer__left">Angular RU Universal Starter</span>
3+
4+
<a *ngFor="let item of tMe" [href]="item.link" rel="nofollow">
5+
<img [src]="item.src" [alt]="item.alt">
6+
</a>
7+
</footer>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import { Component } from '@angular/core';
22

3+
const T_ME: any[] = [
4+
{
5+
link: 'https://t.me/angular_ru',
6+
src: 'https://camo.githubusercontent.com/cf47bb838e2e27d8bcb46de3a7abb1a74556bb0c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54656c656772616d5f636861743a2d416e67756c61725f52552d3231366263312e7376673f7374796c653d666c6174',
7+
alt: 'Angular-RU'
8+
},
9+
{
10+
link: 'https://t.me/angular_universal_ru',
11+
src: 'https://camo.githubusercontent.com/acd09569925bcdadffb848e234e1e4dbb07a6ad9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54656c656772616d5f636861743a2d416e67756c61725f52555f556e6976657273616c2d3134623130322e7376673f7374796c653d666c6174',
12+
alt: 'Angular-RU Universal'
13+
},
14+
];
15+
316
@Component({
417
selector: 'app-footer',
518
templateUrl: './footer.component.html'
619
})
720
export class FooterComponent {
21+
public tMe: any[] = T_ME;
822
}

src/app/shared/layouts/layouts.module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { RouterModule } from '@angular/router';
4-
5-
import { TranslatesModule } from '@shared/translates/translates.module';
4+
import { TranslateModule } from '@ngx-translate/core';
65

76
import { FooterComponent } from './footer/footer.component';
87
import { SidebarComponent } from './sidebar/sidebar.component';
@@ -13,7 +12,7 @@ import { WrapperComponent } from './wrapper/wrapper.component';
1312
imports: [
1413
CommonModule,
1514
RouterModule,
16-
TranslatesModule
15+
TranslateModule.forChild()
1716
],
1817
declarations: [
1918
FooterComponent,
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<nav>
22
<ul>
3-
<li><a [routerLink]="['']" [routerLinkActive]="['router-link-active']">home</a></li>
4-
<li><a [routerLink]="['/mock']" [routerLinkActive]="['router-link-active']">mock</a></li>
5-
<li><a [routerLink]="['/back']" [routerLinkActive]="['router-link-active']">back http</a></li>
3+
<li *ngFor="let item of links">
4+
<a [routerLink]="[item.link]" [routerLinkActive]="['active']">
5+
<i class="material-icons">{{ item.icon }}</i>
6+
{{ item.name | translate }}
7+
</a>
8+
</li>
69
</ul>
710
</nav>
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
2+
3+
const LINKS: any[] = [
4+
{ link: '/home', name: 'home', icon: 'home' },
5+
{ link: '/mock', name: 'mock', icon: 'accessibility' },
6+
{ link: '/back', name: 'back-http', icon: 'accessibility' },
7+
];
28

39
@Component({
410
selector: 'app-sidebar',
511
templateUrl: './sidebar.component.html'
612
})
7-
export class SidebarComponent {
13+
export class SidebarComponent implements OnInit {
14+
public links: any[];
15+
16+
ngOnInit() {
17+
this.links = LINKS.map(link => {
18+
link.name = `sidebar.${link.name}`;
19+
return link;
20+
});
21+
}
822
}

src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"sidebar": {
3+
"home": "Home",
4+
"mock": "Mock",
5+
"back-http": "Back http"
6+
},
27
"home": "This is some text in English at home page",
38
"mock": "This is some text in English at mock page",
49
"back-http": "This is some text in English at back http page"

src/assets/i18n/ru.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"sidebar": {
3+
"home": "Главная",
4+
"mock": "Мокап",
5+
"back-http": "Http на бэк"
6+
},
27
"home": "Какой-то текст на русском на домашней странице",
38
"mock": "Какой-то текст на русском на мокап странице",
49
"back-http": "Какой-то текст на русском на бэк http странице"

src/styles/layouts/_footer.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,15 @@ app-footer {
99
font-size: 12px;
1010
margin: 0 15px;
1111
overflow: hidden;
12+
footer {
13+
display: flex;
14+
flex-direction: row;
15+
align-items: center;
16+
.footer__left {
17+
flex: 1;
18+
}
19+
a {
20+
padding: 15px 0 0 10px;
21+
}
22+
}
1223
}

src/styles/layouts/_sidebar.scss

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
app-sidebar {
22
display: block;
33
width: 200px;
4-
border-right: 2px solid $color-primary;
4+
ul {
5+
margin: 0;
6+
padding: 0;
7+
border-right: 2px solid $color-primary;
8+
li {
9+
list-style-type: none;
10+
a {
11+
position: relative;
12+
cursor: pointer;
13+
display: block;
14+
background-color: transparent;
15+
color: #212121;
16+
height: 48px;
17+
line-height: 48px;
18+
text-decoration: none;
19+
font-weight: 500;
20+
text-overflow: ellipsis;
21+
white-space: nowrap;
22+
overflow: hidden;
23+
padding: 0 16px 0 48px;
24+
transition: all .3s ease-in-out;
25+
&:hover {
26+
background-color: #e0e0e0;
27+
}
28+
&.active {
29+
background-color: #e0e0e0;
30+
}
31+
.material-icons {
32+
position: absolute;
33+
top: 10px;
34+
left: 15px;
35+
}
36+
}
37+
}
38+
}
539
}

0 commit comments

Comments
 (0)