1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import * as i18n from '../../../i18n/i18n_ast';
|
---|
9 | import * as html from '../../../ml_parser/ast';
|
---|
10 | import * as o from '../../../output/output_ast';
|
---|
11 | import * as t from '../../r3_ast';
|
---|
12 | /**
|
---|
13 | * Prefix for non-`goog.getMsg` i18n-related vars.
|
---|
14 | * Note: the prefix uses lowercase characters intentionally due to a Closure behavior that
|
---|
15 | * considers variables like `I18N_0` as constants and throws an error when their value changes.
|
---|
16 | */
|
---|
17 | export declare const TRANSLATION_VAR_PREFIX = "i18n_";
|
---|
18 | /** Name of the i18n attributes **/
|
---|
19 | export declare const I18N_ATTR = "i18n";
|
---|
20 | export declare const I18N_ATTR_PREFIX = "i18n-";
|
---|
21 | /** Prefix of var expressions used in ICUs */
|
---|
22 | export declare const I18N_ICU_VAR_PREFIX = "VAR_";
|
---|
23 | /** Prefix of ICU expressions for post processing */
|
---|
24 | export declare const I18N_ICU_MAPPING_PREFIX = "I18N_EXP_";
|
---|
25 | /** Placeholder wrapper for i18n expressions **/
|
---|
26 | export declare const I18N_PLACEHOLDER_SYMBOL = "\uFFFD";
|
---|
27 | export declare function isI18nAttribute(name: string): boolean;
|
---|
28 | export declare function isI18nRootNode(meta?: i18n.I18nMeta): meta is i18n.Message;
|
---|
29 | export declare function isSingleI18nIcu(meta?: i18n.I18nMeta): boolean;
|
---|
30 | export declare function hasI18nMeta(node: t.Node & {
|
---|
31 | i18n?: i18n.I18nMeta;
|
---|
32 | }): boolean;
|
---|
33 | export declare function hasI18nAttrs(element: html.Element): boolean;
|
---|
34 | export declare function icuFromI18nMessage(message: i18n.Message): i18n.IcuPlaceholder;
|
---|
35 | export declare function wrapI18nPlaceholder(content: string | number, contextId?: number): string;
|
---|
36 | export declare function assembleI18nBoundString(strings: string[], bindingStartIndex?: number, contextId?: number): string;
|
---|
37 | export declare function getSeqNumberGenerator(startsAt?: number): () => number;
|
---|
38 | export declare function placeholdersToParams(placeholders: Map<string, string[]>): {
|
---|
39 | [name: string]: o.LiteralExpr;
|
---|
40 | };
|
---|
41 | export declare function updatePlaceholderMap(map: Map<string, any[]>, name: string, ...values: any[]): void;
|
---|
42 | export declare function assembleBoundTextPlaceholders(meta: i18n.I18nMeta, bindingStartIndex?: number, contextId?: number): Map<string, any[]>;
|
---|
43 | /**
|
---|
44 | * Format the placeholder names in a map of placeholders to expressions.
|
---|
45 | *
|
---|
46 | * The placeholder names are converted from "internal" format (e.g. `START_TAG_DIV_1`) to "external"
|
---|
47 | * format (e.g. `startTagDiv_1`).
|
---|
48 | *
|
---|
49 | * @param params A map of placeholder names to expressions.
|
---|
50 | * @param useCamelCase whether to camelCase the placeholder name when formatting.
|
---|
51 | * @returns A new map of formatted placeholder names to expressions.
|
---|
52 | */
|
---|
53 | export declare function i18nFormatPlaceholderNames(params: {
|
---|
54 | [name: string]: o.Expression;
|
---|
55 | } | undefined, useCamelCase: boolean): {
|
---|
56 | [key: string]: o.Expression;
|
---|
57 | };
|
---|
58 | /**
|
---|
59 | * Converts internal placeholder names to public-facing format
|
---|
60 | * (for example to use in goog.getMsg call).
|
---|
61 | * Example: `START_TAG_DIV_1` is converted to `startTagDiv_1`.
|
---|
62 | *
|
---|
63 | * @param name The placeholder name that should be formatted
|
---|
64 | * @returns Formatted placeholder name
|
---|
65 | */
|
---|
66 | export declare function formatI18nPlaceholderName(name: string, useCamelCase?: boolean): string;
|
---|
67 | /**
|
---|
68 | * Generates a prefix for translation const name.
|
---|
69 | *
|
---|
70 | * @param extra Additional local prefix that should be injected into translation var name
|
---|
71 | * @returns Complete translation const prefix
|
---|
72 | */
|
---|
73 | export declare function getTranslationConstPrefix(extra: string): string;
|
---|
74 | /**
|
---|
75 | * Generate AST to declare a variable. E.g. `var I18N_1;`.
|
---|
76 | * @param variable the name of the variable to declare.
|
---|
77 | */
|
---|
78 | export declare function declareI18nVariable(variable: o.ReadVarExpr): o.Statement;
|
---|