diff --git a/src/app/services/seo.service.ts b/src/app/services/seo.service.ts index 5ce933f..41456e7 100644 --- a/src/app/services/seo.service.ts +++ b/src/app/services/seo.service.ts @@ -4,6 +4,13 @@ import { Item } from '../models'; import { getDiscountedPrice, getMainImage } from '../utils/item.utils'; import { UiRuntimeFacade } from '../facades/runtime/ui-runtime.facade'; import { ConfigService } from '../core/config/config.service'; +import { LanguageService } from './language.service'; + +const OG_LOCALE_MAP: Record = { + ru: 'ru_RU', + en: 'en_US', + hy: 'hy_AM', +}; @Injectable({ providedIn: 'root' @@ -14,6 +21,7 @@ export class SeoService { private doc = inject(DOCUMENT); private readonly uiRuntime = inject(UiRuntimeFacade); private readonly configService = inject(ConfigService); + private readonly languageService = inject(LanguageService); constructor() { // Keep the runtime /OG/Twitter/canonical/robots tags in sync with @@ -38,6 +46,10 @@ export class SeoService { return this.uiRuntime.marketplaceDisplayName() || 'Marketplace'; } + private get ogLocale(): string { + return OG_LOCALE_MAP[this.languageService.currentLanguage()] ?? 'en_US'; + } + /** * Set Open Graph & Twitter Card meta tags for a product/item page. */ @@ -59,7 +71,7 @@ export class SeoService { { property: 'og:image', content: imageUrl }, { property: 'og:url', content: itemUrl }, { property: 'og:site_name', content: this.siteName }, - { property: 'og:locale', content: 'ru_RU' }, + { property: 'og:locale', content: this.ogLocale }, // Product-specific OG tags { property: 'product:price:amount', content: price.toFixed(2) }, @@ -111,7 +123,7 @@ export class SeoService { { property: 'og:image', content: defaultImage }, { property: 'og:url', content: this.siteUrl }, { property: 'og:site_name', content: this.siteName }, - { property: 'og:locale', content: 'ru_RU' }, + { property: 'og:locale', content: this.ogLocale }, { name: 'twitter:card', content: 'summary_large_image' }, { name: 'twitter:title', content: defaultTitle },