import { Component } from '@angular/core';
import {PagesService} from "@app/_services/pages.service";
import { environment } from '@environments/environment';

@Component({
  selector: 'locale',
  templateUrl: './locale.component.html',
  styleUrls: ['./locale.component.scss']
})
export class LocaleComponent {

  public locales = <any>[];
  public ddMenu:boolean;

  constructor(
    public pagesService: PagesService
  ){}

  ngOnInit() {
    this.pagesService.root().subscribe(res => {
      this.locales = res.data;
    });
  }

  get rootPage() {
    return this.pagesService.rootPage;
  }

  flag(localeName:string){
    if (!localeName) localeName = environment.defaultLocale;
    return 'assets/images/locale/'+(localeName||'ru')+'.svg'
  }

  close() {
    setTimeout(() => {
      this.ddMenu = false;
    }, 10);    
  }

}
