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

270
Visualizações
Angular 4 i18n - how to go on after adding the translation-files?

I need to translate my Angular 4 app. Basically I followed the official guide.

  1. I added i18n attributes to tags and so on

  2. The angular-cli created a messages.xlf

  3. I created a folder "locale" in the src-folder

  4. I copied the messages.xlf to this locale-folder...

  5. ... and renamed it to "messages.de.xlf" to hold the German translations

I changed a simple translation to test things out. However, after I switched my browser to "German", there wasn't any difference (used npm start, so basically 'ng serve'). Seems to be that there still is something missing. Also the guide explains how to 'merge' the translation. But this chapter is incredibly odd and doesn't sound quite convincing. It reads like it was done for an earlier version.

For example it states to adapt my startup-script. The thing is that I don't even have a startup-script. My index.html looks like this:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>PickUp2</title>
  <base href="/">

  <link href="assets/iconfont/material-icons.css" rel="stylesheet">
  <link href="roboto.css" rel="stylesheet">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="assets/material_supply_icon.ico">
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

Where do I need to place this startup-script? I don't even know whether I use the JIT or AOT compiler. They were never mentioned in any guide before.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I have translated our Angular-4 app with the method described in the Cookbook. I think the key info that you are missing is that you need to "build" the app for each language separately.

My command to run the app locally with one translation looks like this:

>ng serve --i18n-file src/i18n/messages.fr.xlf --locale fr --i18n-format xlf --aot

to build it just replace ng serve with ng build

Explained:

  • -i18n-file specified which translation to use
  • --aot is the ahead of time compilation of the html templates, this will replace the texts marked i18n with your translations

so in your case you would build the app in german and then deploy it - let's say - to a /de folder. another version of the app could be in /en etc.

then you can redirect your users based on the language they want to have to the dedicated app.

hope this helps

about 4 years ago · Santiago Trujillo Relatório
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