added language routing system

This commit is contained in:
sdarbinyan
2026-02-26 22:23:08 +04:00
parent a4765ffe98
commit e4206d8abc
34 changed files with 197 additions and 98 deletions

View File

@@ -18,7 +18,7 @@
</div>
<h2>Корзина пуста</h2>
<p>Добавьте товары, чтобы начать покупки</p>
<a routerLink="/" class="shop-btn">Перейти к покупкам</a>
<a [routerLink]="'/' | langRoute" class="shop-btn">Перейти к покупкам</a>
</div>
}
@@ -30,13 +30,13 @@
[class.swiped]="swipedItemId() === item.itemID"
(touchstart)="onSwipeStart(item.itemID, $event)">
<div class="cart-item">
<a [routerLink]="['/item', item.itemID]" class="item-image">
<a [routerLink]="['/item', item.itemID] | langRoute" class="item-image">
<img [src]="getMainImage(item)" [alt]="item.name" loading="lazy" />
</a>
<div class="item-info">
<div class="item-header">
<a [routerLink]="['/item', item.itemID]" class="item-name">{{ item.name }}</a>
<a [routerLink]="['/item', item.itemID] | langRoute" class="item-name">{{ item.name }}</a>
<button class="remove-btn" (click)="removeItem(item.itemID)" title="Remove">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 6L6 18M6 6l12 12"/>
@@ -114,10 +114,10 @@
<span class="checkmark"></span>
<span class="terms-text">
Я согласен с
<a routerLink="/public-offer" target="_blank">публичной офертой</a>,
<a routerLink="/return-policy" target="_blank">политикой возврата</a>,
<a routerLink="/guarantee" target="_blank">условиями гарантии</a> и
<a routerLink="/privacy-policy" target="_blank">политикой конфиденциальности</a>
<a [routerLink]="'/public-offer' | langRoute" target="_blank">публичной офертой</a>,
<a [routerLink]="'/return-policy' | langRoute" target="_blank">политикой возврата</a>,
<a [routerLink]="'/guarantee' | langRoute" target="_blank">условиями гарантии</a> и
<a [routerLink]="'/privacy-policy' | langRoute" target="_blank">политикой конфиденциальности</a>
</span>
</label>
</div>

View File

@@ -2,17 +2,18 @@ import { Component, computed, ChangeDetectionStrategy, signal, OnDestroy } from
import { DecimalPipe } from '@angular/common';
import { Router, RouterLink } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { CartService, ApiService } from '../../services';
import { CartService, ApiService, LanguageService } from '../../services';
import { Item, CartItem } from '../../models';
import { interval, Subscription } from 'rxjs';
import { switchMap, take } from 'rxjs/operators';
import { EmptyCartIconComponent } from '../../components/empty-cart-icon/empty-cart-icon.component';
import { environment } from '../../../environments/environment';
import { getDiscountedPrice, getMainImage, trackByItemId } from '../../utils/item.utils';
import { LangRoutePipe } from '../../pipes/lang-route.pipe';
@Component({
selector: 'app-cart',
imports: [DecimalPipe, RouterLink, FormsModule, EmptyCartIconComponent],
imports: [DecimalPipe, RouterLink, FormsModule, EmptyCartIconComponent, LangRoutePipe],
templateUrl: './cart.component.html',
styleUrls: ['./cart.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
@@ -52,7 +53,8 @@ export class CartComponent implements OnDestroy {
constructor(
private cartService: CartService,
private apiService: ApiService,
private router: Router
private router: Router,
private langService: LanguageService
) {
this.items = this.cartService.items;
this.itemCount = this.cartService.itemCount;
@@ -316,7 +318,8 @@ export class CartComponent implements OnDestroy {
// Close popup and redirect to home page
setTimeout(() => {
this.closePaymentPopup();
this.router.navigate(['/']);
const lang = this.langService.currentLanguage();
this.router.navigate([`/${lang}`]);
}, 500);
},
error: (err) => {