MCPcopy Index your code
hub / github.com/angular/angular-cli / setupI18nConfig

Function setupI18nConfig

tests/e2e/tests/i18n/setup.ts:128–275  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126};
127
128export async function setupI18nConfig() {
129 // Add component with i18n content, both translations and localeData (plural, dates).
130 await writeFile(
131 'src/app/app.ts',
132 `
133 import { Component, Inject, LOCALE_ID } from '@angular/core';
134 import { DatePipe } from '@angular/common';
135 import { RouterOutlet } from '@angular/router';
136
137 @Component({
138 selector: 'app-root',
139 imports: [DatePipe, RouterOutlet],
140 templateUrl: './app.html'
141 })
142 export class App {
143 constructor(@Inject(LOCALE_ID) public locale: string) { }
144 title = 'i18n';
145 jan = new Date(2000, 0, 1);
146 minutes = 3;
147 }
148 `,
149 );
150 await writeFile(
151 `src/app/app.html`,
152 `
153 <p id="hello" i18n="An introduction header for this sample">Hello {{ title }}! </p>
154 <p id="locale">{{ locale }}</p>
155 <p id="date">{{ jan | date : 'LLLL' }}</p>
156 <p id="plural" i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</p>
157 <router-outlet></router-outlet>
158 `,
159 );
160
161 await createDir(dirname(translationFile));
162 await writeFile(
163 translationFile,
164 `
165 <?xml version="1.0" encoding="UTF-8" ?>
166 <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
167 <file source-language="en-US" datatype="plaintext" original="ng2.template">
168 <body>
169 <trans-unit id="4286451273117902052" datatype="html">
170 <source>Hello <x id="INTERPOLATION" equiv-text="{{ title }}"/>! </source>
171 <context-group purpose="location">
172 <context context-type="sourcefile">src/app/app.html</context>
173 <context context-type="linenumber">2,3</context>
174 </context-group>
175 <note priority="1" from="description">An introduction header for this sample</note>
176 </trans-unit>
177 <trans-unit id="4606963464835766483" datatype="html">
178 <source>Updated <x id="ICU" equiv-text="{minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}" xid="1887283401472369100"/></source>
179 <context-group purpose="location">
180 <context context-type="sourcefile">src/app/app.html</context>
181 <context context-type="linenumber">5,6</context>
182 </context-group>
183 </trans-unit>
184 <trans-unit id="2002272803511843863" datatype="html">
185 <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION"/> minutes ago}}</source>

Calls 10

writeFileFunction · 0.90
createDirFunction · 0.90
appendToFileFunction · 0.90
updateJsonFileFunction · 0.90
getGlobalVariableFunction · 0.90
readNgVersionFunction · 0.90
installPackageFunction · 0.90
copyFileFunction · 0.90
replaceInFileFunction · 0.90
dirnameFunction · 0.50

Tested by

no test coverage detected