fix(ivy): i18n - do not generate jsdoc comments for `$localize` (#32473)

Previously the template compiler would generate the same jsdoc comment
block for `$localize` as for `goog.getMsg()`. But it turns out that
the closure compiler will complain if the `@desc` and `@meaning`
tags are used for non-`getMsg()` calls.

For now we do not generate the comments for `$localize` calls. They are
not being used at the moment.

In the future it would be good to be able to extract the descriptions and
meanings from the `$localize` calls rather than relying upon the `getMsg()`
calls, which we do now. So we need to find a workaround for this constraint.

PR Close #32473
This commit is contained in:
Pete Bacon Darwin 2019-09-04 15:11:25 +01:00 committed by Miško Hevery
parent 0187b3288b
commit a731119f9f
3 changed files with 11 additions and 70 deletions

View File

@ -194,10 +194,6 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$; $I18N_0$ = $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$;
} }
else { else {
/**
* @desc descA
* @meaning meaningA
*/
$I18N_0$ = $localize \`Content A\`; $I18N_0$ = $localize \`Content A\`;
} }
const $_c2$ = [${AttributeMarker.I18n}, "title"]; const $_c2$ = [${AttributeMarker.I18n}, "title"];
@ -211,10 +207,6 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_idB$$APP_SPEC_TS_4$; $I18N_3$ = $MSG_EXTERNAL_idB$$APP_SPEC_TS_4$;
} }
else { else {
/**
* @desc descB
* @meaning meaningB
*/
$I18N_3$ = $localize \`Title B\`; $I18N_3$ = $localize \`Title B\`;
} }
const $_c5$ = ["title", $I18N_3$]; const $_c5$ = ["title", $I18N_3$];
@ -227,9 +219,6 @@ describe('i18n support in the template compiler', () => {
$I18N_7$ = $MSG_EXTERNAL_4978592519614169666$$APP_SPEC_TS_8$; $I18N_7$ = $MSG_EXTERNAL_4978592519614169666$$APP_SPEC_TS_8$;
} }
else { else {
/**
* @desc meaningC
*/
$I18N_7$ = $localize \`Title C\`; $I18N_7$ = $localize \`Title C\`;
} }
const $_c9$ = ["title", $I18N_7$]; const $_c9$ = ["title", $I18N_7$];
@ -243,10 +232,6 @@ describe('i18n support in the template compiler', () => {
$I18N_11$ = $MSG_EXTERNAL_5200291527729162531$$APP_SPEC_TS_12$; $I18N_11$ = $MSG_EXTERNAL_5200291527729162531$$APP_SPEC_TS_12$;
} }
else { else {
/**
* @desc descD
* @meaning meaningD
*/
$I18N_11$ = $localize \`Title D\`; $I18N_11$ = $localize \`Title D\`;
} }
const $_c13$ = ["title", $I18N_11$]; const $_c13$ = ["title", $I18N_11$];
@ -259,9 +244,6 @@ describe('i18n support in the template compiler', () => {
$I18N_15$ = $MSG_EXTERNAL_idE$$APP_SPEC_TS_16$; $I18N_15$ = $MSG_EXTERNAL_idE$$APP_SPEC_TS_16$;
} }
else { else {
/**
* @desc meaningE
*/
$I18N_15$ = $localize \`Title E\`; $I18N_15$ = $localize \`Title E\`;
} }
const $_c17$ = ["title", $I18N_15$]; const $_c17$ = ["title", $I18N_15$];
@ -283,9 +265,6 @@ describe('i18n support in the template compiler', () => {
$I18N_23$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$; $I18N_23$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$;
} }
else { else {
/**
* @desc [BACKUP_MESSAGE_ID:idH]desc
*/
$I18N_23$ = $localize \`Title G\`; $I18N_23$ = $localize \`Title G\`;
} }
const $_c25$ = ["title", $I18N_23$]; const $_c25$ = ["title", $I18N_23$];
@ -386,10 +365,6 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_8809028065680254561$$APP_SPEC_TS_1$; $I18N_1$ = $MSG_EXTERNAL_8809028065680254561$$APP_SPEC_TS_1$;
} }
else { else {
/**
* @desc d
* @meaning m
*/
$I18N_1$ = $localize \`introduction\`; $I18N_1$ = $localize \`introduction\`;
} }
const $_c1$ = ["title", $I18N_1$]; const $_c1$ = ["title", $I18N_1$];
@ -441,10 +416,6 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$; $I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$;
} }
else { else {
/**
* @desc d
* @meaning m
*/
$I18N_2$ = $localize \`intro $` + $I18N_2$ = $localize \`intro $` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`; String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`;
} }
@ -460,10 +431,6 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$; $I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$;
} }
else { else {
/**
* @desc d1
* @meaning m1
*/
$I18N_3$ = $localize \`$` + $I18N_3$ = $localize \`$` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`; String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`;
} }
@ -485,10 +452,6 @@ describe('i18n support in the template compiler', () => {
$I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$; $I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$;
} }
else { else {
/**
* @desc d2
* @meaning m2
*/
$I18N_6$ = $localize \`$` + $I18N_6$ = $localize \`$` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation: and $` + String.raw `{"\uFFFD0\uFFFD"}:interpolation: and $` +
String.raw `{"\uFFFD1\uFFFD"}:interpolation_1: and again $` + String.raw `{"\uFFFD1\uFFFD"}:interpolation_1: and again $` +
@ -554,10 +517,6 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_8977039798304050198$; $I18N_1$ = $MSG_EXTERNAL_8977039798304050198$;
} }
else { else {
/**
* @desc d
* @meaning m
*/
$I18N_1$ = $localize \`intro $` + $I18N_1$ = $localize \`intro $` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`; String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`;
} }
@ -601,10 +560,6 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__1$; $I18N_1$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__1$;
} }
else { else {
/**
* @desc d
* @meaning m
*/
$I18N_1$ = $localize \`different scope $` + $I18N_1$ = $localize \`different scope $` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`; String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`;
} }
@ -679,10 +634,6 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$; $I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$;
} }
else { else {
/**
* @desc d
* @meaning m
*/
$I18N_2$ = $localize \`intro $` + $I18N_2$ = $localize \`intro $` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`; String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`;
} }
@ -698,10 +649,6 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$; $I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$;
} }
else { else {
/**
* @desc d1
* @meaning m1
*/
$I18N_3$ = $localize \`$` + $I18N_3$ = $localize \`$` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`; String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`;
} }
@ -723,10 +670,6 @@ describe('i18n support in the template compiler', () => {
$I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$; $I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$;
} }
else { else {
/**
* @desc d2
* @meaning m2
*/
$I18N_6$ = $localize \`$` + $I18N_6$ = $localize \`$` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation: and $` + String.raw `{"\uFFFD0\uFFFD"}:interpolation: and $` +
String.raw `{"\uFFFD1\uFFFD"}:interpolation_1: and again $` + String.raw `{"\uFFFD1\uFFFD"}:interpolation_1: and again $` +
@ -795,10 +738,6 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__3$; $I18N_2$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__3$;
} }
else { else {
/**
* @desc d
* @meaning m
*/
$I18N_2$ = $localize \`different scope $` + $I18N_2$ = $localize \`different scope $` +
String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`; String.raw `{"\uFFFD0\uFFFD"}:interpolation:\`;
} }
@ -852,10 +791,6 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7727043314656808423$$APP_SPEC_TS_0$; $I18N_0$ = $MSG_EXTERNAL_7727043314656808423$$APP_SPEC_TS_0$;
} }
else { else {
/**
* @desc d
* @meaning m
*/
$I18N_0$ = $localize \`Element title\`; $I18N_0$ = $localize \`Element title\`;
} }
const $_c1$ = ["title", $I18N_0$]; const $_c1$ = ["title", $I18N_0$];

View File

@ -25,7 +25,10 @@ export function createGoogleGetMsgStatements(
args.push(mapLiteral(params, true)); args.push(mapLiteral(params, true));
} }
// /** Description and meaning of message */ // /**
// * @desc description of message
// * @meaning meaning of message
// */
// const MSG_... = goog.getMsg(..); // const MSG_... = goog.getMsg(..);
// I18N_X = MSG_...; // I18N_X = MSG_...;
const statements = []; const statements = [];

View File

@ -17,10 +17,13 @@ export function createLocalizeStatements(
params: {[name: string]: o.Expression}): o.Statement[] { params: {[name: string]: o.Expression}): o.Statement[] {
const statements = []; const statements = [];
const jsdocComment = i18nMetaToDocStmt(metaFromI18nMessage(message)); // TODO: re-enable these comments when we have a plan on how to make them work so that Closure
if (jsdocComment !== null) { // compiler doesn't complain about the JSDOC comments.
statements.push(jsdocComment);
} // const jsdocComment = i18nMetaToDocStmt(metaFromI18nMessage(message));
// if (jsdocComment !== null) {
// statements.push(jsdocComment);
// }
const {messageParts, placeHolders} = serializeI18nMessageForLocalize(message); const {messageParts, placeHolders} = serializeI18nMessageForLocalize(message);
statements.push(new o.ExpressionStatement(variable.set( statements.push(new o.ExpressionStatement(variable.set(