-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
localization : adding localization in progress
- Loading branch information
Showing
17 changed files
with
260 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
<app-loader></app-loader> | ||
<app-navbar></app-navbar> | ||
<router-outlet></router-outlet> | ||
|
||
|
||
<button mat-button *ngIf="translate.currentLang=== 'en'" (click)="switchLanguage('ar')" >{{"Arabic" | translate}}</button> | ||
<button mat-button *ngIf="translate.currentLang=== 'ar'" (click)="switchLanguage('en')" >{{"English" | translate}}</button> | ||
{{ 'HELLO' | translate }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 13 additions & 24 deletions
37
src/app/components/product-view/product-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
src/app/components/products-sidebar/products-sidebar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
<h4>Filter products</h4> | ||
<h4>{{ 'Filter products' | translate }}</h4> | ||
<mat-divider></mat-divider> | ||
|
||
<div class="d-flex flex-column"> | ||
<mat-checkbox [(ngModel)]="isAllCategoriesChecked" (change)="handleAllCheck()" > | ||
All categories | ||
<mat-checkbox [(ngModel)]="isAllCategoriesChecked" (change)="handleAllCheck()"> | ||
{{ 'All categories' | translate }} | ||
</mat-checkbox> | ||
<mat-checkbox *ngFor="let category of checkBoxcategories" (change)="handleCheck()" [(ngModel)]="category.checked"> | ||
{{ category.name }} | ||
{{ category.name | translate }} | ||
</mat-checkbox> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
<mat-toolbar color="primary" class="d-fle justify-content-between"> | ||
<span>Angular Store</span> | ||
<span>{{ "Angular store" | translate}}</span> | ||
|
||
<div> | ||
<span class="spacer"></span> | ||
<button mat-button *ngIf="translate.currentLang=== 'en'" (click)="switchLanguage('ar')" >{{"ENGLISH" | translate}}</button> | ||
<button mat-button *ngIf="translate.currentLang=== 'ar'" (click)="switchLanguage('en')" >{{"ARABIC" | translate}}</button> | ||
<button mat-button *ngIf="translate.currentLang === 'ar'" (click)="localizService.switchLanguage('en')">Switch to | ||
EN</button> | ||
<button mat-button *ngIf="translate.currentLang === 'en'" (click)="localizService.switchLanguage('ar')">التحويل | ||
للعربي </button> | ||
|
||
<ng-template *ngIf="!(auth.isAuth$ | async)" #loginTemplate> | ||
<a mat-button routerLink="/auth">Login</a> | ||
</ng-template> | ||
|
||
<span class="mx-2" *ngIf="auth.isAuth$ | async"> |</span> | ||
|
||
<ng-container *ngIf="auth.isAuth$ | async"> | ||
<a mat-button (click)="logout()">{{"Logout" | translate}}</a> | ||
</ng-container> | ||
</div> | ||
</mat-toolbar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Injectable, Renderer2, RendererFactory2 } from '@angular/core'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class LocalizationService { | ||
private renderer!: Renderer2; | ||
|
||
constructor( | ||
public translate: TranslateService, | ||
rendererFactory: RendererFactory2 | ||
) { | ||
this.renderer = rendererFactory.createRenderer(null, null); | ||
} | ||
setDefaultLanguage(language: string = 'en') { | ||
this.translate.setDefaultLang(language); | ||
this.translate.use(language); | ||
localStorage.setItem('language', language); | ||
} | ||
|
||
changeDirectionToRtl() { | ||
this.renderer.setAttribute(document.documentElement, 'dir', 'rtl'); | ||
} | ||
|
||
changeDirectionToLtr() { | ||
this.renderer.setAttribute(document.documentElement, 'dir', 'ltr'); | ||
} | ||
|
||
switchLanguage(language: string) { | ||
language === 'ar' ? this.changeDirectionToRtl() : this.changeDirectionToLtr(); | ||
|
||
this.translate.use(language); | ||
localStorage.setItem('language', language); | ||
} | ||
|
||
getLang(): 'en' | 'ar' { | ||
return this.translate.currentLang as 'en' | 'ar' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.