test: update ivy i18n integration test (#33314)
The integration test now checks that the locale inlining is working. PR Close #33314
This commit is contained in:

committed by
Andrew Kushnir

parent
fb84ea74fe
commit
f76b370d70
@ -7,7 +7,9 @@
|
||||
<p id="message">{{ message }}</p>
|
||||
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
|
||||
</div>
|
||||
<p id="locale">{{ locale }}</p>
|
||||
<p id="pipe">{{ 1 | percent }} awesome</p>
|
||||
<p id="date">{{ jan | date : 'LLLL' }}</p>
|
||||
<h2>Here are some links to help you start: </h2>
|
||||
<ul>
|
||||
<li>
|
||||
|
@ -27,6 +27,6 @@ describe('AppComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
expect(compiled.querySelector('h1').textContent)
|
||||
.toContain('Bonjour cli-hello-world-ivy-compat!');
|
||||
.toContain('Hello cli-hello-world-ivy-compat!');
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,10 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, Inject, LOCALE_ID} from '@angular/core';
|
||||
|
||||
@Component(
|
||||
{selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css']})
|
||||
export class AppComponent {
|
||||
constructor(@Inject(LOCALE_ID) public locale: string) {}
|
||||
title = `cli-hello-world-ivy-compat`;
|
||||
message = $localize `Welcome to the i18n app.`;
|
||||
jan = new Date(2000, 0, 1);
|
||||
}
|
||||
|
@ -1,17 +1,13 @@
|
||||
import {registerLocaleData} from '@angular/common';
|
||||
import {LOCALE_ID, NgModule} from '@angular/core';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import localeFr from '@angular/common/locales/fr';
|
||||
import {AppComponent} from './app.component';
|
||||
|
||||
// adding this code to detect issues like https://github.com/angular/angular-cli/issues/10322
|
||||
// it should not affect the CLI importing additional locale data for compile time inlined bundles.
|
||||
registerLocaleData(localeFr);
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent],
|
||||
imports: [BrowserModule],
|
||||
providers: [{provide: LOCALE_ID, useValue: 'fr'}],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
@NgModule({declarations: [AppComponent], imports: [BrowserModule], bootstrap: [AppComponent]})
|
||||
export class AppModule {
|
||||
}
|
||||
|
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* This file includes polyfills needed by Angular and is loaded before the app.
|
||||
* You can add your own extra polyfills to this file.
|
||||
*
|
||||
* This file is divided into 2 sections:
|
||||
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
||||
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
||||
* file.
|
||||
*
|
||||
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
||||
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
||||
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
||||
*
|
||||
* Learn more in https://angular.io/guide/browser-support
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
* BROWSER POLYFILLS
|
||||
*/
|
||||
|
||||
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
|
||||
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
||||
|
||||
/**
|
||||
* Web Animations `@angular/platform-browser/animations`
|
||||
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||
*/
|
||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||
|
||||
/**
|
||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||
* because those flags need to be set before `zone.js` being loaded, and webpack
|
||||
* will put import in the top of bundle, so user need to create a separate file
|
||||
* in this directory (for example: zone-flags.ts), and put the following flags
|
||||
* into that file, and then add the following code before importing zone.js.
|
||||
* import './zone-flags.ts';
|
||||
*
|
||||
* The flags allowed in zone-flags.ts are listed here.
|
||||
*
|
||||
* The following flags will work for all browsers.
|
||||
*
|
||||
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch
|
||||
* requestAnimationFrame
|
||||
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch
|
||||
* specified eventNames
|
||||
*
|
||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||
*
|
||||
* (window as any).__Zone_enable_cross_context_check = true;
|
||||
*
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
* Zone JS is required by default for Angular itself.
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
|
||||
/***************************************************************************************************
|
||||
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
|
||||
*/
|
||||
import '@angular/localize/init';
|
||||
|
||||
// Note that `computeMsgId` is a private API at this stage. It will probably be exported directly
|
||||
// from `@angular/localize` at some point.
|
||||
import {computeMsgId} from '@angular/compiler';
|
||||
import {loadTranslations} from '@angular/localize';
|
||||
|
||||
// Load some runtime translations!
|
||||
loadTranslations({
|
||||
[computeMsgId(' Hello {$INTERPOLATION}! ')]: 'Bonjour {$INTERPOLATION}!',
|
||||
[computeMsgId('Welcome to the i18n app.')]: 'Bienvenue sur l\'application i18n.',
|
||||
});
|
||||
|
||||
// Set up the locale for the runtime inlining (EXPERIMENTAL)
|
||||
$localize.locale = 'fr';
|
||||
import {registerLocaleData} from '@angular/common';
|
||||
import localeFr from '@angular/common/locales/fr';
|
||||
registerLocaleData(localeFr);
|
||||
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
*/
|
@ -62,16 +62,6 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
*/
|
||||
import '@angular/localize/init';
|
||||
|
||||
// Note that `computeMsgId` is a private API at this stage. It will probably be exported directly
|
||||
// from `@angular/localize` at some point.
|
||||
import {computeMsgId} from '@angular/compiler';
|
||||
import {loadTranslations} from '@angular/localize';
|
||||
|
||||
// Load some runtime translations!
|
||||
loadTranslations({
|
||||
[computeMsgId(' Hello {$INTERPOLATION}! ')]: 'Bonjour {$INTERPOLATION}!',
|
||||
[computeMsgId('Welcome to the i18n app.')]: 'Bienvenue sur l\'application i18n.',
|
||||
});
|
||||
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
|
Reference in New Issue
Block a user