Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

387
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda