From 81245635af1e2a75fb684a16028bc41447be8054 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 13 Aug 2022 10:29:36 +0200 Subject: [PATCH] Feature/setup i18n (#1139) * Setup i18n * Update changelog --- CHANGELOG.md | 4 + angular.json | 41 +- apps/api/src/app/auth/auth.controller.ts | 13 +- .../subscription/subscription.controller.ts | 11 +- apps/client/src/app/app-routing.module.ts | 20 +- .../access-table/access-table.component.html | 6 +- .../access-table/access-table.component.ts | 2 + .../login-with-access-token-dialog.html | 6 +- .../pages/about/changelog/changelog-page.html | 4 +- .../privacy-policy/privacy-policy-page.html | 2 +- .../hallo-ghostfolio-page.html | 2 +- .../hello-ghostfolio-page.html | 2 +- ...ostfolio-meets-internet-identity-page.html | 2 +- apps/client/src/app/pages/blog/blog-page.html | 10 +- .../src/app/pages/landing/landing-page.html | 4 +- .../src/app/pages/register/register-page.html | 6 +- apps/client/src/assets/index.html | 10 + apps/client/src/assets/robots.txt | 4 +- apps/client/src/assets/site.webmanifest | 4 +- apps/client/src/assets/sitemap.xml | 28 +- apps/client/src/index.html | 16 +- apps/client/src/locales/messages.de.xlf | 2278 +++++++++++++++++ apps/client/src/locales/messages.xlf | 2278 +++++++++++++++++ libs/common/src/lib/config.ts | 1 + package.json | 5 +- 25 files changed, 4688 insertions(+), 71 deletions(-) create mode 100644 apps/client/src/assets/index.html create mode 100644 apps/client/src/locales/messages.de.xlf create mode 100644 apps/client/src/locales/messages.xlf diff --git a/CHANGELOG.md b/CHANGELOG.md index 730e47554..773c52fb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Set up i18n support + ### Changed - Reduced the maximum width of the performance chart on the home page diff --git a/angular.json b/angular.json index bd60b92ee..8ee428695 100644 --- a/angular.json +++ b/angular.json @@ -77,41 +77,50 @@ "polyfills": "apps/client/src/polyfills.ts", "tsConfig": "apps/client/tsconfig.app.json", "assets": [ - "apps/client/src/assets", { "glob": "assetlinks.json", "input": "apps/client/src/assets", - "output": "./.well-known" + "output": "./../.well-known" }, { "glob": "CHANGELOG.md", "input": "", - "output": "./assets" + "output": "./../assets" + }, + { + "glob": "index.html", + "input": "apps/client/src/assets", + "output": "./../" }, { "glob": "LICENSE", "input": "", - "output": "./assets" + "output": "./../assets" }, { "glob": "robots.txt", "input": "apps/client/src/assets", - "output": "./" + "output": "./../" }, { "glob": "sitemap.xml", "input": "apps/client/src/assets", - "output": "./" + "output": "./../" }, { "glob": "**/*", "input": "node_modules/ionicons/dist/ionicons", - "output": "./ionicons" + "output": "./../ionicons" }, { "glob": "**/*.js", "input": "node_modules/ionicons/dist/", - "output": "./" + "output": "./../" + }, + { + "glob": "**/*", + "input": "apps/client/src/assets", + "output": "./../assets/" } ], "styles": ["apps/client/src/styles.scss"], @@ -124,6 +133,10 @@ "namedChunks": true }, "configurations": { + "development-en": { + "baseHref": "/en/", + "localize": ["en"] + }, "production": { "fileReplacements": [ { @@ -162,6 +175,9 @@ "proxyConfig": "apps/client/proxy.conf.json" }, "configurations": { + "development-en": { + "browserTarget": "client:build:development-en" + }, "production": { "browserTarget": "client:build:production" } @@ -188,6 +204,15 @@ "outputs": ["coverage/apps/client"] } }, + "i18n": { + "locales": { + "de": { + "baseHref": "/de/", + "translation": "apps/client/src/locales/messages.de.xlf" + } + }, + "sourceLocale": "en" + }, "tags": [] }, "client-e2e": { diff --git a/apps/api/src/app/auth/auth.controller.ts b/apps/api/src/app/auth/auth.controller.ts index 9cb6f8132..749f6f037 100644 --- a/apps/api/src/app/auth/auth.controller.ts +++ b/apps/api/src/app/auth/auth.controller.ts @@ -1,5 +1,6 @@ import { WebAuthService } from '@ghostfolio/api/app/auth/web-auth.service'; import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; +import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; import { OAuthResponse } from '@ghostfolio/common/interfaces'; import { Body, @@ -62,9 +63,17 @@ export class AuthController { const jwt: string = req.user.jwt; if (jwt) { - res.redirect(`${this.configurationService.get('ROOT_URL')}/auth/${jwt}`); + res.redirect( + `${this.configurationService.get( + 'ROOT_URL' + )}/${DEFAULT_LANGUAGE_CODE}/auth/${jwt}` + ); } else { - res.redirect(`${this.configurationService.get('ROOT_URL')}/auth`); + res.redirect( + `${this.configurationService.get( + 'ROOT_URL' + )}/${DEFAULT_LANGUAGE_CODE}/auth` + ); } } diff --git a/apps/api/src/app/subscription/subscription.controller.ts b/apps/api/src/app/subscription/subscription.controller.ts index aabc46d24..70317fe76 100644 --- a/apps/api/src/app/subscription/subscription.controller.ts +++ b/apps/api/src/app/subscription/subscription.controller.ts @@ -1,6 +1,9 @@ import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; import { PropertyService } from '@ghostfolio/api/services/property/property.service'; -import { PROPERTY_COUPONS } from '@ghostfolio/common/config'; +import { + DEFAULT_LANGUAGE_CODE, + PROPERTY_COUPONS +} from '@ghostfolio/common/config'; import { Coupon } from '@ghostfolio/common/interfaces'; import type { RequestWithUser } from '@ghostfolio/common/types'; import { @@ -93,7 +96,11 @@ export class SubscriptionController { 'SubscriptionController' ); - res.redirect(`${this.configurationService.get('ROOT_URL')}/account`); + res.redirect( + `${this.configurationService.get( + 'ROOT_URL' + )}/${DEFAULT_LANGUAGE_CODE}/account` + ); } @Post('stripe/checkout-session') diff --git a/apps/client/src/app/app-routing.module.ts b/apps/client/src/app/app-routing.module.ts index 558a3360d..bc10c4cd7 100644 --- a/apps/client/src/app/app-routing.module.ts +++ b/apps/client/src/app/app-routing.module.ts @@ -54,45 +54,45 @@ const routes: Routes = [ import('./pages/blog/blog-page.module').then((m) => m.BlogPageModule) }, { - path: 'de/blog/2021/07/hallo-ghostfolio', + path: 'blog/2021/07/hallo-ghostfolio', loadChildren: () => import( './pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.module' ).then((m) => m.HalloGhostfolioPageModule) }, { - path: 'demo', - loadChildren: () => - import('./pages/demo/demo-page.module').then((m) => m.DemoPageModule) - }, - { - path: 'en/blog/2021/07/hello-ghostfolio', + path: 'blog/2021/07/hello-ghostfolio', loadChildren: () => import( './pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.module' ).then((m) => m.HelloGhostfolioPageModule) }, { - path: 'en/blog/2022/01/ghostfolio-first-months-in-open-source', + path: 'blog/2022/01/ghostfolio-first-months-in-open-source', loadChildren: () => import( './pages/blog/2022/01/first-months-in-open-source/first-months-in-open-source-page.module' ).then((m) => m.FirstMonthsInOpenSourcePageModule) }, { - path: 'en/blog/2022/07/ghostfolio-meets-internet-identity', + path: 'blog/2022/07/ghostfolio-meets-internet-identity', loadChildren: () => import( './pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.module' ).then((m) => m.GhostfolioMeetsInternetIdentityPageModule) }, { - path: 'en/blog/2022/07/how-do-i-get-my-finances-in-order', + path: 'blog/2022/07/how-do-i-get-my-finances-in-order', loadChildren: () => import( './pages/blog/2022/07/how-do-i-get-my-finances-in-order/how-do-i-get-my-finances-in-order-page.module' ).then((m) => m.HowDoIGetMyFinancesInOrderPageModule) }, + { + path: 'demo', + loadChildren: () => + import('./pages/demo/demo-page.module').then((m) => m.DemoPageModule) + }, { path: 'faq', loadChildren: () => diff --git a/apps/client/src/app/components/access-table/access-table.component.html b/apps/client/src/app/components/access-table/access-table.component.html index be184b0e0..e3587d3fe 100644 --- a/apps/client/src/app/components/access-table/access-table.component.html +++ b/apps/client/src/app/components/access-table/access-table.component.html @@ -21,8 +21,10 @@ - {{ baseUrl }}/p/{{ element.id }}{{ baseUrl }}/{{ defaultLanguageCode }}/p/{{ element.id }} diff --git a/apps/client/src/app/components/access-table/access-table.component.ts b/apps/client/src/app/components/access-table/access-table.component.ts index 210995c53..92f707378 100644 --- a/apps/client/src/app/components/access-table/access-table.component.ts +++ b/apps/client/src/app/components/access-table/access-table.component.ts @@ -8,6 +8,7 @@ import { Output } from '@angular/core'; import { MatTableDataSource } from '@angular/material/table'; +import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; import { Access } from '@ghostfolio/common/interfaces'; @Component({ @@ -24,6 +25,7 @@ export class AccessTableComponent implements OnChanges, OnInit { public baseUrl = window.location.origin; public dataSource: MatTableDataSource; + public defaultLanguageCode = DEFAULT_LANGUAGE_CODE; public displayedColumns = []; public constructor() {} diff --git a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html index 8a2110ef1..0106acac8 100644 --- a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html +++ b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html @@ -25,14 +25,14 @@ > Sign in with Internet Identity - Sign in with Google diff --git a/apps/client/src/app/pages/about/changelog/changelog-page.html b/apps/client/src/app/pages/about/changelog/changelog-page.html index e75178298..ac462b147 100644 --- a/apps/client/src/app/pages/about/changelog/changelog-page.html +++ b/apps/client/src/app/pages/about/changelog/changelog-page.html @@ -4,7 +4,7 @@

Changelog

- + @@ -15,7 +15,7 @@

License

- + diff --git a/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.html b/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.html index f3021edeb..44f76264e 100644 --- a/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.html +++ b/apps/client/src/app/pages/about/privacy-policy/privacy-policy-page.html @@ -2,7 +2,7 @@

Privacy Policy

- +
diff --git a/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html b/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html index ae3aa358b..b3b2fde5f 100644 --- a/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html +++ b/apps/client/src/app/pages/blog/2021/07/hallo-ghostfolio/hallo-ghostfolio-page.html @@ -68,7 +68,7 @@

Ghostfol.io Screenshot diff --git a/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html b/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html index 47c2819fb..43e3e0e35 100644 --- a/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html +++ b/apps/client/src/app/pages/blog/2021/07/hello-ghostfolio/hello-ghostfolio-page.html @@ -66,7 +66,7 @@

Ghostfol.io Screenshot diff --git a/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html b/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html index c75d2a101..2273cc2a2 100644 --- a/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html +++ b/apps/client/src/app/pages/blog/2022/07/ghostfolio-meets-internet-identity/ghostfolio-meets-internet-identity-page.html @@ -8,7 +8,7 @@ Ghostfolio meets Internet Identity Teaser diff --git a/apps/client/src/app/pages/blog/blog-page.html b/apps/client/src/app/pages/blog/blog-page.html index 12f16b654..dbea378ed 100644 --- a/apps/client/src/app/pages/blog/blog-page.html +++ b/apps/client/src/app/pages/blog/blog-page.html @@ -8,7 +8,7 @@

@@ -34,7 +34,7 @@
@@ -60,7 +60,7 @@
@@ -86,7 +86,7 @@
Hello Ghostfolio
@@ -110,7 +110,7 @@
diff --git a/apps/client/src/app/pages/register/register-page.html b/apps/client/src/app/pages/register/register-page.html index 770beb345..60e8c3f29 100644 --- a/apps/client/src/app/pages/register/register-page.html +++ b/apps/client/src/app/pages/register/register-page.html @@ -36,15 +36,15 @@ > Continue with Internet Identity - Continue with Google diff --git a/apps/client/src/assets/index.html b/apps/client/src/assets/index.html new file mode 100644 index 000000000..6ebf79945 --- /dev/null +++ b/apps/client/src/assets/index.html @@ -0,0 +1,10 @@ + + + + Ghostfol.io + + + + + + diff --git a/apps/client/src/assets/robots.txt b/apps/client/src/assets/robots.txt index f87a4c1b5..059aea258 100644 --- a/apps/client/src/assets/robots.txt +++ b/apps/client/src/assets/robots.txt @@ -1,6 +1,6 @@ User-agent: * Allow: / -Disallow: /about/privacy-policy -Disallow: /p/* +Disallow: /en/about/privacy-policy +Disallow: /en/p/* Sitemap: https://ghostfol.io/sitemap.xml diff --git a/apps/client/src/assets/site.webmanifest b/apps/client/src/assets/site.webmanifest index 91853e97b..5948d94fe 100644 --- a/apps/client/src/assets/site.webmanifest +++ b/apps/client/src/assets/site.webmanifest @@ -6,12 +6,12 @@ "icons": [ { "sizes": "192x192", - "src": "/assets/android-chrome-192x192.png", + "src": "/en/assets/android-chrome-192x192.png", "type": "image/png" }, { "sizes": "512x512", - "src": "/assets/android-chrome-512x512.png", + "src": "/en/assets/android-chrome-512x512.png", "type": "image/png" } ], diff --git a/apps/client/src/assets/sitemap.xml b/apps/client/src/assets/sitemap.xml index 0b2cf4ee3..b8ac3a840 100644 --- a/apps/client/src/assets/sitemap.xml +++ b/apps/client/src/assets/sitemap.xml @@ -9,23 +9,19 @@ 2022-07-29T00:00:00+00:00 - https://ghostfol.io/about - 2022-07-29T00:00:00+00:00 - - - https://ghostfol.io/about/changelog + https://ghostfol.io/de/blog/2021/07/hallo-ghostfolio 2022-07-29T00:00:00+00:00 - https://ghostfol.io/blog + https://ghostfol.io/en/about 2022-07-29T00:00:00+00:00 - https://ghostfol.io/de/blog/2021/07/hallo-ghostfolio + https://ghostfol.io/en/about/changelog 2022-07-29T00:00:00+00:00 - https://ghostfol.io/demo + https://ghostfol.io/en/blog 2022-07-29T00:00:00+00:00 @@ -45,27 +41,31 @@ 2022-07-29T00:00:00+00:00 - https://ghostfol.io/faq + https://ghostfol.io/en/demo + 2022-07-29T00:00:00+00:00 + + + https://ghostfol.io/en/faq 2022-07-29T00:00:00+00:00 - https://ghostfol.io/features + https://ghostfol.io/en/features 2022-07-29T00:00:00+00:00 - https://ghostfol.io/markets + https://ghostfol.io/en/markets 2022-07-29T00:00:00+00:00 - https://ghostfol.io/pricing + https://ghostfol.io/en/pricing 2022-07-29T00:00:00+00:00 - https://ghostfol.io/register + https://ghostfol.io/en/register 2022-07-29T00:00:00+00:00 - https://ghostfol.io/resources + https://ghostfol.io/en/resources 2022-07-29T00:00:00+00:00 diff --git a/apps/client/src/index.html b/apps/client/src/index.html index 2e20f9d25..970431f9d 100644 --- a/apps/client/src/index.html +++ b/apps/client/src/index.html @@ -21,7 +21,7 @@ /> - + - + - +