test(ivy): add i18n integration tests via TestBed (#27852)
PR Close #27852
This commit is contained in:
committed by
Kara Erickson
parent
ac5f5ed0a6
commit
4613864fc8
@@ -389,7 +389,7 @@ describe('i18n support in the view compiler', () => {
|
||||
it('should correctly bind to context in nested template', () => {
|
||||
const input = `
|
||||
<div *ngFor="let outer of items">
|
||||
<div i18n-title="m|d" title="different scope {{ outer | uppercase }}">
|
||||
<div i18n-title="m|d" title="different scope {{ outer | uppercase }}"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -518,7 +518,7 @@ describe('i18n support in the view compiler', () => {
|
||||
it('should correctly bind to context in nested template', () => {
|
||||
const input = `
|
||||
<div *ngFor="let outer of items">
|
||||
<div i18n-title="m|d" title="different scope {{ outer | uppercase }}">
|
||||
<div i18n-title="m|d" title="different scope {{ outer | uppercase }}"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -1347,7 +1347,7 @@ describe('i18n support in the view compiler', () => {
|
||||
verify(input, output);
|
||||
});
|
||||
|
||||
it('should be able to be child elements inside i18n block', () => {
|
||||
it('should be able to act as child elements inside i18n block', () => {
|
||||
const input = `
|
||||
<div i18n>
|
||||
<ng-template>Template content: {{ valueA | uppercase }}</ng-template>
|
||||
|
||||
@@ -504,7 +504,7 @@ function appendI18nNode(tNode: TNode, parentTNode: TNode, previousTNode: TNode |
|
||||
* @publicAPI
|
||||
*/
|
||||
export function i18nPostprocess(
|
||||
message: string, replacements: {[key: string]: (string | string[])}): string {
|
||||
message: string, replacements: {[key: string]: (string | string[])} = {}): string {
|
||||
//
|
||||
// Step 1: resolve all multi-value cases (like [�*1:1��#2:1�|�#4:1�|�5�])
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,13 +16,12 @@
|
||||
export function polyfillGoogGetMsg(translations: {[key: string]: string} = {}): void {
|
||||
const glob = (global as any);
|
||||
glob.goog = glob.goog || {};
|
||||
glob.goog.getMsg =
|
||||
glob.goog.getMsg || function(input: string, placeholders: {[key: string]: string} = {}) {
|
||||
if (typeof translations[input] !== 'undefined') { // to account for empty string
|
||||
input = translations[input];
|
||||
}
|
||||
return Object.keys(placeholders).length ?
|
||||
input.replace(/\{\$(.*?)\}/g, (match, key) => placeholders[key] || '') :
|
||||
input;
|
||||
};
|
||||
}
|
||||
glob.goog.getMsg = function(input: string, placeholders: {[key: string]: string} = {}) {
|
||||
if (typeof translations[input] !== 'undefined') { // to account for empty string
|
||||
input = translations[input];
|
||||
}
|
||||
return Object.keys(placeholders).length ?
|
||||
input.replace(/\{\$(.*?)\}/g, (match, key) => placeholders[key] || '') :
|
||||
input;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user