Skip to content

Commit 4737301

Browse files
committed
refactor(@angular/cli): rename ng xi18n to ng extract-i18n
`ng i18n-extract` and `ng xi18n` has been deprecated in favor of `ng extract-i18n` to have a better intuitive naming and match the architect key in `angular.json`.
1 parent 14239cd commit 4737301

16 files changed

+31
-26
lines changed

packages/angular/cli/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ts_library(
4646
"//packages/angular/cli:commands/update.ts",
4747
"//packages/angular/cli:commands/version.ts",
4848
"//packages/angular/cli:commands/run.ts",
49-
"//packages/angular/cli:commands/xi18n.ts",
49+
"//packages/angular/cli:commands/extract-i18n.ts",
5050
# @external_end
5151
],
5252
data = glob(
@@ -223,8 +223,8 @@ ts_json_schema(
223223
)
224224

225225
ts_json_schema(
226-
name = "xi18n_schema",
227-
src = "commands/xi18n.json",
226+
name = "extract-i18n_schema",
227+
src = "commands/extract-i18n.json",
228228
data = [
229229
"commands/definitions.json",
230230
],

packages/angular/cli/commands.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"deploy": "./commands/deploy.json",
77
"doc": "./commands/doc.json",
88
"e2e": "./commands/e2e.json",
9+
"extract-i18n": "./commands/extract-i18n.json",
910
"make-this-awesome": "./commands/easter-egg.json",
1011
"generate": "./commands/generate.json",
1112
"help": "./commands/help.json",
@@ -15,6 +16,5 @@
1516
"serve": "./commands/serve.json",
1617
"test": "./commands/test.json",
1718
"update": "./commands/update.json",
18-
"version": "./commands/version.json",
19-
"xi18n": "./commands/xi18n.json"
19+
"version": "./commands/version.json"
2020
}

packages/angular/cli/commands/xi18n-impl.ts renamed to packages/angular/cli/commands/extract-i18n-impl.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
import { ArchitectCommand } from '../models/architect-command';
1010
import { Arguments } from '../models/interface';
11-
import { Schema as Xi18nCommandSchema } from './xi18n';
11+
import { Schema as ExtractI18nCommandSchema } from './extract-i18n';
1212

13-
export class Xi18nCommand extends ArchitectCommand<Xi18nCommandSchema> {
13+
export class ExtractI18nCommand extends ArchitectCommand<ExtractI18nCommandSchema> {
1414
public readonly target = 'extract-i18n';
1515

16-
public async run(options: Xi18nCommandSchema & Arguments) {
16+
public async run(options: ExtractI18nCommandSchema & Arguments) {
1717
const version = process.version.substr(1).split('.');
1818
if (Number(version[0]) === 12 && Number(version[1]) === 0) {
1919
this.logger.error(
@@ -23,6 +23,11 @@ export class Xi18nCommand extends ArchitectCommand<Xi18nCommandSchema> {
2323
return 1;
2424
}
2525

26+
const commandName = process.argv[2];
27+
if (['xi18n', 'i18n-extract'].includes(commandName)) {
28+
this.logger.warn(`Warning: "ng ${commandName}" has been deprecated and will be removed in a future major version. Please use "ng extract-i18n" instead.`);
29+
}
30+
2631
return this.runArchitectTarget(options);
2732
}
2833
}

packages/angular/cli/commands/xi18n.json renamed to packages/angular/cli/commands/extract-i18n.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"$schema": "http://json-schema.org/schema",
3-
"$id": "ng-cli://commands/xi18n.json",
3+
"$id": "ng-cli://commands/extract-i18n.json",
44
"description": "Extracts i18n messages from source code.",
55
"$longDescription": "",
66

7-
"$aliases": ["i18n-extract"],
7+
"$aliases": ["i18n-extract", "xi18n"],
88
"$scope": "in",
99
"$type": "architect",
10-
"$impl": "./xi18n-impl#Xi18nCommand",
10+
"$impl": "./extract-i18n-impl#ExtractI18nCommand",
1111

1212
"type": "object",
1313
"allOf": [

packages/angular/cli/models/command-runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const standardCommands = {
3939
'config': '../commands/config.json',
4040
'doc': '../commands/doc.json',
4141
'e2e': '../commands/e2e.json',
42+
'extract-i18n': '../commands/extract-i18n.json',
4243
'make-this-awesome': '../commands/easter-egg.json',
4344
'generate': '../commands/generate.json',
4445
'help': '../commands/help.json',
@@ -49,7 +50,6 @@ const standardCommands = {
4950
'test': '../commands/test.json',
5051
'update': '../commands/update.json',
5152
'version': '../commands/version.json',
52-
'xi18n': '../commands/xi18n.json',
5353
};
5454

5555
export interface CommandMapOptions {

tests/legacy-cli/e2e/tests/i18n/extract-default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function() {
1515
join('src/app/i18n-test', 'i18n-test.component.html'),
1616
'<p i18n>Hello world</p>',
1717
);
18-
await ng('xi18n');
18+
await ng('extract-i18n');
1919
await expectFileToExist('messages.xlf');
2020
await expectFileToMatch('messages.xlf', /Hello world/);
2121
}

tests/legacy-cli/e2e/tests/i18n/extract-errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default async function () {
1616
'<p i18n>Hello world <span i18n>inner</span></p>',
1717
);
1818

19-
const { message } = await expectToFail(() => ng('xi18n'));
19+
const { message } = await expectToFail(() => ng('extract-i18n'));
2020

2121
const veProject = getGlobalVariable('argv')['ve'];
2222
const msg = veProject

tests/legacy-cli/e2e/tests/i18n/extract-ivy-libraries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default async function() {
6161
await installPackage(localizeVersion);
6262

6363
// Extract messages
64-
await ng('xi18n', '--ivy');
64+
await ng('extract-i18n', '--ivy');
6565
await expectFileToMatch('messages.xlf', 'Hello world');
6666
await expectFileToMatch('messages.xlf', 'i18n-lib-test works!');
6767
await expectFileToMatch('messages.xlf', 'src/app/app.component.html');

tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default async function() {
2121
);
2222

2323
// Should fail with --ivy flag if `@angular/localize` is missing
24-
const { message: message1 } = await expectToFail(() => ng('xi18n'));
24+
const { message: message1 } = await expectToFail(() => ng('extract-i18n'));
2525
if (!message1.includes(`Ivy extraction requires the '@angular/localize' package.`)) {
2626
throw new Error('Expected localize package error message when missing');
2727
}
@@ -34,13 +34,13 @@ export default async function() {
3434
await installPackage(localizeVersion);
3535

3636
// Should show ivy enabled application warning without --ivy flag
37-
const { stderr: message3 } = await ng('xi18n', '--no-ivy');
37+
const { stderr: message3 } = await ng('extract-i18n', '--no-ivy');
3838
if (!message3.includes(`Ivy extraction not enabled but application is Ivy enabled.`)) {
3939
throw new Error('Expected ivy enabled application warning');
4040
}
4141

4242
// Should not show any warnings when extracting
43-
const { stderr: message5 } = await ng('xi18n', '--ivy');
43+
const { stderr: message5 } = await ng('extract-i18n', '--ivy');
4444
if (message5.includes('WARNING')) {
4545
throw new Error('Expected no warnings to be shown');
4646
}
@@ -53,7 +53,7 @@ export default async function() {
5353
});
5454

5555
// Should show ivy disabled application warning with --ivy flag and enableIvy false
56-
const { message: message4 } = await expectToFail(() => ng('xi18n', '--ivy'));
56+
const { message: message4 } = await expectToFail(() => ng('extract-i18n', '--ivy'));
5757
if (!message4.includes(`Ivy extraction enabled but application is not Ivy enabled.`)) {
5858
throw new Error('Expected ivy disabled application warning');
5959
}

tests/legacy-cli/e2e/tests/i18n/extract-locale.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function() {
1414
.then(() => writeFile(
1515
join('src/app/i18n-test', 'i18n-test.component.html'),
1616
'<p i18n>Hello world</p>'))
17-
.then(() => ng('xi18n', '--i18n-locale', 'fr'))
17+
.then(() => ng('extract-i18n', '--i18n-locale', 'fr'))
1818
.then((output) => {
1919
if (!output.stderr.match(/starting from Angular v4/)) {
2020
return expectFileToMatch('messages.xlf', 'source-language="fr"');

tests/legacy-cli/e2e/tests/i18n/extract-outfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ export default async function () {
1414
join('src/app/i18n-test', 'i18n-test.component.html'),
1515
'<p i18n>Hello world</p>',
1616
);
17-
await ng('xi18n', '--out-file', 'messages.fr.xlf');
17+
await ng('extract-i18n', '--out-file', 'messages.fr.xlf');
1818
await expectFileToMatch('messages.fr.xlf', 'Hello world');
1919
}

tests/legacy-cli/e2e/tests/i18n/extract-xmb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function() {
1717
.then(() =>
1818
writeFile(join('src/app/i18n-test', 'i18n-test.component.html'), '<p i18n>Hello world</p>'),
1919
)
20-
.then(() => ng('xi18n', '--format', 'xmb'))
20+
.then(() => ng('extract-i18n', '--format', 'xmb'))
2121
.then(() => expectFileToExist('messages.xmb'))
2222
.then(() => expectFileToMatch('messages.xmb', /Hello world/));
2323
}

tests/legacy-cli/e2e/tests/i18n/ivy-localize-app-shell.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default async function () {
104104
);
105105

106106
// Extract the translation messages and copy them for each language.
107-
await ng('xi18n', '--output-path=src/locale');
107+
await ng('extract-i18n', '--output-path=src/locale');
108108
await expectFileToExist('src/locale/messages.xlf');
109109
await expectFileToMatch('src/locale/messages.xlf', `source-language="en-US"`);
110110
await expectFileToMatch('src/locale/messages.xlf', `An introduction header for this sample`);

tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default async function() {
119119
);
120120

121121
// Extract the translation messages and copy them for each language.
122-
await ng('xi18n', '--output-path=src/locale');
122+
await ng('extract-i18n', '--output-path=src/locale');
123123
await expectFileToExist('src/locale/messages.xlf');
124124
await expectFileToMatch('src/locale/messages.xlf', `source-language="en-US"`);
125125
await expectFileToMatch('src/locale/messages.xlf', `An introduction header for this sample`);

tests/legacy-cli/e2e/tests/i18n/legacy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export async function setupI18nConfig(useLocalize = true, format: keyof typeof f
219219

220220
// Extract the translation messages.
221221
await ng(
222-
'xi18n',
222+
'extract-i18n',
223223
'--output-path=src/locale',
224224
`--format=${format}`,
225225
);

tests/legacy-cli/e2e/utils/process.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export function execAndWaitForOutputToMatch(cmd: string, args: string[], match:
187187
export function ng(...args: string[]) {
188188
const argv = getGlobalVariable('argv');
189189
const maybeSilentNg = argv['nosilent'] ? noSilentNg : silentNg;
190-
if (['build', 'serve', 'test', 'e2e', 'xi18n'].indexOf(args[0]) != -1) {
190+
if (['build', 'serve', 'test', 'e2e', 'extract-i18n'].indexOf(args[0]) != -1) {
191191
if (args[0] == 'e2e') {
192192
// Wait 1 second before running any end-to-end test.
193193
return new Promise(resolve => setTimeout(resolve, 1000))

0 commit comments

Comments
 (0)