feat(portal-shell): wire @angular/localize plumbing per ADR-0019
Lay down the i18n infrastructure ahead of the string sweep that marks every UI label. No template or code changes yet — that comes next. What this commit does: - Add `@angular/localize` as a direct dependency (it was a transitive via the Angular metapackage; promoting it makes the `init` polyfill resolvable). - Configure the i18n block in `apps/portal-shell/project.json`: source locale `en` (matches the project English-only rule, with `baseHref: /en/`), one target locale `fr` (with `baseHref: /fr/` and `translation` pointing at the seed XLF). - Add `@angular/localize/init` to the `polyfills` array so the runtime resolver is available before the app bootstraps. - Add an `extract-i18n` Nx target that wraps Angular's `@angular/build:extract-i18n` executor, dropping the source XLF next to the translation files (`apps/portal-shell/src/locale/`). - Enable `--localize` on the production build configuration. The build now emits two folders — `dist/apps/portal-shell/browser/en/` and `.../fr/` — each with the right `<html lang>` and `<base href>`. - Seed an empty `messages.fr.xlf` (XLIFF 1.2 skeleton) so the build is happy and the sweep PR can drop trans-units into it directly. What is intentionally out of scope: - String marking (the sweep PR — every existing UI label, then populate `messages.fr.xlf` with translations). - Locale switcher in the footer + `__Host-portal_locale` cookie + the smart `/` redirect (lands once strings are translated and the user can meaningfully switch). - Collapsing `/accessibility` + `/accessibilite` into a single localised route (lands with the sweep, since it requires marked text + localized route paths). - CI gate that fails the build on missing translations (lands when there are translations to be missing).
This commit is contained in:
@@ -5,6 +5,18 @@
|
||||
"prefix": "app",
|
||||
"sourceRoot": "apps/portal-shell/src",
|
||||
"tags": ["scope:portal-shell", "type:app"],
|
||||
"i18n": {
|
||||
"sourceLocale": {
|
||||
"code": "en",
|
||||
"baseHref": "/en/"
|
||||
},
|
||||
"locales": {
|
||||
"fr": {
|
||||
"translation": "apps/portal-shell/src/locale/messages.fr.xlf",
|
||||
"baseHref": "/fr/"
|
||||
}
|
||||
}
|
||||
},
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@angular/build:application",
|
||||
@@ -12,6 +24,7 @@
|
||||
"options": {
|
||||
"outputPath": "dist/apps/portal-shell",
|
||||
"browser": "apps/portal-shell/src/main.ts",
|
||||
"polyfills": ["@angular/localize/init"],
|
||||
"tsConfig": "apps/portal-shell/tsconfig.app.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
@@ -24,6 +37,7 @@
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"localize": ["en", "fr"],
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
@@ -57,6 +71,14 @@
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular/build:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "portal-shell:build",
|
||||
"outputPath": "apps/portal-shell/src/locale",
|
||||
"outFile": "messages.xlf"
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"continuous": true,
|
||||
"executor": "@angular/build:dev-server",
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<file source-language="en" target-language="fr" datatype="plaintext" original="ng2.template">
|
||||
<body>
|
||||
<!--
|
||||
French translation file for portal-shell.
|
||||
|
||||
Empty in this initial plumbing PR per ADR-0019. The first string
|
||||
sweep PR will mark every UI string in the templates with
|
||||
`i18n="@@<id>"` and add a `<trans-unit id="<id>">` entry below
|
||||
with the French translation. Until then, the production build's
|
||||
`--localize` emits both `dist/apps/portal-shell/browser/en/...`
|
||||
and `dist/apps/portal-shell/browser/fr/...`, but the FR bundle
|
||||
falls back to source text for every untranslated key.
|
||||
|
||||
Editor convention: keep the entries grouped by feature
|
||||
(header.*, sidebar.*, footer.*, page.<route>.*) and ordered
|
||||
alphabetically within each group, so diffs stay readable.
|
||||
-->
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
Reference in New Issue
Block a user