Angular-cli: xi18n should parse index.html and build should fill in the translated texts in index.html

Created on 20 Dec 2017  路  8Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 1.6.0
Node: 8.9.1
OS: darwin x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router
... service-worker

@angular/cdk: 5.0.0
@angular/cli: 1.6.0
@angular/material: 5.0.0
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0

Repro steps

  • in index.html, use the i18n marker like

    please wait...

  • run ng xi18n
  • the 'please wait' does not popup in the gererated .xlf files
  • run ng build ng build -prod --aot --output-path=dist/de --base-href /de/ --i18n-file=src/i18n/messages.de.xlf --i18n-format=xlf --locale=de;

Observed behavior

<!-- Normally this includes a stack trace and some more information. -->

Desired behavior

devkibuild-angular i18n feature

Most helpful comment

if parsing the index.html would be possible, we could also set the right language attribute in the HTML-tag.

All 8 comments

ng xi18n operates over components of your Angular application, but index.html is not part of it actually. It's not a component template.

I don't think this is functionality we can provide but @ocombe might know more.

wel, the entry and name index.html are in the .angular-cli.json. Also, the cli can inject the base href using the --base-href switch

it will be possible as part of universal (it's on the roadmap)

If I can't use server-side rendering, is there a plan to inject translated string in index.html or other static file ?

if parsing the index.html would be possible, we could also set the right language attribute in the HTML-tag.

What's the status on this? I'm trying to set up locale-specific index.html to change some tags specific to the locale, like the title, the HTML lang attribute, canonical link, and others, but can't rely on the i18n translation.

Was trying to make multiple index.html files, 1 per locale, but when I run with --localize flag it ignores the angular.json config about which index.html to use.

Looks like this, building with --configuration=es-CO works, but using --localize to build all locales at once doesn't work:
image

I filed a bug for this: #17684

17684 was closed because including the index.html in the localization process would be a better solution than providing a way to compile multiple configurations at once, or providing the i18n a way to configure the index.html to use for each locale.

For now, working around it by creating a configuration for each locale and building all of them through gulp script in series.

Has there been any updates regarding this issue? It would be a great improvement being able to translate the index.html

Was this page helpful?
0 / 5 - 0 ratings