fix(localize): include meaning in generated ARB files (#40546)
The ARB format doesn't have a dedicated field for message meaning so these changes include it as a customize attribute called `x-meaning`. Fixes #40506. PR Close #40546
This commit is contained in:
parent
6db342a87a
commit
8b9f6b504e
@ -50,7 +50,8 @@ export class ArbTranslationSerializer implements TranslationSerializer {
|
|||||||
const id = getMessageId(message);
|
const id = getMessageId(message);
|
||||||
output += this.serializeMessage(id, message);
|
output += this.serializeMessage(id, message);
|
||||||
output += this.serializeMeta(
|
output += this.serializeMeta(
|
||||||
id, message.description, duplicateMessages.filter(hasLocation).map(m => m.location));
|
id, message.description, message.meaning,
|
||||||
|
duplicateMessages.filter(hasLocation).map(m => m.location));
|
||||||
}
|
}
|
||||||
|
|
||||||
output += '\n}';
|
output += '\n}';
|
||||||
@ -62,14 +63,19 @@ export class ArbTranslationSerializer implements TranslationSerializer {
|
|||||||
return `,\n ${JSON.stringify(id)}: ${JSON.stringify(message.text)}`;
|
return `,\n ${JSON.stringify(id)}: ${JSON.stringify(message.text)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private serializeMeta(id: string, description: string|undefined, locations: ɵSourceLocation[]):
|
private serializeMeta(
|
||||||
string {
|
id: string, description: string|undefined, meaning: string|undefined,
|
||||||
|
locations: ɵSourceLocation[]): string {
|
||||||
const meta: string[] = [];
|
const meta: string[] = [];
|
||||||
|
|
||||||
if (description) {
|
if (description) {
|
||||||
meta.push(`\n "description": ${JSON.stringify(description)}`);
|
meta.push(`\n "description": ${JSON.stringify(description)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (meaning) {
|
||||||
|
meta.push(`\n "x-meaning": ${JSON.stringify(meaning)}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (locations.length > 0) {
|
if (locations.length > 0) {
|
||||||
let locationStr = `\n "x-locations": [`;
|
let locationStr = `\n "x-locations": [`;
|
||||||
for (let i = 0; i < locations.length; i++) {
|
for (let i = 0; i < locations.length; i++) {
|
||||||
|
@ -64,7 +64,8 @@ runInEachFileSystem(() => {
|
|||||||
' "13579": "{$START_BOLD_TEXT}b{$CLOSE_BOLD_TEXT}",',
|
' "13579": "{$START_BOLD_TEXT}b{$CLOSE_BOLD_TEXT}",',
|
||||||
' "24680": "a",',
|
' "24680": "a",',
|
||||||
' "@24680": {',
|
' "@24680": {',
|
||||||
' "description": "and description"',
|
' "description": "and description",',
|
||||||
|
' "x-meaning": "meaning"',
|
||||||
' },',
|
' },',
|
||||||
' "80808": "multi\\nlines",',
|
' "80808": "multi\\nlines",',
|
||||||
' "90000": "<escape{$double-quotes-\\"}me>",',
|
' "90000": "<escape{$double-quotes-\\"}me>",',
|
||||||
@ -72,6 +73,7 @@ runInEachFileSystem(() => {
|
|||||||
' "100001": "{VAR_PLURAL, plural, one {{START_BOLD_TEXT}something bold{CLOSE_BOLD_TEXT}} other {pre {START_TAG_SPAN}middle{CLOSE_TAG_SPAN} post}}",',
|
' "100001": "{VAR_PLURAL, plural, one {{START_BOLD_TEXT}something bold{CLOSE_BOLD_TEXT}} other {pre {START_TAG_SPAN}middle{CLOSE_TAG_SPAN} post}}",',
|
||||||
' "12345": "a{$PH}b{$PH_1}c",',
|
' "12345": "a{$PH}b{$PH_1}c",',
|
||||||
' "@12345": {',
|
' "@12345": {',
|
||||||
|
' "x-meaning": "some meaning",',
|
||||||
' "x-locations": [',
|
' "x-locations": [',
|
||||||
' {',
|
' {',
|
||||||
' "file": "file.ts",',
|
' "file": "file.ts",',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user