refactor(compiler): remove redundant `metaFromI18nMessage()` function (#34154)
PR Close #34154
This commit is contained in:
parent
f6a6f26e0f
commit
41485599f3
|
@ -10,7 +10,7 @@ import {mapLiteral} from '../../../output/map_util';
|
|||
import * as o from '../../../output/output_ast';
|
||||
|
||||
import {serializeIcuNode} from './icu_serializer';
|
||||
import {i18nMetaToDocStmt, metaFromI18nMessage} from './meta';
|
||||
import {i18nMetaToDocStmt} from './meta';
|
||||
import {formatI18nPlaceholderName} from './util';
|
||||
|
||||
/** Closure uses `goog.getMsg(message)` to lookup translations */
|
||||
|
@ -32,7 +32,7 @@ export function createGoogleGetMsgStatements(
|
|||
// const MSG_... = goog.getMsg(..);
|
||||
// I18N_X = MSG_...;
|
||||
const statements = [];
|
||||
const jsdocComment = i18nMetaToDocStmt(metaFromI18nMessage(message));
|
||||
const jsdocComment = i18nMetaToDocStmt(message);
|
||||
if (jsdocComment !== null) {
|
||||
statements.push(jsdocComment);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import * as i18n from '../../../i18n/i18n_ast';
|
|||
import * as o from '../../../output/output_ast';
|
||||
|
||||
import {serializeIcuNode} from './icu_serializer';
|
||||
import {metaFromI18nMessage} from './meta';
|
||||
import {formatI18nPlaceholderName} from './util';
|
||||
|
||||
export function createLocalizeStatements(
|
||||
|
@ -18,9 +17,8 @@ export function createLocalizeStatements(
|
|||
const statements = [];
|
||||
|
||||
const {messageParts, placeHolders} = serializeI18nMessageForLocalize(message);
|
||||
statements.push(new o.ExpressionStatement(variable.set(o.localizedString(
|
||||
metaFromI18nMessage(message), messageParts, placeHolders,
|
||||
placeHolders.map(ph => params[ph])))));
|
||||
statements.push(new o.ExpressionStatement(variable.set(
|
||||
o.localizedString(message, messageParts, placeHolders, placeHolders.map(ph => params[ph])))));
|
||||
|
||||
return statements;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ export class I18nMetaVisitor implements html.Visitor {
|
|||
*/
|
||||
private _parseMetadata(meta: string|i18n.I18nMeta): I18nMeta {
|
||||
return typeof meta === 'string' ? parseI18nMeta(meta) :
|
||||
meta instanceof i18n.Message ? metaFromI18nMessage(meta) : {};
|
||||
meta instanceof i18n.Message ? meta : {};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,16 +187,6 @@ export class I18nMetaVisitor implements html.Visitor {
|
|||
}
|
||||
}
|
||||
|
||||
export function metaFromI18nMessage(message: i18n.Message, id: string | null = null): I18nMeta {
|
||||
return {
|
||||
id: typeof id === 'string' ? id : message.id || '',
|
||||
customId: message.customId,
|
||||
legacyIds: message.legacyIds,
|
||||
meaning: message.meaning || '',
|
||||
description: message.description || ''
|
||||
};
|
||||
}
|
||||
|
||||
/** I18n separators for metadata **/
|
||||
const I18N_MEANING_SEPARATOR = '|';
|
||||
const I18N_ID_SEPARATOR = '@@';
|
||||
|
|
Loading…
Reference in New Issue