1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to configure html's lang attribute depending on the URL using angular SSR

Discussão em 'Angular' iniciado por Mattew Eon, Julho 21, 2025.

  1. Mattew Eon

    Mattew Eon Guest

    I'm trying to migrate my Angular App to an Angular SSR for better SEO. I need to provide the html's lang attribute depending on the route :

    • If the route starts with /fr, set it to fr
    • If the route starts with /en, set it to en

    I think I have to use this in my AppComponent :

    public readonly document = inject(DOCUMENT);

    constructor() {
    this.document.documentElement.lang = myLanguage;
    }


    But I have no idea how to retrieve the route to know which language I should set.

    Continue reading...

Compartilhe esta Página