Skip to content

Commit

Permalink
feat: 언어설정에 한자간체, 한자번체 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-dong-su committed Mar 4, 2024
1 parent f6fae5d commit 959136c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/web/src/apis/openApi/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ export const postOpenAIAPI = async (messages: Message[]) => {
}
);

console.log(response.data.choices[0].message.content);

return JSON.parse(response.data.choices[0].message.content);
};
6 changes: 3 additions & 3 deletions packages/web/src/apis/openApi/mutations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export const usePostTranslateGPT = () => {
targetLang: string;
}) => {
const userContent = title
? `Translate the following text to ${targetLang} and format the output as requested: { title: "${title}", content: "${content}" }`
: `Translate the following text to ${targetLang} and format the output as requested: { content: "${content}" }`;
? `Translate the following text to ${targetLang} and format the output as requested: { title: ${title}, content: ${content} }`
: `Translate the following text to ${targetLang} and format the output as requested: { content: ${content} }`;

const messages: Message[] = [
{
role: 'system',
content:
'You are a translator assistant that provides JSON output. Please ensure the translation output is in the format of {title: "translated text", content: "translated text"} if title is provided, otherwise just {content: "translated text"}.',
'You are a translator assistant that provides JSON output. Please ensure the translation output is in the format of {title: translated text, content: translated text} if title is provided, otherwise just {content: translated text}.',
},
{
role: 'user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ export default function Language() {
<Spacing size={8} direction="horizontal" />
<span>English</span>
</Flex>
{/* Simplified Chinese */}
<Flex className="py-12" onClick={() => setLanguage('zh-CN')}>
<CircleCheckbox checked={language === 'zh-CN'} />
<Spacing size={8} direction="horizontal" />
<span>简体中文</span>
</Flex>
{/* Traditional Chinese */}
<Flex className="py-12" onClick={() => setLanguage('zh-TW')}>
<CircleCheckbox checked={language === 'zh-TW'} />
<Spacing size={8} direction="horizontal" />
<span>繁體中文</span>
</Flex>
<ButtonGroup>
<Button onClick={handleSubmit} disabled={prevLanguage === language}>
{t('confirm')}
Expand Down

0 comments on commit 959136c

Please sign in to comment.