Skip to content

Commit d463673

Browse files
committed
feat(@formatjs/cli): extract object-type description from message, fix formatjs#3373
1 parent 3f75923 commit d463673

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

packages/cli/src/formatters/crowdin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export const format: FormatFn<SmartlingJson> = msgs => {
1313
for (const [id, msg] of Object.entries(msgs)) {
1414
results[id] = {
1515
message: msg.defaultMessage!,
16-
description: msg.description,
16+
description:
17+
typeof msg.description === 'string'
18+
? msg.description
19+
: JSON.stringify(msg.description),
1720
}
1821
}
1922
return results

packages/cli/src/formatters/lokalise.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export const format: FormatFn<StructuredJson> = msgs => {
1515
for (const [id, msg] of Object.entries(msgs)) {
1616
results[id] = {
1717
translation: msg.defaultMessage!,
18-
notes: msg.description,
18+
notes:
19+
typeof msg.description === 'string'
20+
? msg.description
21+
: JSON.stringify(msg.description),
1922
}
2023
}
2124
return results

packages/cli/src/formatters/smartling.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ export const format: FormatFn<SmartlingJson> = msgs => {
4141
for (const [id, msg] of Object.entries(msgs)) {
4242
results[id] = {
4343
message: msg.defaultMessage!,
44-
description: msg.description,
44+
description:
45+
typeof msg.description === 'string'
46+
? msg.description
47+
: JSON.stringify(msg.description),
4548
}
4649
}
4750
return results

packages/cli/src/formatters/transifex.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export const format: FormatFn<StructuredJson> = msgs => {
1515
for (const [id, msg] of Object.entries(msgs)) {
1616
results[id] = {
1717
string: msg.defaultMessage!,
18-
developer_comment: msg.description,
18+
developer_comment:
19+
typeof msg.description === 'string'
20+
? msg.description
21+
: JSON.stringify(msg.description),
1922
}
2023
}
2124
return results

0 commit comments

Comments
 (0)