Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

388
Visualizações
Change URL when using ngx-translate

I am trying to change the URL when someone clicks on a choosen language using ngx-translate. I guess I should do it by subscribing to language change events and then modifying the current url to reflect the chosen language, Since I am a newbie I am not sure if I need a service to do it, or may be another way to solve it.

I want to change from this:

https://amarello.cloud/es/

To this:

https://amarello.cloud/en/

,depending on the choosen language.

This is my 'header.component.ts'


import { Component, OnInit } from '@angular/core';
//For translate language
import { TranslateService } from '@ngx-translate/core'; 

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {

  menu: boolean = false;
  submenu: boolean = false;
  submin: boolean = false;

  constructor(private translate: TranslateService) 
    { translate.addLangs(['es','en']);
      translate.setDefaultLang('es'); 
    }

  ngOnInit(): void {
  }

  open() {
    if (this.menu == false) {
      this.menu = true;
    } else {
      this.menu = false
    }

    if (this.submin == false) {
      this.submin = true;
    } else {
      this.submin = false
    }
  }

  openSub() {
    if (this.submenu == false) {
      this.submenu = true;
    } else {
      this.submenu = false
    }
  }


  useLanguage(language: string): void {
    this.translate.use(language); 

    // this.translate.onLangChange().subscribe(trans => { 

    // })

  }
  

}
 

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda