Skip to content

aitorjs/angular-build-in-i18n

Repository files navigation

Transladable string, translated to Spanish, English (base) and Basque. Working with AOT. Creates one app per language.

Steeps

  • ng build --aot

  • Anadir un string como traducible:

    Hello world!

  • Crear la pantilla general con todas las traduciones: ng xi18n --output-path src/i18n o npm run get-i18n

  • cp src/i18n/messages.xlf src/i18n/messages.es.xlf, suponiendo que queremos traducir la app a castellano.

  • Modificar la traducción en messages.es.xlf (la linea que tiene la etiqueta )

    <trans-unit id="[...]" datatype="html">
      <source>Hello World!</source>
      <target>Hola mundo!</target>
    </trans-unit>
    

Posibilidad 1:

  • Servir la aplicación en castellano: ng serve --aot --i18n-file=src/i18n/messages.es.xlf --locale=es --i18n-format=xlf (Eventualmente, npm run serve-en, npm run serve-es, npm run serve-eu atajos para servir la app en ingles, castellano o euskara )
  • Abrir http://localhost:4200

Posibilidad 2:

  • Añadir esta linea como script al pacakge.json paara build-ear la app:
"build-i18n": "for lang in en es fr; do ng build --output-path=dist/$lang --aot -prod --bh /$lang/ --i18n-file=src/i18n/messages.$lang.xlf --i18n-format=xlf --locale=$lang; done"

https://medium.com/@feloy/deploying-an-i18n-angular-app-with-angular-cli-fc788f17e358

Software for translation

For now, we are using Virtaal (http://virtaal.translatehouse.org/) that is multiplatform so whats on GNU/Linux (use apt), Windows and MacOs

Using File-> Update template can update language translation with last updates from base template keeping the translated strings.

I18n

This project was generated with Angular CLI version 1.1.3.

About

Playing with build-in internationalization (i18n) options

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published