Skip to content

Commit 7e49395

Browse files
feat(blog): translations for page titles (#281)
1 parent 1e2d333 commit 7e49395

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

apps/blog/src/assets/i18n/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@
108108
"readLess": "Read less"
109109
},
110110
"seo": {
111-
"metaDescription": "Angular.love - a place for all Angular enthusiasts created to inspire and educate."
111+
"metaDescription": "Angular.love - a place for all Angular enthusiasts created to inspire and educate.",
112+
"home": "Blog and community for Angular fans",
113+
"aboutUs": "About us",
114+
"becomeAuthor": "Become an author",
115+
"notFound": "Not found"
112116
},
113117
"adBanner": {
114118
"registerButton": "Download for free",

apps/blog/src/assets/i18n/pl.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@
111111
"readLess": "Czytaj mniej"
112112
},
113113
"seo": {
114-
"metaDescription": "Angular.love - ciekawostki oraz rozwiązania dla średnio-zaawansowanych oraz zaawansowanych developerów Angulara."
114+
"metaDescription": "Angular.love - ciekawostki oraz rozwiązania dla średnio-zaawansowanych oraz zaawansowanych developerów Angulara.",
115+
"home": "Blog dla sympatyków Angulara",
116+
"aboutUs": "O nas",
117+
"becomeAuthor": "Zostań autorem",
118+
"notFound": "Nie znaleziono"
115119
},
116120
"adBanner": {
117121
"registerButton": "Pobierz za darmo",

libs/blog/shared/util-seo/src/lib/services/seo.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { DOCUMENT } from '@angular/common';
2-
import { inject, Injectable, signal } from '@angular/core';
2+
import { inject, Injectable } from '@angular/core';
33
import { Meta, MetaDefinition, Title } from '@angular/platform-browser';
44
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
5+
import { TranslocoService } from '@jsverse/transloco';
56
import { filter, map, switchMap } from 'rxjs';
67

78
import { SeoMetaData } from '@angular-love/contracts/articles';
@@ -19,6 +20,7 @@ export class SeoService {
1920
private readonly _meta = inject(Meta);
2021
private readonly _document = inject(DOCUMENT);
2122
private readonly _seoConfig = inject(SEO_CONFIG);
23+
private readonly _translocoService = inject(TranslocoService);
2224
private _url = '';
2325

2426
init(): void {
@@ -47,7 +49,9 @@ export class SeoService {
4749
this.updateTag(seoConfig.siteName, 'ogSiteName');
4850

4951
if (routeData && routeData['seo'] && routeData['seo']['title']) {
50-
this.setTitle(`${routeData['seo']['title']} - ${seoConfig.title}`);
52+
this.setTitle(
53+
`${seoConfig.title} - ${this._translocoService.translate(routeData['seo']['title'])}`,
54+
);
5155
} else {
5256
this.setTitle('');
5357
}

libs/blog/shell/feature-shell-web/src/lib/blog-shell.routes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const routes: Route[] = [
3131
(await import('@angular-love/blog/home/feature-home'))
3232
.HomePageComponent,
3333
data: {
34-
seo: { title: 'Home' },
34+
seo: { title: 'seo.home' },
3535
},
3636
},
3737
{
@@ -48,7 +48,7 @@ export const routes: Route[] = [
4848
(await import('@angular-love/feature-about-us'))
4949
.FeatureAboutUsComponent,
5050
data: {
51-
seo: { title: 'About Us' },
51+
seo: { title: 'seo.aboutUs' },
5252
},
5353
},
5454
{
@@ -63,7 +63,7 @@ export const routes: Route[] = [
6363
(await import('@angular-love/blog/become-author-page-feature'))
6464
.BecomeAuthorPageFeatureComponent,
6565
data: {
66-
seo: { title: 'Become an author' },
66+
seo: { title: 'seo.becomeAuthor' },
6767
},
6868
},
6969
{
@@ -78,7 +78,7 @@ export const routes: Route[] = [
7878
(await import('@angular-love/blog/shared/ui-not-found'))
7979
.NotFoundPageComponent,
8080
data: {
81-
seo: { title: 'Not Found' },
81+
seo: { title: 'seo.notFound' },
8282
},
8383
},
8484
...articleRoutes,

0 commit comments

Comments
 (0)