Files
owncast/web/components/chat/ChatPartMessage/ChatPartMessage.tsx
Copilot 275339bdf0 Add localization support for chat message components with enhanced Translation component (#4560)
* Initial plan

* Add localization support for chat message components

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Update chat message localization to use string interpolation

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Restore original styling while preserving string interpolation

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Separate styling from variables in translation templates

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Revert to concatenation approach for chat message localization

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Add id property to Translation component and restore missing CSS classes and IDs

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Javascript formatting autofixes

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gabek <414923+gabek@users.noreply.github.com>
Co-authored-by: Gabe Kangas <gabek@real-ity.com>
Co-authored-by: Owncast <owncast@owncast.online>
2025-09-16 00:13:13 -07:00

51 lines
1.4 KiB
TypeScript

import { FC } from 'react';
import dynamic from 'next/dynamic';
import { ModerationBadge } from '../ChatUserBadge/ModerationBadge';
import { Translation } from '../../ui/Translation/Translation';
import { Localization } from '../../../types/localization';
import styles from './ChatPartMessage.module.scss';
// Lazy loaded components
const UsergroupDeleteOutlined = dynamic(() => import('@ant-design/icons/UsergroupDeleteOutlined'), {
ssr: false,
});
export type ChatPartMessageProps = {
isAuthorModerator: boolean;
userColor: number;
displayName: string;
};
export const ChatPartMessage: FC<ChatPartMessageProps> = ({
isAuthorModerator,
userColor,
displayName,
}) => {
const color = `var(--theme-color-users-${userColor})`;
return (
<div className={styles.root}>
<span style={{ color }}>
<span className={styles.icon}>
<UsergroupDeleteOutlined />
</span>
{isAuthorModerator && (
<span className={styles.moderatorBadge}>
<ModerationBadge userColor={userColor} />
</span>
)}
<span className={styles.partMessage}>
<span className={styles.user}>{displayName}</span>
<span> </span>
<Translation
translationKey={Localization.Frontend.Chat.userLeft}
defaultText="left the chat."
/>
</span>
</span>
</div>
);
};