fix: og:locale hardcoded ru_RU regardless of active locale

Both setItemMeta() and resetToDefaults() hardcoded 'ru_RU'. Added a
LanguageService-driven mapping (ru/en/hy -> ru_RU/en_US/hy_AM).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sdarbinyan
2026-08-13 09:02:18 +04:00
parent 461cd8421c
commit 9f784406d7

View File

@@ -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<string, string> = {
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 <title>/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 },