From 335553e8914e451c919fabc5f822dd8b5563003a Mon Sep 17 00:00:00 2001
From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com>
Date: Tue, 16 Aug 2022 20:53:14 +0200
Subject: [PATCH] Feature/tag template literal strings (#1152)
* Tagged template literal strings
* Update changelog
---
CHANGELOG.md | 4 +
.../access-table/access-table.component.ts | 2 +-
.../accounts-table.component.ts | 4 +-
.../admin-overview.component.ts | 16 +-
.../admin-users/admin-users.component.ts | 4 +-
.../app/components/header/header.component.ts | 2 +-
.../portfolio-summary.component.ts | 2 +-
.../src/app/core/http-response.interceptor.ts | 12 +-
.../pages/account/account-page.component.ts | 18 +-
.../src/app/pages/demo/demo-page.component.ts | 2 +-
.../transactions-page.component.ts | 4 +-
apps/client/src/locales/messages.de.xlf | 184 ++++++++++++++++++
apps/client/src/locales/messages.xlf | 161 +++++++++++++++
.../activities-table.component.ts | 4 +-
14 files changed, 393 insertions(+), 26 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba800403d..c6bf4596f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Set up `ng-extract-i18n-merge` to improve the i18n extraction and merge workflow
+### Changed
+
+- Tagged template literal strings in components for localization with `$localize`
+
## 1.179.5 - 15.08.2022
### Added
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 92f707378..de26e5938 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
@@ -46,7 +46,7 @@ export class AccessTableComponent implements OnChanges, OnInit {
public onDeleteAccess(aId: string) {
const confirmation = confirm(
- 'Do you really want to revoke this granted access?'
+ $localize`Do you really want to revoke this granted access?`
);
if (confirmation) {
diff --git a/apps/client/src/app/components/accounts-table/accounts-table.component.ts b/apps/client/src/app/components/accounts-table/accounts-table.component.ts
index d07bf076d..bd644d582 100644
--- a/apps/client/src/app/components/accounts-table/accounts-table.component.ts
+++ b/apps/client/src/app/components/accounts-table/accounts-table.component.ts
@@ -69,7 +69,9 @@ export class AccountsTableComponent implements OnChanges, OnDestroy, OnInit {
}
public onDeleteAccount(aId: string) {
- const confirmation = confirm('Do you really want to delete this account?');
+ const confirmation = confirm(
+ $localize`Do you really want to delete this account?`
+ );
if (confirmation) {
this.accountDeleted.emit(aId);
diff --git a/apps/client/src/app/components/admin-overview/admin-overview.component.ts b/apps/client/src/app/components/admin-overview/admin-overview.component.ts
index 493802806..c351f1a68 100644
--- a/apps/client/src/app/components/admin-overview/admin-overview.component.ts
+++ b/apps/client/src/app/components/admin-overview/admin-overview.component.ts
@@ -103,7 +103,7 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
}
public onAddCurrency() {
- const currency = prompt('Please add a currency:');
+ const currency = prompt($localize`Please add a currency:`);
if (currency) {
const currencies = uniq([...this.customCurrencies, currency]);
@@ -116,7 +116,9 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
}
public onDeleteCoupon(aCouponCode: string) {
- const confirmation = confirm('Do you really want to delete this coupon?');
+ const confirmation = confirm(
+ $localize`Do you really want to delete this coupon?`
+ );
if (confirmation === true) {
const coupons = this.coupons.filter((coupon) => {
@@ -127,7 +129,9 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
}
public onDeleteCurrency(aCurrency: string) {
- const confirmation = confirm('Do you really want to delete this currency?');
+ const confirmation = confirm(
+ $localize`Do you really want to delete this currency?`
+ );
if (confirmation === true) {
const currencies = this.customCurrencies.filter((currency) => {
@@ -142,7 +146,9 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
}
public onFlushCache() {
- const confirmation = confirm('Do you really want to flush the cache?');
+ const confirmation = confirm(
+ $localize`Do you really want to flush the cache?`
+ );
if (confirmation === true) {
this.cacheService
@@ -190,7 +196,7 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
}
public onSetSystemMessage() {
- const systemMessage = prompt('Please set your system message:');
+ const systemMessage = prompt($localize`Please set your system message:`);
if (systemMessage) {
this.putSystemMessage(systemMessage);
diff --git a/apps/client/src/app/components/admin-users/admin-users.component.ts b/apps/client/src/app/components/admin-users/admin-users.component.ts
index fc5aaa83b..7f2a34d2b 100644
--- a/apps/client/src/app/components/admin-users/admin-users.component.ts
+++ b/apps/client/src/app/components/admin-users/admin-users.component.ts
@@ -55,7 +55,9 @@ export class AdminUsersComponent implements OnDestroy, OnInit {
}
public onDeleteUser(aId: string) {
- const confirmation = confirm('Do you really want to delete this user?');
+ const confirmation = confirm(
+ $localize`Do you really want to delete this user?`
+ );
if (confirmation) {
this.dataService
diff --git a/apps/client/src/app/components/header/header.component.ts b/apps/client/src/app/components/header/header.component.ts
index 3e04f2206..4e3611cb4 100644
--- a/apps/client/src/app/components/header/header.component.ts
+++ b/apps/client/src/app/components/header/header.component.ts
@@ -123,7 +123,7 @@ export class HeaderComponent implements OnChanges {
.loginAnonymous(data?.accessToken)
.pipe(
catchError(() => {
- alert('Oops! Incorrect Security Token.');
+ alert($localize`Oops! Incorrect Security Token.`);
return EMPTY;
}),
diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts
index d8cda52f4..7a69f0d58 100644
--- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts
+++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts
@@ -45,7 +45,7 @@ export class PortfolioSummaryComponent implements OnChanges, OnInit {
public onEditEmergencyFund() {
const emergencyFundInput = prompt(
- 'Please enter the amount of your emergency fund:',
+ $localize`Please enter the amount of your emergency fund:`,
this.summary.emergencyFund.toString()
);
const emergencyFund = parseFloat(emergencyFundInput?.trim());
diff --git a/apps/client/src/app/core/http-response.interceptor.ts b/apps/client/src/app/core/http-response.interceptor.ts
index b76884ffa..bd418405b 100644
--- a/apps/client/src/app/core/http-response.interceptor.ts
+++ b/apps/client/src/app/core/http-response.interceptor.ts
@@ -56,14 +56,16 @@ export class HttpResponseInterceptor implements HttpInterceptor {
if (!this.snackBarRef) {
if (this.info.isReadOnlyMode) {
this.snackBarRef = this.snackBar.open(
- 'This feature is currently unavailable. Please try again later.',
+ $localize`This feature is currently unavailable. Please try again later.`,
undefined,
{ duration: 6000 }
);
} else {
this.snackBarRef = this.snackBar.open(
- 'This feature requires a subscription.',
- this.hasPermissionForSubscription ? 'Upgrade Plan' : undefined,
+ $localize`This feature requires a subscription.`,
+ this.hasPermissionForSubscription
+ ? $localize`Upgrade Plan`
+ : undefined,
{ duration: 6000 }
);
}
@@ -79,8 +81,8 @@ export class HttpResponseInterceptor implements HttpInterceptor {
} else if (error.status === StatusCodes.INTERNAL_SERVER_ERROR) {
if (!this.snackBarRef) {
this.snackBarRef = this.snackBar.open(
- 'Oops! Something went wrong. Please try again later.',
- 'Okay',
+ $localize`Oops! Something went wrong. Please try again later.`,
+ $localize`Okay`,
{ duration: 6000 }
);
diff --git a/apps/client/src/app/pages/account/account-page.component.ts b/apps/client/src/app/pages/account/account-page.component.ts
index 804a48565..5cdb2f624 100644
--- a/apps/client/src/app/pages/account/account-page.component.ts
+++ b/apps/client/src/app/pages/account/account-page.component.ts
@@ -218,7 +218,7 @@ export class AccountPageComponent implements OnDestroy, OnInit {
}
public onRedeemCoupon() {
- let couponCode = prompt('Please enter your coupon code:');
+ let couponCode = prompt($localize`Please enter your coupon code:`);
couponCode = couponCode?.trim();
if (couponCode) {
@@ -227,17 +227,21 @@ export class AccountPageComponent implements OnDestroy, OnInit {
.pipe(
takeUntil(this.unsubscribeSubject),
catchError(() => {
- this.snackBar.open('😞 Could not redeem coupon code', undefined, {
- duration: 3000
- });
+ this.snackBar.open(
+ '😞 ' + $localize`Could not redeem coupon code`,
+ undefined,
+ {
+ duration: 3000
+ }
+ );
return EMPTY;
})
)
.subscribe(() => {
this.snackBarRef = this.snackBar.open(
- '✅ Coupon code has been redeemed',
- 'Reload',
+ '✅' + $localize`Coupon code has been redeemed`,
+ $localize`Reload`,
{
duration: 3000
}
@@ -283,7 +287,7 @@ export class AccountPageComponent implements OnDestroy, OnInit {
this.registerDevice();
} else {
const confirmation = confirm(
- 'Do you really want to remove this sign in method?'
+ $localize`Do you really want to remove this sign in method?`
);
if (confirmation) {
diff --git a/apps/client/src/app/pages/demo/demo-page.component.ts b/apps/client/src/app/pages/demo/demo-page.component.ts
index dce634a7d..c62ece50a 100644
--- a/apps/client/src/app/pages/demo/demo-page.component.ts
+++ b/apps/client/src/app/pages/demo/demo-page.component.ts
@@ -28,7 +28,7 @@ export class DemoPageComponent implements OnDestroy {
if (hasToken) {
alert(
- 'As you are already logged in, you cannot access the demo account.'
+ $localize`As you are already logged in, you cannot access the demo account.`
);
} else {
this.tokenStorageService.saveToken(this.info.demoAuthToken, true);
diff --git a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
index 80c0701b5..d0fc9ee63 100644
--- a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
+++ b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
@@ -188,7 +188,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
input.type = 'file';
input.onchange = (event) => {
- this.snackBar.open('⏳ Importing data...');
+ this.snackBar.open('⏳' + $localize`Importing data...`);
// Getting the file reference
const file = (event.target as HTMLInputElement).files[0];
@@ -334,7 +334,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
private handleImportSuccess() {
this.fetchActivities();
- this.snackBar.open('✅ Import has been completed', undefined, {
+ this.snackBar.open('✅' + $localize`Import has been completed`, undefined, {
duration: 3000
});
}
diff --git a/apps/client/src/locales/messages.de.xlf b/apps/client/src/locales/messages.de.xlf
index e71c1cdd9..ccb3b6e86 100644
--- a/apps/client/src/locales/messages.de.xlf
+++ b/apps/client/src/locales/messages.de.xlf
@@ -2256,6 +2256,190 @@
126
+
+
+ Do you really want to revoke this granted access?
+
+ apps/client/src/app/components/access-table/access-table.component.ts
+ 49
+
+
+
+
+ Do you really want to delete this account?
+
+ apps/client/src/app/components/accounts-table/accounts-table.component.ts
+ 73
+
+
+
+
+ Please add a currency:
+
+ apps/client/src/app/components/admin-overview/admin-overview.component.ts
+ 106
+
+
+
+
+ Do you really want to delete this coupon?
+
+ apps/client/src/app/components/admin-overview/admin-overview.component.ts
+ 120
+
+
+
+
+ Do you really want to delete this currency?
+
+ apps/client/src/app/components/admin-overview/admin-overview.component.ts
+ 133
+
+
+
+
+ Do you really want to flush the cache?
+
+ apps/client/src/app/components/admin-overview/admin-overview.component.ts
+ 150
+
+
+
+
+ Please set your system message:
+
+ apps/client/src/app/components/admin-overview/admin-overview.component.ts
+ 199
+
+
+
+
+ Do you really want to delete this user?
+
+ apps/client/src/app/components/admin-users/admin-users.component.ts
+ 59
+
+
+
+
+ Please enter the amount of your emergency fund:
+
+ apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts
+ 48
+
+
+
+
+ This feature is currently unavailable. Please try again later.
+
+ apps/client/src/app/core/http-response.interceptor.ts
+ 59
+
+
+
+
+ This feature requires a subscription.
+
+ apps/client/src/app/core/http-response.interceptor.ts
+ 65
+
+
+
+
+ Upgrade Plan
+
+ apps/client/src/app/core/http-response.interceptor.ts
+ 67
+
+
+
+
+ Oops! Something went wrong. Please try again later.
+
+ apps/client/src/app/core/http-response.interceptor.ts
+ 84
+
+
+
+
+ Okay
+
+ apps/client/src/app/core/http-response.interceptor.ts
+ 85
+
+
+
+
+ Please enter your coupon code:
+
+ apps/client/src/app/pages/account/account-page.component.ts
+ 221
+
+
+
+
+ Could not redeem coupon code
+
+ apps/client/src/app/pages/account/account-page.component.ts
+ 231
+
+
+
+
+ Coupon code has been redeemed
+
+ apps/client/src/app/pages/account/account-page.component.ts
+ 243
+
+
+
+
+ Reload
+
+ apps/client/src/app/pages/account/account-page.component.ts
+ 244
+
+
+
+
+ Do you really want to remove this sign in method?
+
+ apps/client/src/app/pages/account/account-page.component.ts
+ 290
+
+
+
+
+ As you are already logged in, you cannot access the demo account.
+
+ apps/client/src/app/pages/demo/demo-page.component.ts
+ 31
+
+
+
+
+ Importing data...
+
+ apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
+ 191
+
+
+
+
+ Import has been completed
+
+ apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
+ 337
+
+
+
+
+ Do you really want to delete this activity?
+
+ libs/ui/src/lib/activities-table/activities-table.component.ts
+ 136
+
+