fix: i18n gaps in popular searches and compare table
Some checks failed
Architecture Governance / architecture (push) Has been cancelled

- SearchFacade.popularSearches hardcoded English titles regardless of
  active locale. Converted to a getter using translate.t() for the
  displayed title/text; the underlying search query stays the stable
  English canonical term the backend index matches against.
- Compare table and compare page rendered product.name raw instead of
  through getTranslatedField(), same pattern used everywhere else
  product titles are shown (catalog, product detail).
- SearchTrendingService.loadTrending() is a genuine backend gap (no
  trending-search endpoint exists) - already degrades gracefully,
  documented as a gap in BACKEND-API-REFERENCE.md \u00a712.6 rather than
  faked client-side.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sdarbinyan
2026-08-13 10:04:29 +04:00
parent 6cc5d43a10
commit 178b5f0dc7
10 changed files with 83 additions and 36 deletions

View File

@@ -6,7 +6,7 @@
<th scope="col">{{ 'ux.compareAttribute' | translate }}</th>
@for (product of products; track product.itemID) {
<th scope="col">
<div class="compare-product-title">{{ product.name }}</div>
<div class="compare-product-title">{{ productTitle(product) }}</div>
</th>
}
</tr>

View File

@@ -2,6 +2,8 @@ import { ChangeDetectionStrategy, Component, Input, computed, inject } from '@an
import { Product } from '../../../../../core/products/models/product-domain.model';
import { TranslateService } from '../../../../../i18n/translate.service';
import { TranslatePipe } from '../../../../../i18n/translate.pipe';
import { LanguageService } from '../../../../../services/language.service';
import { getTranslatedField } from '../../../../../utils/item.utils';
interface CompareRow {
key: string;
@@ -27,6 +29,7 @@ const STOCK_LABEL_KEYS: Record<string, string> = {
})
export class CompareTableComponent {
private readonly i18n = inject(TranslateService);
private readonly languageService = inject(LanguageService);
@Input() products: Product[] = [];
@Input() hideIdentical = false;
@@ -61,6 +64,10 @@ export class CompareTableComponent {
return this.hideIdentical ? baseRows.filter(row => !row.identical) : baseRows;
});
productTitle(product: Product): string {
return getTranslatedField(product, 'name', this.languageService.currentLanguage());
}
isDifferentRow(row: CompareRow): boolean {
return this.highlightDifferences && !row.identical;
}

View File

@@ -26,7 +26,7 @@
<section class="compare-products-list">
@for (product of products(); track product.itemID) {
<article class="compare-product-chip">
<a [routerLink]="['/product', product.itemID] | langRoute">{{ product.name }}</a>
<a [routerLink]="['/product', product.itemID] | langRoute">{{ productTitle(product) }}</a>
<button type="button" [attr.aria-label]="'ux.removeFromCompare' | translate" (click)="remove(product.itemID)">×</button>
</article>
}

View File

@@ -5,6 +5,8 @@ import { Product } from '../../../../../core/products/models/product-domain.mode
import { UserExperienceFacade } from '../../../../../facades/platform/user-experience.facade';
import { TranslatePipe } from '../../../../../i18n/translate.pipe';
import { LangRoutePipe } from '../../../../../pipes/lang-route.pipe';
import { LanguageService } from '../../../../../services/language.service';
import { getTranslatedField } from '../../../../../utils/item.utils';
import { DEFAULT_USER_EXPERIENCE_CONFIG } from '../../../../../shared/models/config';
import { CompareTableComponent } from '../components/compare-table.component';
import { EmptyStateComponent } from '../../../../../shared/ui/empty-state/empty-state.component';
@@ -21,6 +23,7 @@ import { ButtonComponent } from '../../../../../shared/ui/button/button.componen
export class ComparePageComponent {
private readonly uxFacade = inject(UserExperienceFacade);
private readonly configService = inject(ConfigService);
private readonly languageService = inject(LanguageService);
private readonly compareConfig = this.resolveCompareConfig();
@@ -39,6 +42,10 @@ export class ComparePageComponent {
this.uxFacade.clearCompare();
}
productTitle(product: Product): string {
return getTranslatedField(product, 'name', this.languageService.currentLanguage());
}
private resolveCompareConfig() {
const raw = (this.configService.getBootstrapSnapshot() as any)?.userExperience?.compare ?? {};
return {