Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/country name localization (#7065)

Thomas Kaulfdd96bcd6bdc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6a2a9a94a..f964c9cae6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Fixed
+
+- Fixed an issue with the localization of the country names
+
## 3.12.0 - 2026-06-17
### Changed
diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
index ce997cf274..829129b38b 100644
--- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
+++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
@@ -373,7 +373,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
) {
for (const { code, weight } of this.assetProfile.countries) {
this.countries[code] = {
- name: getCountryName({ code, locale: this.data.locale }),
+ name: getCountryName({ code }),
value: weight
};
}
diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
index d9a5354e56..453b8cb6ad 100644
--- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
+++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
@@ -271,8 +271,7 @@
[locale]="data.locale"
[value]="
getCountryName({
- code: assetProfile?.countries[0].code,
- locale: data.locale
+ code: assetProfile?.countries[0].code
})
"
>Country</gf-value
diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
index 08c8a7a1e0..b8dede2cde 100644
--- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
+++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
@@ -438,10 +438,7 @@ export class GfHoldingDetailDialogComponent implements OnInit {
if (SymbolProfile?.countries?.length > 0) {
for (const country of SymbolProfile.countries) {
this.countries[country.code] = {
- name: getCountryName({
- code: country.code,
- locale: this.data.locale
- }),
+ name: getCountryName({ code: country.code }),
value: country.weight
};
}
diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
index 609eec3c08..0d56918740 100644
--- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
+++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
@@ -274,8 +274,7 @@
[locale]="data.locale"
[value]="
getCountryName({
- code: SymbolProfile.countries[0].code,
- locale: data.locale
+ code: SymbolProfile.countries[0].code
})
"
>Country</gf-value
diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
index 26601ad59d..9aab27dc07 100644
--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
@@ -399,10 +399,7 @@ export class GfAllocationsPageComponent implements OnInit {
: position.valueInPercentage);
} else {
this.countries[code] = {
- name: getCountryName({
- code,
- locale: this.user?.settings?.locale
- }),
+ name: getCountryName({ code }),
value:
weight *
(isNumber(position.valueInBaseCurrency)
diff --git a/apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts b/apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts
index 0dd14485f1..1af3c6d547 100644
--- a/apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts
+++ b/apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts
@@ -33,7 +33,6 @@ export class GfProductPageComponent implements OnInit {
) {}
public ngOnInit() {
- const locale = document.documentElement.lang;
const { subscriptionOffer } = this.dataService.fetchInfo();
this.price = subscriptionOffer?.price;
@@ -57,7 +56,7 @@ export class GfProductPageComponent implements OnInit {
'Türkçe'
],
name: 'Ghostfolio',
- origin: getCountryName({ locale, code: 'CH' }),
+ origin: getCountryName({ code: 'CH' }),
regions: [$localize`Global`],
slogan: 'Open Source Wealth Management',
useAnonymously: true
@@ -70,10 +69,7 @@ export class GfProductPageComponent implements OnInit {
};
if (this.product2.origin) {
- this.product2.origin = getCountryName({
- locale,
- code: this.product2.origin
- });
+ this.product2.origin = getCountryName({ code: this.product2.origin });
}
if (this.product2.regions) {
diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts
index 68b8c51bdc..a29129f91a 100644
--- a/libs/common/src/lib/helper.ts
+++ b/libs/common/src/lib/helper.ts
@@ -258,15 +258,13 @@ export function getCurrencyFromSymbol(aSymbol = '') {
return aSymbol.replace(DEFAULT_CURRENCY, '');
}
-export function getCountryName({
- code,
- locale = getLocale()
-}: {
- code: string;
- locale?: string;
-}): string {
+export function getCountryName({ code }: { code: string }): string {
try {
- return new Intl.DisplayNames([locale], { type: 'region' }).of(code) ?? code;
+ return (
+ new Intl.DisplayNames([document.documentElement.lang || locale], {
+ type: 'region'
+ }).of(code) ?? code
+ );
} catch {
return code;
}
diff --git a/libs/ui/src/lib/world-map-chart/world-map-chart.component.ts b/libs/ui/src/lib/world-map-chart/world-map-chart.component.ts
index 0d5eb73870..899441b7be 100644
--- a/libs/ui/src/lib/world-map-chart/world-map-chart.component.ts
+++ b/libs/ui/src/lib/world-map-chart/world-map-chart.component.ts
@@ -95,7 +95,7 @@ export class GfWorldMapChartComponent implements OnChanges, OnDestroy {
this.svgMapElement.options.countryNames = Object.keys(
this.svgMapElement.countries
).reduce<{ [code: string]: string }>((names, code) => {
- names[code] = getCountryName({ code, locale: this.locale });
+ names[code] = getCountryName({ code });
return names;
}, {});