More metadata#85
Conversation
| const expectedMessages = fs.readFileSync(path.join(fixtureDir, 'expected.json')); | ||
| const actualMessages = fs.readFileSync(path.join(fixtureDir, 'actual.json')); | ||
| assert.equal(trim(actualMessages), trim(expectedMessages)); | ||
| const expectedMessages = require(path.join(fixtureDir, 'expected.json')); |
There was a problem hiding this comment.
changed this test to rely on deepEqual instead of text string content. different object key order was breaking tests
| let key = getMessageDescriptorKey(keyPath); | ||
|
|
||
| if (DESCRIPTOR_PROPS.has(key)) { | ||
| if (Object.keys(fields).includes(key)) { |
There was a problem hiding this comment.
this is breaking tests in older node versions
|
@mattkime thanks for working through this! I want to have a deeper understanding of your use cases so I can internalize them. Could you provide some real world examples of |
|
We'll have a field that references a story or epic in our ticketing system - |
|
I'm most interested to see a JSX and/or JS example of exactly what you're thinking. |
|
@ericf Does this clarify? but this is obviously only one side. The other half is extracting the data and providing it to the translators. |
|
Hmm… there's something here I'm not liking about expanding the props of <FormattedMessage
id='abc1234'
description={{
text: 'card title',
jira: 'MW-1234',
}}
defaultMessage='Article: {title}'
/>And this would extracted to: [{
"id": "abc1234",
"description": {
"text": "card title",
"jira": "MW-1234"
},
"defaultMessage": "Article: {title}"
}] |
|
Sounds good, I'll take another swing at the pr
…On Thu, Dec 22, 2016 at 3:06 PM Eric Ferraiuolo ***@***.***> wrote:
Hmm… there's something here I'm not liking about expanding the props of
<FormattedMessage>. But I do see the value in structured metadata. What
if description could be any value as long as it can be statically
evaluated and is JSON-serializable?
<FormattedMessage
id='abc1234'
description={{
text: 'card title',
jira: 'MW-1234',
}}
defaultMessage='Article: {title}'
/>
And this would extracted to:
[{
"id": "abc1234",
"description": {
"text": "card title",
"jira": "MW-1234"
},
"defaultMessage": "Article: {title}"
}]
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#85 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANMcNC76AKHEs-h-wDXhNx3DullLxDkks5rKuZfgaJpZM4LToXY>
.
|
|
I verified that this works for extraction as long as I get rid of a The next step is providing for some sort of verification of the description fields. i'd like to provide a function to |
The description should be type-checked and only call
This would likely only be possible if you use Babel via its API. Since |
|
Closing in favor of #87 |
addresses #80
adds ability to configure additional metadata fields and whether they're required.
fields: For specifying additional metadata fields and whether they're required. Takes an object with field names as key names, which specify whether they're required.fields: { metadata: { required: true }, otherdata: {required: false} }