Browse Source

Bugfix/country name localization (#7065)

* Fix country name localization

* Update changelog
pull/7068/head
Thomas Kaul 4 days ago
committed by GitHub
parent
commit
fdd96bcd6b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 2
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  3. 3
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
  4. 5
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
  5. 3
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
  6. 5
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
  7. 8
      apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts
  8. 14
      libs/common/src/lib/helper.ts
  9. 2
      libs/ui/src/lib/world-map-chart/world-map-chart.component.ts

6
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/), 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). 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 ## 3.12.0 - 2026-06-17
### Changed ### Changed

2
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) { for (const { code, weight } of this.assetProfile.countries) {
this.countries[code] = { this.countries[code] = {
name: getCountryName({ code, locale: this.data.locale }), name: getCountryName({ code }),
value: weight value: weight
}; };
} }

3
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html

@ -271,8 +271,7 @@
[locale]="data.locale" [locale]="data.locale"
[value]=" [value]="
getCountryName({ getCountryName({
code: assetProfile?.countries[0].code, code: assetProfile?.countries[0].code
locale: data.locale
}) })
" "
>Country</gf-value >Country</gf-value

5
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) { if (SymbolProfile?.countries?.length > 0) {
for (const country of SymbolProfile.countries) { for (const country of SymbolProfile.countries) {
this.countries[country.code] = { this.countries[country.code] = {
name: getCountryName({ name: getCountryName({ code: country.code }),
code: country.code,
locale: this.data.locale
}),
value: country.weight value: country.weight
}; };
} }

3
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html

@ -274,8 +274,7 @@
[locale]="data.locale" [locale]="data.locale"
[value]=" [value]="
getCountryName({ getCountryName({
code: SymbolProfile.countries[0].code, code: SymbolProfile.countries[0].code
locale: data.locale
}) })
" "
>Country</gf-value >Country</gf-value

5
apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

@ -399,10 +399,7 @@ export class GfAllocationsPageComponent implements OnInit {
: position.valueInPercentage); : position.valueInPercentage);
} else { } else {
this.countries[code] = { this.countries[code] = {
name: getCountryName({ name: getCountryName({ code }),
code,
locale: this.user?.settings?.locale
}),
value: value:
weight * weight *
(isNumber(position.valueInBaseCurrency) (isNumber(position.valueInBaseCurrency)

8
apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts

@ -33,7 +33,6 @@ export class GfProductPageComponent implements OnInit {
) {} ) {}
public ngOnInit() { public ngOnInit() {
const locale = document.documentElement.lang;
const { subscriptionOffer } = this.dataService.fetchInfo(); const { subscriptionOffer } = this.dataService.fetchInfo();
this.price = subscriptionOffer?.price; this.price = subscriptionOffer?.price;
@ -57,7 +56,7 @@ export class GfProductPageComponent implements OnInit {
'Türkçe' 'Türkçe'
], ],
name: 'Ghostfolio', name: 'Ghostfolio',
origin: getCountryName({ locale, code: 'CH' }), origin: getCountryName({ code: 'CH' }),
regions: [$localize`Global`], regions: [$localize`Global`],
slogan: 'Open Source Wealth Management', slogan: 'Open Source Wealth Management',
useAnonymously: true useAnonymously: true
@ -70,10 +69,7 @@ export class GfProductPageComponent implements OnInit {
}; };
if (this.product2.origin) { if (this.product2.origin) {
this.product2.origin = getCountryName({ this.product2.origin = getCountryName({ code: this.product2.origin });
locale,
code: this.product2.origin
});
} }
if (this.product2.regions) { if (this.product2.regions) {

14
libs/common/src/lib/helper.ts

@ -258,15 +258,13 @@ export function getCurrencyFromSymbol(aSymbol = '') {
return aSymbol.replace(DEFAULT_CURRENCY, ''); return aSymbol.replace(DEFAULT_CURRENCY, '');
} }
export function getCountryName({ export function getCountryName({ code }: { code: string }): string {
code,
locale = getLocale()
}: {
code: string;
locale?: string;
}): string {
try { 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 { } catch {
return code; return code;
} }

2
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.options.countryNames = Object.keys(
this.svgMapElement.countries this.svgMapElement.countries
).reduce<{ [code: string]: string }>((names, code) => { ).reduce<{ [code: string]: string }>((names, code) => {
names[code] = getCountryName({ code, locale: this.locale }); names[code] = getCountryName({ code });
return names; return names;
}, {}); }, {});

Loading…
Cancel
Save