Compare commits
5 Commits
90582949d5
...
1237ee4439
| Author | SHA1 | Date | |
|---|---|---|---|
| 1237ee4439 | |||
| 935d1f5dd9 | |||
| 2a31e85e50 | |||
| c4665737dc | |||
| e3dac5bc83 |
@@ -1,17 +1,15 @@
|
||||
import { APP_INITIALIZER, ApplicationConfig } from "@angular/core";
|
||||
import { provideRouter } from "@angular/router";
|
||||
|
||||
import { provideHttpClient } from "@angular/common/http";
|
||||
import { routes } from "./app.routes";
|
||||
import { TranslateService } from "./services/translate.service";
|
||||
|
||||
export function setupTranslateServiceFactory(service: TranslateService) {
|
||||
return () => service.use("en");
|
||||
const lang = localStorage.getItem("lang") ?? "en";
|
||||
return () => service.use(lang);
|
||||
}
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideRouter(routes),
|
||||
provideHttpClient(),
|
||||
TranslateService,
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ a {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 0;
|
||||
transition: 0.3s ease-in-out;
|
||||
transition: 0.5s ease-in-out;
|
||||
span {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
@@ -21,7 +21,7 @@ a {
|
||||
font-size: 0.8rem;
|
||||
height: 0;
|
||||
font-weight: 600;
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
transition: all 0.6s ease-in-out;
|
||||
}
|
||||
&:hover {
|
||||
transform: translateY(-1rem);
|
||||
|
||||
@@ -57,6 +57,8 @@
|
||||
align-items: center;
|
||||
span {
|
||||
font-weight: 600;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
fa-icon {
|
||||
font-size: 1.2rem;
|
||||
|
||||
@@ -53,6 +53,18 @@ export class PanelComponent {
|
||||
this.langModal.nativeElement.style.left = `calc(${x}px - 3.5rem)`;
|
||||
}
|
||||
|
||||
@HostListener("window:click", ["$event"])
|
||||
private closeLangModal(event: MouseEvent) {
|
||||
if (
|
||||
this.langModal &&
|
||||
this.langBtn &&
|
||||
!this.langModal.nativeElement.contains(event.target as Node) &&
|
||||
!this.langBtn.nativeElement.contains(event.target as Node)
|
||||
) {
|
||||
this.langModal.nativeElement.classList.remove("active");
|
||||
}
|
||||
}
|
||||
|
||||
toggleModal() {
|
||||
if (this.langModal) {
|
||||
this.langModal.nativeElement.classList.toggle("active");
|
||||
@@ -63,6 +75,7 @@ export class PanelComponent {
|
||||
}
|
||||
|
||||
useLang(lang: string) {
|
||||
this.langModal && this.langModal.nativeElement.classList.remove("active");
|
||||
this.translateService.use(lang);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import { Injectable } from "@angular/core";
|
||||
export class TranslateService {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
data: Record<string, any> = {};
|
||||
lang = "en";
|
||||
lang: string | null = null;
|
||||
constructor(private http: HttpClient) {}
|
||||
use(lang: string): Promise<object> {
|
||||
this.lang = lang ?? "en";
|
||||
localStorage.setItem("lang", this.lang);
|
||||
return new Promise<object>((resolve) => {
|
||||
const langPath = `assets/i18n/${lang ?? "en"}.json`;
|
||||
const langPath = `assets/i18n/${this.lang}.json`;
|
||||
this.http.get(langPath).subscribe({
|
||||
next: (response) => {
|
||||
this.data = response ?? {};
|
||||
|
||||
@@ -47,7 +47,8 @@ ngneat-dialog {
|
||||
}
|
||||
.btns {
|
||||
fa-icon {
|
||||
cursor: pointer;
|
||||
z-index: 999;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
.ngneat-drag-marker {
|
||||
|
||||
Reference in New Issue
Block a user