Why context is missing in the MessageDescriptor type, but works?
#2489
-
|
I need to add a context to some messages in my project, for this, the const text1 = i18n.t(/* i18n */ { id: 'right_direction', message: 'Right', context: 'direction' })
const text2 = i18n.t(/* i18n */ { id: 'right_check_result', message: 'Right', context: 'check result' })But, it produces a typescript error: because the type MessageDescriptor = {
id: string;
comment?: string;
message?: string;
values?: Record<string, unknown>;
};So, the question is - why the If not correct, what is the correct approach to pass the context? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I think you already figured out that it doesn't work in the way as it intended The context is only consumed and makes sense when macro applied. Hence only If by "it works" you mean, extractor pick it up to the catalog - then yes, extractor does not analyze the scopw, when it sees an object with properties it will extract all properties it knows how to handle. |
Beta Was this translation helpful? Give feedback.
I think you already figured out that it doesn't work in the way as it intended
#2490 (comment)
The context is only consumed and makes sense when macro applied. Hence only
MacroMessageDescriptortype defines it.If by "it works" you mean, extractor pick it up to the catalog - then yes, extractor does not analyze the scopw, when it sees an object with properties it will extract all properties it knows how to handle.