Skip to content

Commit 16ac620

Browse files
committed
refactor(localize): convert scripts within packages/localize to relative imports
This commit updates scripts within `packages/localize` to relative imports as a prep work to the upcoming infra updates.
1 parent 7499b74 commit 16ac620

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+76
-73
lines changed

goldens/public-api/localize/init/index.api.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
55
```ts
66

7-
import { ɵ$localize as $localize } from '@angular/localize';
8-
import { ɵLocalizeFn as LocalizeFn } from '@angular/localize';
9-
import { ɵTranslateFn as TranslateFn } from '@angular/localize';
10-
11-
export { $localize }
12-
13-
export { LocalizeFn }
14-
15-
export { TranslateFn }
7+
// @public
8+
const $localize_2: LocalizeFn;
9+
export { $localize_2 as $localize }
10+
11+
// @public (undocumented)
12+
export interface LocalizeFn {
13+
// (undocumented)
14+
(messageParts: TemplateStringsArray, ...expressions: readonly any[]): string;
15+
locale?: string;
16+
translate?: TranslateFn;
17+
}
18+
19+
// @public (undocumented)
20+
export interface TranslateFn {
21+
// (undocumented)
22+
(messageParts: TemplateStringsArray, expressions: readonly any[]): [TemplateStringsArray, readonly any[]];
23+
}
1624

1725
// (No @packageDocumentation comment for this package)
1826

goldens/public-api/localize/tools/index.api.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
import { AbsoluteFsPath } from '@angular/compiler-cli/private/localize';
88
import { Element as Element_2 } from '@angular/compiler';
99
import { Logger } from '@angular/compiler-cli/private/localize';
10-
import { MessageId } from '@angular/localize';
1110
import { NodePath } from '@babel/core';
1211
import { ParseError } from '@angular/compiler';
1312
import { PathManipulation } from '@angular/compiler-cli/private/localize';
1413
import { PluginObj } from '@babel/core';
1514
import { ReadonlyFileSystem } from '@angular/compiler-cli/private/localize';
1615
import { types } from '@babel/core';
17-
import { ɵParsedMessage } from '@angular/localize';
18-
import { ɵParsedTranslation } from '@angular/localize';
19-
import { ɵSourceLocation } from '@angular/localize';
20-
import { ɵSourceMessage } from '@angular/localize';
2116

2217
// @public
2318
export class ArbTranslationParser implements TranslationParser<ArbJsonObject> {
@@ -31,14 +26,14 @@ export class ArbTranslationParser implements TranslationParser<ArbJsonObject> {
3126
export class ArbTranslationSerializer implements TranslationSerializer {
3227
constructor(sourceLocale: string, basePath: AbsoluteFsPath, fs: PathManipulation);
3328
// (undocumented)
34-
serialize(messages: ɵParsedMessage[]): string;
29+
serialize(messages: ParsedMessage[]): string;
3530
}
3631

3732
// @public
3833
export function buildLocalizeReplacement(messageParts: TemplateStringsArray, substitutions: readonly types.Expression[]): types.Expression;
3934

4035
// @public
41-
export function checkDuplicateMessages(fs: PathManipulation, messages: ɵParsedMessage[], duplicateMessageHandling: DiagnosticHandlingStrategy, basePath: AbsoluteFsPath): Diagnostics;
36+
export function checkDuplicateMessages(fs: PathManipulation, messages: ParsedMessage[], duplicateMessageHandling: DiagnosticHandlingStrategy, basePath: AbsoluteFsPath): Diagnostics;
4237

4338
// @public
4439
export type DiagnosticHandlingStrategy = 'error' | 'warning' | 'ignore';
@@ -71,14 +66,14 @@ export function isGlobalIdentifier(identifier: NodePath<types.Identifier>): bool
7166
export class LegacyMessageIdMigrationSerializer implements TranslationSerializer {
7267
constructor(_diagnostics: Diagnostics);
7368
// (undocumented)
74-
serialize(messages: ɵParsedMessage[]): string;
69+
serialize(messages: ParsedMessage[]): string;
7570
}
7671

7772
// @public
78-
export function makeEs2015TranslatePlugin(diagnostics: Diagnostics, translations: Record<string, ɵParsedTranslation>, { missingTranslation, localizeName }?: TranslatePluginOptions, fs?: PathManipulation): PluginObj;
73+
export function makeEs2015TranslatePlugin(diagnostics: Diagnostics, translations: Record<string, ParsedTranslation>, { missingTranslation, localizeName }?: TranslatePluginOptions, fs?: PathManipulation): PluginObj;
7974

8075
// @public
81-
export function makeEs5TranslatePlugin(diagnostics: Diagnostics, translations: Record<string, ɵParsedTranslation>, { missingTranslation, localizeName }?: TranslatePluginOptions, fs?: PathManipulation): PluginObj;
76+
export function makeEs5TranslatePlugin(diagnostics: Diagnostics, translations: Record<string, ParsedTranslation>, { missingTranslation, localizeName }?: TranslatePluginOptions, fs?: PathManipulation): PluginObj;
8277

8378
// @public
8479
export function makeLocalePlugin(locale: string, { localizeName }?: TranslatePluginOptions): PluginObj;
@@ -87,7 +82,7 @@ export function makeLocalePlugin(locale: string, { localizeName }?: TranslatePlu
8782
export class MessageExtractor {
8883
constructor(fs: ReadonlyFileSystem, logger: Logger, { basePath, useSourceMaps, localizeName }: ExtractionOptions);
8984
// (undocumented)
90-
extractMessages(filename: string): ɵParsedMessage[];
85+
extractMessages(filename: string): ParsedMessage[];
9186
}
9287

9388
// @public
@@ -102,23 +97,23 @@ export class SimpleJsonTranslationParser implements TranslationParser<SimpleJson
10297
export class SimpleJsonTranslationSerializer implements TranslationSerializer {
10398
constructor(sourceLocale: string);
10499
// (undocumented)
105-
serialize(messages: ɵParsedMessage[]): string;
100+
serialize(messages: ParsedMessage[]): string;
106101
}
107102

108103
// @public
109-
export function translate(diagnostics: Diagnostics, translations: Record<string, ɵParsedTranslation>, messageParts: TemplateStringsArray, substitutions: readonly any[], missingTranslation: DiagnosticHandlingStrategy): [TemplateStringsArray, readonly any[]];
104+
export function translate(diagnostics: Diagnostics, translations: Record<string, ParsedTranslation>, messageParts: TemplateStringsArray, substitutions: readonly any[], missingTranslation: DiagnosticHandlingStrategy): [TemplateStringsArray, readonly any[]];
110105

111106
// @public
112-
export function unwrapExpressionsFromTemplateLiteral(quasi: NodePath<types.TemplateLiteral>, fs?: PathManipulation): [types.Expression[], (ɵSourceLocation | undefined)[]];
107+
export function unwrapExpressionsFromTemplateLiteral(quasi: NodePath<types.TemplateLiteral>, fs?: PathManipulation): [types.Expression[], (SourceLocation | undefined)[]];
113108

114109
// @public
115-
export function unwrapMessagePartsFromLocalizeCall(call: NodePath<types.CallExpression>, fs?: PathManipulation): [TemplateStringsArray, (ɵSourceLocation | undefined)[]];
110+
export function unwrapMessagePartsFromLocalizeCall(call: NodePath<types.CallExpression>, fs?: PathManipulation): [TemplateStringsArray, (SourceLocation | undefined)[]];
116111

117112
// @public
118-
export function unwrapMessagePartsFromTemplateLiteral(elements: NodePath<types.TemplateElement>[], fs?: PathManipulation): [TemplateStringsArray, (ɵSourceLocation | undefined)[]];
113+
export function unwrapMessagePartsFromTemplateLiteral(elements: NodePath<types.TemplateElement>[], fs?: PathManipulation): [TemplateStringsArray, (SourceLocation | undefined)[]];
119114

120115
// @public
121-
export function unwrapSubstitutionsFromLocalizeCall(call: NodePath<types.CallExpression>, fs?: PathManipulation): [types.Expression[], (ɵSourceLocation | undefined)[]];
116+
export function unwrapSubstitutionsFromLocalizeCall(call: NodePath<types.CallExpression>, fs?: PathManipulation): [types.Expression[], (SourceLocation | undefined)[]];
122117

123118
// @public
124119
export class Xliff1TranslationParser implements TranslationParser<XmlTranslationParserHint> {
@@ -132,7 +127,7 @@ export class Xliff1TranslationParser implements TranslationParser<XmlTranslation
132127
export class Xliff1TranslationSerializer implements TranslationSerializer {
133128
constructor(sourceLocale: string, basePath: AbsoluteFsPath, useLegacyIds: boolean, formatOptions?: FormatOptions, fs?: PathManipulation);
134129
// (undocumented)
135-
serialize(messages: ɵParsedMessage[]): string;
130+
serialize(messages: ParsedMessage[]): string;
136131
}
137132

138133
// @public
@@ -147,14 +142,14 @@ export class Xliff2TranslationParser implements TranslationParser<XmlTranslation
147142
export class Xliff2TranslationSerializer implements TranslationSerializer {
148143
constructor(sourceLocale: string, basePath: AbsoluteFsPath, useLegacyIds: boolean, formatOptions?: FormatOptions, fs?: PathManipulation);
149144
// (undocumented)
150-
serialize(messages: ɵParsedMessage[]): string;
145+
serialize(messages: ParsedMessage[]): string;
151146
}
152147

153148
// @public
154149
export class XmbTranslationSerializer implements TranslationSerializer {
155150
constructor(basePath: AbsoluteFsPath, useLegacyIds: boolean, fs?: PathManipulation);
156151
// (undocumented)
157-
serialize(messages: ɵParsedMessage[]): string;
152+
serialize(messages: ParsedMessage[]): string;
158153
}
159154

160155
// @public

packages/localize/init/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
ɵ$localize as $localize,
1010
ɵLocalizeFn as LocalizeFn,
1111
ɵTranslateFn as TranslateFn,
12-
} from '@angular/localize';
12+
} from '../index';
1313

1414
export {$localize, LocalizeFn, TranslateFn};
1515

packages/localize/test/translate_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88
// Ensure that `$localize` is loaded to the global scope.
9-
import '@angular/localize/init';
9+
import '../init';
1010

1111
import {clearTranslations, loadTranslations} from '../index';
1212
import {computeMsgId, MessageId, TargetMessage} from '../src/utils';

packages/localize/tools/src/extract/duplicates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88
import {AbsoluteFsPath, PathManipulation} from '@angular/compiler-cli/private/localize';
9-
import {MessageId, ɵParsedMessage} from '@angular/localize';
9+
import {MessageId, ɵParsedMessage} from '../../../index';
1010

1111
import {DiagnosticHandlingStrategy, Diagnostics} from '../diagnostics';
1212
import {serializeLocationPosition} from '../source_file_utils';

packages/localize/tools/src/extract/extraction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
SourceFile,
1313
SourceFileLoader,
1414
} from '@angular/compiler-cli/private/localize';
15-
import {ɵParsedMessage, ɵSourceLocation} from '@angular/localize';
15+
import {ɵParsedMessage, ɵSourceLocation} from '../../../index';
1616
import {transformSync} from '@babel/core';
1717

1818
import {makeEs2015ExtractPlugin} from './source_files/es2015_extract_plugin';

packages/localize/tools/src/extract/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Logger,
1212
PathManipulation,
1313
} from '@angular/compiler-cli/private/localize';
14-
import {ɵParsedMessage} from '@angular/localize';
14+
import {ɵParsedMessage} from '../../../index';
1515

1616
import {DiagnosticHandlingStrategy, Diagnostics} from '../diagnostics';
1717

packages/localize/tools/src/extract/source_files/es2015_extract_plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88
import {PathManipulation} from '@angular/compiler-cli/private/localize';
9-
import {ɵParsedMessage, ɵparseMessage} from '@angular/localize';
9+
import {ɵParsedMessage, ɵparseMessage} from '../../../../index';
1010
import {NodePath, PluginObj, types as t} from '@babel/core';
1111

1212
import {

packages/localize/tools/src/extract/source_files/es5_extract_plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88
import {PathManipulation} from '@angular/compiler-cli/private/localize';
9-
import {ɵParsedMessage, ɵparseMessage} from '@angular/localize';
9+
import {ɵParsedMessage, ɵparseMessage} from '../../../../index';
1010
import {NodePath, PluginObj, types as t} from '@babel/core';
1111

1212
import {

packages/localize/tools/src/extract/translation_files/arb_translation_serializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88
import {AbsoluteFsPath, PathManipulation} from '@angular/compiler-cli/private/localize';
9-
import {ɵParsedMessage, ɵSourceLocation} from '@angular/localize';
9+
import {ɵParsedMessage, ɵSourceLocation} from '../../../../index';
1010
import {TranslationSerializer} from './translation_serializer';
1111
import {consolidateMessages, hasLocation} from './utils';
1212

0 commit comments

Comments
 (0)