Skip to content

Commit ed8c1e9

Browse files
committed
WIP(2): Merge branch 'main' into multiLang
1 parent e786334 commit ed8c1e9

File tree

19 files changed

+509
-146
lines changed

19 files changed

+509
-146
lines changed

app/frontend/package-lock.json

Lines changed: 281 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Stack, Pivot, PivotItem } from "@fluentui/react";
2-
2+
import { useTranslation } from "react-i18next";
33
import styles from "./AnalysisPanel.module.css";
44

55
import { SupportingContent } from "../SupportingContent";
@@ -29,7 +29,9 @@ export const AnalysisPanel = ({ answer, activeTab, activeCitation, citationHeigh
2929
const isDisabledCitationTab: boolean = !activeCitation;
3030
const [citation, setCitation] = useState("");
3131

32-
const client = useLogin ? useMsal().instance : undefined;
32+
const client = useLogin ? useMsal().instance : undefined
33+
const { t } = useTranslation();
34+
3335

3436
const fetchCitation = async () => {
3537
const token = client ? await getToken(client) : undefined;
@@ -78,21 +80,21 @@ export const AnalysisPanel = ({ answer, activeTab, activeCitation, citationHeigh
7880
>
7981
<PivotItem
8082
itemKey={AnalysisPanelTabs.ThoughtProcessTab}
81-
headerText="Thought process"
83+
headerText={t("headerTexts.thoughtProcess")}
8284
headerButtonProps={isDisabledThoughtProcessTab ? pivotItemDisabledStyle : undefined}
8385
>
8486
<ThoughtProcess thoughts={answer.context.thoughts || []} />
8587
</PivotItem>
8688
<PivotItem
8789
itemKey={AnalysisPanelTabs.SupportingContentTab}
88-
headerText="Supporting content"
90+
headerText={t("headerTexts.supportingContent")}
8991
headerButtonProps={isDisabledSupportingContentTab ? pivotItemDisabledStyle : undefined}
9092
>
9193
<SupportingContent supportingContent={answer.context.data_points} />
9294
</PivotItem>
9395
<PivotItem
9496
itemKey={AnalysisPanelTabs.CitationTab}
95-
headerText="Citation"
97+
headerText={t("headerTexts.citation")}
9698
headerButtonProps={isDisabledCitationTab ? pivotItemDisabledStyle : undefined}
9799
>
98100
{renderFileViewer()}

app/frontend/src/components/Answer/Answer.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMemo } from "react";
22
import { Stack, IconButton } from "@fluentui/react";
3+
import { useTranslation } from "react-i18next";
34
import DOMPurify from "dompurify";
45

56
import styles from "./Answer.module.css";
@@ -39,7 +40,7 @@ export const Answer = ({
3940
const followupQuestions = answer.context?.followup_questions;
4041
const messageContent = answer.message.content;
4142
const parsedAnswer = useMemo(() => parseAnswerToHtml(messageContent, isStreaming, onCitationClicked), [answer]);
42-
43+
const { t } = useTranslation();
4344
const sanitizedAnswerHtml = DOMPurify.sanitize(parsedAnswer.answerHtml);
4445

4546
return (
@@ -51,15 +52,15 @@ export const Answer = ({
5152
<IconButton
5253
style={{ color: "black" }}
5354
iconProps={{ iconName: "Lightbulb" }}
54-
title="Show thought process"
55+
title={t("tooltips.showThoughtProcess")}
5556
ariaLabel="Show thought process"
5657
onClick={() => onThoughtProcessClicked()}
5758
disabled={!answer.context.thoughts?.length}
5859
/>
5960
<IconButton
6061
style={{ color: "black" }}
6162
iconProps={{ iconName: "ClipboardList" }}
62-
title="Show supporting content"
63+
title={t("tooltips.showSupportingContent")}
6364
ariaLabel="Show supporting content"
6465
onClick={() => onSupportingContentClicked()}
6566
disabled={!answer.context.data_points}

app/frontend/src/components/Answer/SpeechOutputAzure.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
2-
2+
import { useTranslation } from "react-i18next";
33
import { IconButton } from "@fluentui/react";
44

55
interface Props {
@@ -10,6 +10,7 @@ let audio = new Audio();
1010

1111
export const SpeechOutputAzure = ({ url }: Props) => {
1212
const [isPlaying, setIsPlaying] = useState(false);
13+
const { t } = useTranslation();
1314

1415
const startOrStopAudio = async () => {
1516
if (isPlaying) {
@@ -35,7 +36,7 @@ export const SpeechOutputAzure = ({ url }: Props) => {
3536
<IconButton
3637
style={{ color: color }}
3738
iconProps={{ iconName: "Volume3" }}
38-
title="Speak answer"
39+
title={t("tooltips.speakAnswer")}
3940
ariaLabel="Speak answer"
4041
onClick={() => startOrStopAudio()}
4142
disabled={!url}

app/frontend/src/components/Answer/SpeechOutputBrowser.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from "react";
22
import { IconButton } from "@fluentui/react";
3+
import { useTranslation } from "react-i18next";
34

45
interface Props {
56
answer: string;
@@ -28,6 +29,7 @@ const getUtterance = function (text: string) {
2829
};
2930

3031
export const SpeechOutputBrowser = ({ answer }: Props) => {
32+
const { t } = useTranslation();
3133
const [isPlaying, setIsPlaying] = useState<boolean>(false);
3234

3335
const startOrStopSpeech = (answer: string) => {
@@ -63,7 +65,7 @@ export const SpeechOutputBrowser = ({ answer }: Props) => {
6365
style={{ color: color }}
6466
iconProps={{ iconName: "Volume3" }}
6567
title="Speak answer"
66-
ariaLabel="Speak answer"
68+
ariaLabel={t("tooltips.speakAnswer")}
6769
onClick={() => startOrStopSpeech(answer)}
6870
disabled={!synth}
6971
/>

app/frontend/src/components/GPT4VSettings/GPT4VSettings.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,31 @@ export const GPT4VSettings = ({ updateGPT4VInputs, updateUseGPT4V, isUseGPT4V, g
4646
<Checkbox
4747
id={useGPT4VFieldId}
4848
checked={useGPT4V}
49-
label={t("settingsLabels.useGPT4V")}
49+
label={t("labels.useGPT4V")}
5050
onChange={onuseGPT4V}
5151
aria-labelledby={useGPT4VId}
5252
onRenderLabel={(props: ICheckboxProps | undefined) => (
53-
<HelpCallout labelId={useGPT4VId} fieldId={useGPT4VFieldId} helpText={t("toolTipText.useGPT4Vision")} label={props?.label} />
53+
<HelpCallout labelId={useGPT4VId} fieldId={useGPT4VFieldId} helpText={t("helpTexts.useGPT4Vision")} label={props?.label} />
5454
)}
5555
/>
5656
{useGPT4V && (
5757
<Dropdown
5858
id={gpt4VInputFieldId}
5959
selectedKey={vectorFieldOption}
60-
label={t("settingsLabels.gpt4VInput.label")}
60+
label={t("labels.gpt4VInput.label")}
6161
options={[
6262
{
6363
key: GPT4VInput.TextAndImages,
64-
text: t("settingsLabels.gpt4VInput.options.textAndImages")
64+
text: t("labels.gpt4VInput.options.textAndImages")
6565
},
66-
{ text: t("settingsLabels.gpt4VInput.options.images"), key: GPT4VInput.Images },
67-
{ text: t("settingsLabels.gpt4VInput.options.texts"), key: GPT4VInput.Texts }
66+
{ text: t("labels.gpt4VInput.options.images"), key: GPT4VInput.Images },
67+
{ text: t("labels.gpt4VInput.options.texts"), key: GPT4VInput.Texts }
6868
]}
6969
required
7070
onChange={onSetGPT4VInput}
7171
aria-labelledby={gpt4VInputId}
7272
onRenderLabel={(props: IDropdownProps | undefined) => (
73-
<HelpCallout labelId={gpt4VInputId} fieldId={gpt4VInputFieldId} helpText={t("toolTipText.gpt4VisionInputs")} label={props?.label} />
73+
<HelpCallout labelId={gpt4VInputId} fieldId={gpt4VInputFieldId} helpText={t("helpTexts.gpt4VisionInputs")} label={props?.label} />
7474
)}
7575
/>
7676
)}

app/frontend/src/components/HelpCallout/HelpCallout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export const HelpCallout = (props: IHelpCalloutProps): JSX.Element => {
3030
<label id={props.labelId} htmlFor={props.fieldId}>
3131
{props.label}
3232
</label>
33-
<IconButton id={iconButtonId} iconProps={iconProps} title="Info" ariaLabel="Info" onClick={toggleIsCalloutVisible} styles={iconButtonStyles} />
33+
<IconButton id={iconButtonId} iconProps={iconProps} title={t("tooltips.info")} ariaLabel="Info" onClick={toggleIsCalloutVisible} styles={iconButtonStyles} />
3434
</Stack>
3535
{isCalloutVisible && (
3636
<Callout target={"#" + iconButtonId} setInitialFocus onDismiss={toggleIsCalloutVisible} ariaDescribedBy={descriptionId} role="alertdialog">
3737
<Stack tokens={stackTokens} horizontalAlign="start" styles={labelCalloutStackStyles}>
3838
<span id={descriptionId}>{props.helpText}</span>
39-
<DefaultButton onClick={toggleIsCalloutVisible}>{t("settingsLabels.closeButton")}</DefaultButton>
39+
<DefaultButton onClick={toggleIsCalloutVisible}>{t("labels.closeButton")}</DefaultButton>
4040
</Stack>
4141
</Callout>
4242
)}

app/frontend/src/components/MarkdownViewer/MarkdownViewer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState, useEffect } from "react";
2+
import { useTranslation } from "react-i18next";
23
import { marked } from "marked";
34
import styles from "./MarkdownViewer.module.css";
45
import { Spinner, SpinnerSize, MessageBar, MessageBarType, Link, IconButton } from "@fluentui/react";
@@ -11,6 +12,7 @@ export const MarkdownViewer: React.FC<MarkdownViewerProps> = ({ src }) => {
1112
const [content, setContent] = useState<string>("");
1213
const [isLoading, setIsLoading] = useState<boolean>(true);
1314
const [error, setError] = useState<Error | null>(null);
15+
const { t } = useTranslation();
1416

1517
/**
1618
* Anchor links are not handled well by 'marked' and result in HTTP 404 errors as the URL they point to does not exist.
@@ -66,7 +68,7 @@ export const MarkdownViewer: React.FC<MarkdownViewerProps> = ({ src }) => {
6668
style={{ color: "black" }}
6769
iconProps={{ iconName: "Save" }}
6870
title="Save"
69-
ariaLabel="Save"
71+
ariaLabel={t("tooltips.save")}
7072
href={src}
7173
download
7274
/>

app/frontend/src/components/QuestionInput/QuestionInput.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState, useEffect, useContext } from "react";
22
import { Stack, TextField } from "@fluentui/react";
33
import { Button, Tooltip } from "@fluentui/react-components";
44
import { Send28Filled } from "@fluentui/react-icons";
5+
import { useTranslation } from "react-i18next";
56
import { useMsal } from "@azure/msal-react";
67

78
import styles from "./QuestionInput.module.css";
@@ -21,7 +22,8 @@ interface Props {
2122
export const QuestionInput = ({ onSend, disabled, placeholder, clearOnSend, initQuestion, showSpeechInput }: Props) => {
2223
const [question, setQuestion] = useState<string>("");
2324
const { loggedIn } = useContext(LoginContext);
24-
25+
const { t } = useTranslation();
26+
2527
useEffect(() => {
2628
initQuestion && setQuestion(initQuestion);
2729
}, [initQuestion]);
@@ -74,7 +76,7 @@ export const QuestionInput = ({ onSend, disabled, placeholder, clearOnSend, init
7476
onKeyDown={onEnterPress}
7577
/>
7678
<div className={styles.questionInputButtonsContainer}>
77-
<Tooltip content="Submit question" relationship="label">
79+
<Tooltip content={t("tooltips.submitQuestion")} relationship="label">
7880
<Button size="large" icon={<Send28Filled primaryFill="rgba(115, 118, 225, 1)" />} disabled={sendQuestionDisabled} onClick={sendQuestion} />
7981
</Tooltip>
8082
</div>

app/frontend/src/components/QuestionInput/SpeechInput.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SetStateAction, useState } from "react";
22
import { Button, Tooltip } from "@fluentui/react-components";
33
import { Mic28Filled } from "@fluentui/react-icons";
4+
import { useTranslation } from "react-i18next";
45
import styles from "./QuestionInput.module.css";
56

67
interface Props {
@@ -31,8 +32,8 @@ try {
3132
}
3233

3334
export const SpeechInput = ({ updateQuestion }: Props) => {
35+
const { t } = useTranslation();
3436
const [isRecording, setIsRecording] = useState<boolean>(false);
35-
3637
const startRecording = () => {
3738
if (speechRecognition == null) {
3839
console.error("SpeechRecognition not supported");
@@ -85,14 +86,14 @@ export const SpeechInput = ({ updateQuestion }: Props) => {
8586
<>
8687
{!isRecording && (
8788
<div className={styles.questionInputButtonsContainer}>
88-
<Tooltip content="Ask question with voice" relationship="label">
89+
<Tooltip content={t("tooltips.askWithVoice")} relationship="label">
8990
<Button size="large" icon={<Mic28Filled primaryFill="rgba(115, 118, 225, 1)" />} onClick={startRecording} />
9091
</Tooltip>
9192
</div>
9293
)}
9394
{isRecording && (
9495
<div className={styles.questionInputButtonsContainer}>
95-
<Tooltip content="Stop recording question" relationship="label">
96+
<Tooltip content={t("tooltips.stopRecording")} relationship="label">
9697
<Button size="large" icon={<Mic28Filled primaryFill="rgba(250, 0, 0, 0.7)" />} disabled={!isRecording} onClick={stopRecording} />
9798
</Tooltip>
9899
</div>

0 commit comments

Comments
 (0)