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

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

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

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

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

Loading…
Cancel
Save