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

Angular: How to get the current locale at runtime when using AOT

Discussão em 'Angular' iniciado por williamsandonz, Setembro 26, 2024.

  1. I am compiling my project with:

    ng serve --aot --i18nFile=client/locale/messages.fr.xlf --i18nFormat=xlf --locale=fr


    How can I access the locale ID at runtime? I want to show/hide elements based on the locale.

    PS. I do realise that using JIT compilation I can simply do this:

    providers: [ { provide: LOCALE_ID, useValue: 'fr' } ]


    But I'm looking for a AOT solution. I also would rather not infer locale based on hostname or anything like that.

    Continue reading...

Compartilhe esta Página