Browse Source

Skip untranslated meta descriptions of public pages

pull/8369/head
Thomas Kaul 4 weeks ago
parent
commit
ecca30c10d
  1. 6
      apps/api/src/middlewares/html-template.middleware.ts
  2. 10
      apps/api/src/services/i18n/i18n.service.ts
  3. 9
      apps/client/src/app/pages/i18n/i18n-page.html

6
apps/api/src/middlewares/html-template.middleware.ts

@ -258,7 +258,8 @@ export class HtmlTemplateMiddleware implements NestMiddleware {
): [string, string][] { ): [string, string][] {
const description = this.i18nService.getTranslation({ const description = this.i18nService.getTranslation({
languageCode, languageCode,
id: 'metaDescription.resources.personalFinanceTools.product' id: 'metaDescription.resources.personalFinanceTools.product',
skipUntranslated: true
}); });
const path = [ const path = [
@ -304,7 +305,8 @@ export class HtmlTemplateMiddleware implements NestMiddleware {
const description = this.i18nService.getTranslation({ const description = this.i18nService.getTranslation({
languageCode, languageCode,
id: routeId id: routeId,
skipUntranslated: true
}); });
return [ return [

10
apps/api/src/services/i18n/i18n.service.ts

@ -43,11 +43,13 @@ export class I18nService implements OnModuleInit {
public getTranslation({ public getTranslation({
id, id,
languageCode, languageCode,
placeholders placeholders,
skipUntranslated = false
}: { }: {
id: string; id: string;
languageCode: string; languageCode: string;
placeholders?: Record<string, string | number>; placeholders?: Record<string, string | number>;
skipUntranslated?: boolean;
}): string { }): string {
const languageCodeToUse = this.translations[languageCode] const languageCodeToUse = this.translations[languageCode]
? languageCode ? languageCode
@ -61,9 +63,13 @@ export class I18nService implements OnModuleInit {
return ''; return '';
} }
const targetSelector = skipUntranslated
? 'target:not([state="new"])'
: 'target';
let translatedText = $( let translatedText = $(
`trans-unit[id="${id}"] > ${ `trans-unit[id="${id}"] > ${
languageCodeToUse === DEFAULT_LANGUAGE_CODE ? 'source' : 'target' languageCodeToUse === DEFAULT_LANGUAGE_CODE ? 'source' : targetSelector
}` }`
).text(); ).text();

9
apps/client/src/app/pages/i18n/i18n-page.html

@ -76,9 +76,8 @@
offering. offering.
</li> </li>
<li i18n="@@metaDescription.register"> <li i18n="@@metaDescription.register">
Create your account with a security token or Google and get started with Create your account and get started with Ghostfolio, the open source
Ghostfolio, the open source software to track stocks, ETFs and software to track stocks, ETFs and cryptocurrencies.
cryptocurrencies.
</li> </li>
<li i18n="@@metaDescription.resources"> <li i18n="@@metaDescription.resources">
Explore the Ghostfolio resources on personal finance and investing: Explore the Ghostfolio resources on personal finance and investing:
@ -105,8 +104,8 @@
privacy. privacy.
</li> </li>
<li i18n="@@metaDescription.resources.personalFinanceTools.product"> <li i18n="@@metaDescription.resources.personalFinanceTools.product">
Looking for an open source alternative to $&#123;name&#125;? Compare Compare Ghostfolio vs $&#123;name&#125;: the open source alternative on
Ghostfolio vs $&#123;name&#125; on features, data privacy and pricing. features, data privacy and pricing.
</li> </li>
<li i18n="@@metaKeywords"> <li i18n="@@metaKeywords">
app, asset, cryptocurrency, dashboard, etf, finance, management, app, asset, cryptocurrency, dashboard, etf, finance, management,

Loading…
Cancel
Save