Skip to content

Commit

Permalink
fix: reflect correctly the translation key in Timestamp component
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Jun 26, 2024
1 parent 579953c commit 741e9ce
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions docusaurus/docs/React/guides/date-time-formatting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,6 @@ Now we can apply custom configuration in all the translation JSON files. It coul
}
```

Besides overriding the formatting parameters above, we can customize the translation key via `timestampTranslationKey` prop in all of the above mentioned components (`DateSeparator`, `EventComponent`, `MessageTimestamp`).

```tsx
import { MessageTimestampProps, MessageTimestamp } from 'stream-chat-react';

const CustomMessageTimestamp = (props: MessageTimestampProps) => (
<MessageTimestamp {...props} timestampTranslationKey='customTimestampTranslationKey' />
);
```

##### Understanding the formatting syntax

Once the default prop values are nullified, we override the default formatting rules in the JSON translation value. We can take a look at an example of German translation for SystemMessage:
Expand Down
2 changes: 1 addition & 1 deletion src/components/Message/Timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function Timestamp(props: TimestampProps) {
messageCreatedAt: normalizedTimestamp,
t,
tDateTimeParser,
timestampTranslationKey: 'timestamp/Timestamp',
timestampTranslationKey: 'timestamp/MessageTimestamp',
}),
[calendar, calendarFormats, format, formatDate, normalizedTimestamp, t, tDateTimeParser],
);
Expand Down

0 comments on commit 741e9ce

Please sign in to comment.