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

282
Vistas
Prevent Angular from updating base href with langcode

I have problem with angular v9. I have implemented i18n localization features into my app. When I try to build my application with certain location it constantly adds the sub-folder to the base href path (but I want to keep files in the sub-folder). Is there any way to prevent adding the locale into the base href url?

Reproduction steps:

  1. Generate dummy project ng new Project.
  2. Build production config ng build --prod --localize.
  3. Files are built into dist/en-us/ folder, but the index.html has <base href="/en-US/">.

Is there any way to force angular to stop adding the langcode into base href? This inflicts all the app links to contain language code, which is unwanted.

My deployment is configured to deploy the application based on the directory into different location which every will be at root.

  • hxxp://app.fr/ root in /fr/ folder
  • hxxp://app.de/ root in /de/ folder
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

I had the same problem and found the solution in this issue:

https://github.com/angular/angular-cli/issues/17260

You have to write for each locales and for your sourceLocale the baseHref

"i18n": {
    "sourceLocale": {
        "code": "en",
        "baseHref": ""
    },
    "locales": {
        "fr": {
            "baseHref": "",
            "translation": "src/locale/messages.fr.xlf"
        }
    }
}
over 4 years ago · Santiago Trujillo Denunciar

0

Posting with my solution, but that kills the new feature of Angular v.9.

The solution is to not use --localize flag.

So I removed definition:

"i18n": {
    "sourceLocale": "de",
    "locales": {
      "fr": "src/app/locale/messages.fr.xlf",
}

Then I created custom configuration under:

  "configurations": {
    "fr": {
      "i18nFile": "src/app/locale/messages.fr.xlf",
      "i18nLocale": "fr",
      "outputPath": "dist/fr"
    }

And just called:

ng build --configuration=fr

But that is ugly.. so waiting for some better ideas :)

over 4 years ago · Santiago Trujillo Denunciar

0

You can override baseHref with this:

"locales": {
  "de": {
    "translation": "src/locale/messages.de.xlf",
    "baseHref": "/"
  },
....
}
over 4 years ago · Santiago Trujillo Denunciar
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