feat(desktop): add i18n infrastructure with react-intl (#8105)
This commit is contained in:
@@ -2,6 +2,18 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Copy } from './icons';
|
||||
import { defineMessages, useIntl } from '../i18n';
|
||||
|
||||
const i18n = defineMessages({
|
||||
copied: {
|
||||
id: 'messageCopyLink.copied',
|
||||
defaultMessage: 'Copied!',
|
||||
},
|
||||
copy: {
|
||||
id: 'messageCopyLink.copy',
|
||||
defaultMessage: 'Copy',
|
||||
},
|
||||
});
|
||||
|
||||
interface MessageCopyLinkProps {
|
||||
text: string;
|
||||
@@ -9,6 +21,7 @@ interface MessageCopyLinkProps {
|
||||
}
|
||||
|
||||
export default function MessageCopyLink({ text, contentRef }: MessageCopyLinkProps) {
|
||||
const intl = useIntl();
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const handleCopy = async () => {
|
||||
@@ -54,7 +67,7 @@ export default function MessageCopyLink({ text, contentRef }: MessageCopyLinkPro
|
||||
className="flex font-mono items-center gap-1 text-xs text-text-secondary hover:cursor-pointer hover:text-text-primary transition-all duration-200 opacity-0 group-hover:opacity-100 -translate-y-4 group-hover:translate-y-0"
|
||||
>
|
||||
<Copy className="h-3 w-3" />
|
||||
<span>{copied ? 'Copied!' : 'Copy'}</span>
|
||||
<span>{copied ? intl.formatMessage(i18n.copied) : intl.formatMessage(i18n.copy)}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user