Extract more strings for localization (#1417)

Only English and Spanish translations added.
This commit is contained in:
GuilleHoardings
2023-02-11 12:12:50 +09:00
committed by GitHub
parent 8fb31a3a54
commit 00c58975cf
13 changed files with 221 additions and 87 deletions
+6 -4
View File
@@ -11,6 +11,7 @@ import {
Textarea,
useDisclosure,
} from "@chakra-ui/react";
import { useTranslation } from "next-i18next";
import { useState } from "react";
interface SkipButtonProps extends ButtonProps {
@@ -18,6 +19,7 @@ interface SkipButtonProps extends ButtonProps {
}
export const SkipButton = ({ onSkip, ...props }: SkipButtonProps) => {
const { t } = useTranslation(["common", "tasks"]);
const { isOpen, onOpen: showModal, onClose: closeModal } = useDisclosure();
const [value, setValue] = useState("");
@@ -30,25 +32,25 @@ export const SkipButton = ({ onSkip, ...props }: SkipButtonProps) => {
return (
<>
<Button size="lg" variant="outline" onClick={showModal} {...props}>
Skip
{t("skip")}
</Button>
<Modal isOpen={isOpen} onClose={closeModal}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Skip</ModalHeader>
<ModalHeader>{t("skip")}</ModalHeader>
<ModalCloseButton />
<ModalBody>
<Textarea
value={value}
onChange={(e) => setValue(e.target.value)}
resize="none"
placeholder="Any feedback on this task?"
placeholder={t("tasks:any_feedback_on_this_task")}
/>
</ModalBody>
<ModalFooter>
<Button colorScheme="blue" mr={3} onClick={onSubmit}>
Send
{t("send")}
</Button>
</ModalFooter>
</ModalContent>
@@ -1,4 +1,5 @@
import { Box, Grid, GridItem, Text, useColorModeValue } from "@chakra-ui/react";
import { useTranslation } from "next-i18next";
import React from "react";
import { useState } from "react";
import { LikertButtons } from "src/components/Buttons/LikertButtons";
@@ -18,160 +19,154 @@ interface LabelInfo {
inverted: boolean;
}
const getLabelInfo = (label: string): LabelInfo => {
const getLabelInfo = (label: string, t: (key: string) => string): LabelInfo => {
switch (label) {
case "spam":
return {
zeroText: "Not Spam",
zeroDescription: ["Suitable for training Open Assistant."],
oneText: "Spam",
zeroText: t("not_spam"),
zeroDescription: [t("not_spam.explanation")],
oneText: t("spam"),
oneDescription: [
"Seems to be intentionally low-quality or irrelevant",
'We consider the following unwanted content as spam: trolling, intentional undermining of our purpose, illegal material, material that violates our code of conduct, and other things that are inappropriate for our dataset. We collect these under the common heading of "spam".',
"This is not an assessment of whether this message is the best possible answer. Especially for prompts or user-replies, we very much want to retain all kinds of responses in the dataset, so that the assistant can learn to reply appropriately.",
"Please mark this text as spam only if it is clearly unsuited to be part of our dataset, as outlined above, and try not to make any subjective value-judgments beyond that.",
t("spam.one_desc.line_1"),
t("spam.one_desc.line_2"),
t("spam.one_desc.line_3"),
t("spam.one_desc.line_4"),
],
inverted: true,
};
case "fails_task":
return {
zeroText: "Follows Instructions",
zeroText: t("follows_instructions"),
zeroDescription: [],
oneText: "Fails Task",
oneDescription: ["Fails to follow the correct instruction / task"],
oneText: t("fails_task"),
oneDescription: [t("fails_task.one_desc")],
inverted: true,
};
case "not_appropriate":
return {
zeroText: "Appropriate",
zeroText: t("appropriate"),
zeroDescription: [],
oneText: "Inappropriate",
oneDescription: ["Inappropriate for customer assistant"],
oneText: t("inappropriate"),
oneDescription: [t("inappropriate.one_desc")],
inverted: true,
};
case "violence":
return {
zeroText: "Harmless",
zeroText: t("harmless"),
zeroDescription: [],
oneText: "Violent",
oneDescription: ["Encourages or fails to discourage violence/abuse/terrorism/self-harm"],
oneText: t("violent"),
oneDescription: [t("violent.one_desc")],
inverted: true,
};
case "excessive_harm":
return {
zeroText: "Safe",
zeroText: t("safe"),
zeroDescription: [],
oneText: "Harmful",
oneDescription: [
"Content likely to cause excessive harm not justifiable in the context",
"Harm refers to physical or mental damage or injury to someone or something. Excessive refers to a reasonable threshold of harm in the context, for instance damaging skin is not excessive in the context of surgery.",
],
oneText: t("harmful"),
oneDescription: [t("harmful.one_desc.line_1"), t("harmful.one_desc.line_2")],
inverted: true,
};
case "sexual_content":
return {
zeroText: "Non Sexual",
zeroText: t("non_sexual"),
zeroDescription: [],
oneText: "Sexual",
oneDescription: ["Contains sexual content"],
oneText: t("sexual"),
oneDescription: [t("sexual.one_desc")],
inverted: true,
};
case "toxicity":
return {
zeroText: "Polite",
zeroText: t("polite"),
zeroDescription: [],
oneText: "Rude",
oneDescription: ["Contains rude, abusive, profane or insulting content"],
oneText: t("rude"),
oneDescription: [t("rude.one_desc")],
inverted: true,
};
case "moral_judgement":
return {
zeroText: "Non-Judgemental",
zeroText: t("non_judgemental"),
zeroDescription: [],
oneText: "Judgemental",
oneDescription: ["Expresses moral judgement"],
oneText: t("judgemental"),
oneDescription: [t("judgemental.one_desc")],
inverted: true,
};
case "political_content":
return {
zeroText: "Apolitical",
zeroText: t("apolitical"),
zeroDescription: [],
oneText: "Political",
oneDescription: ["Expresses political views"],
oneText: t("political"),
oneDescription: [t("political.one_desc")],
inverted: true,
};
case "humor":
return {
zeroText: "Serious",
zeroText: t("serious"),
zeroDescription: [],
oneText: "Humorous",
oneDescription: ["Contains humorous content including sarcasm"],
oneText: t("humorous"),
oneDescription: [t("humorous.one_desc")],
inverted: false,
};
case "hate_speech":
return {
zeroText: "Safe",
zeroText: t("safe"),
zeroDescription: [],
oneText: "Hateful",
oneDescription: [
"Content is abusive or threatening and expresses prejudice against a protected characteristic",
"Prejudice refers to preconceived views not based on reason. Protected characteristics include gender, ethnicity, religion, sexual orientation, and similar characteristics.",
],
oneText: t("hateful"),
oneDescription: [t("hateful.one_desc.line_1"), t("hateful.one_desc.line_2")],
inverted: true,
};
case "threat":
return {
zeroText: "Safe",
zeroText: t("safe"),
zeroDescription: [],
oneText: "Threatening",
oneDescription: ["Contains a threat against a person or persons"],
oneText: t("threatening"),
oneDescription: [t("threatening.one_desc")],
inverted: true,
};
case "misleading":
return {
zeroText: "Accurate",
zeroText: t("accurate"),
zeroDescription: [],
oneText: "Misleading",
oneDescription: ["Contains text which is incorrect or misleading"],
oneText: t("misleading"),
oneDescription: [t("misleading.one_desc")],
inverted: true,
};
case "helpfulness":
return {
zeroText: "Unhelpful",
zeroText: t("unhelpful"),
zeroDescription: [],
oneText: "Helpful",
oneDescription: ["Completes the task to a high standard"],
oneText: t("helpful"),
oneDescription: [t("helpful.one_desc")],
inverted: false,
};
case "creative":
return {
zeroText: "Boring",
zeroText: t("boring"),
zeroDescription: [],
oneText: "Creative",
oneDescription: ["Expresses creativity in responding to the task"],
oneText: t("creative"),
oneDescription: [t("creative.one_desc")],
inverted: false,
};
case "pii":
return {
zeroText: "Clean",
zeroText: t("clean"),
zeroDescription: [],
oneText: "Contains PII",
oneDescription: ["Contains personally identifying information"],
oneText: t("contains_pii"),
oneDescription: [t("contains_pii.one_desc")],
inverted: false,
};
case "quality":
return {
zeroText: "Low Quality",
zeroText: t("low_quality"),
zeroDescription: [],
oneText: "High Quality",
oneText: t("high_quality"),
oneDescription: [],
inverted: false,
};
case "creativity":
return {
zeroText: "Ordinary",
zeroText: t("ordinary"),
zeroDescription: [],
oneText: "Creative",
oneText: t("creative"),
oneDescription: [],
inverted: false,
};
@@ -187,6 +182,7 @@ const getLabelInfo = (label: string): LabelInfo => {
};
export const LabelLikertGroup = ({ labelIDs, onChange, isEditable = true }: LabelInputGroupProps) => {
const { t } = useTranslation("labelling");
const [labelValues, setLabelValues] = useState<number[]>(Array.from({ length: labelIDs.length }).map(() => null));
const cardColor = useColorModeValue("gray.50", "gray.800");
@@ -194,7 +190,7 @@ export const LabelLikertGroup = ({ labelIDs, onChange, isEditable = true }: Labe
return (
<Grid templateColumns={"minmax(min-content, 30em)"} rowGap={2}>
{labelIDs.map((labelId, idx) => {
const { zeroText, oneText, zeroDescription, oneDescription, inverted } = getLabelInfo(labelId);
const { zeroText, oneText, zeroDescription, oneDescription, inverted } = getLabelInfo(labelId, t);
let textA = zeroText;
let textB = oneText;
@@ -1,4 +1,5 @@
import { Box, Flex, IconButton, Progress, Tooltip, useColorModeValue } from "@chakra-ui/react";
import { useTranslation } from "next-i18next";
import { Edit2 } from "lucide-react";
import { SkipButton } from "src/components/Buttons/Skip";
import { SubmitButton } from "src/components/Buttons/Submit";
@@ -25,13 +26,14 @@ export const TaskControls = ({
onSubmit,
onSkip,
}: TaskControlsProps) => {
const { t } = useTranslation();
const backgroundColor = useColorModeValue("white", "gray.800");
return (
<Box width="full" bg={backgroundColor} borderRadius="xl" shadow="base">
{isLoading && <Progress size="sm" isIndeterminate />}
<Flex p="6" gap="4" direction={["column", "row"]}>
<TaskInfo id={task.id} output="Submit your answer" />
<TaskInfo id={task.id} output={t("submit_your_answer")} />
<Flex width={["full", "fit-content"]} justify="center" ml="auto" gap={2}>
{taskStatus.mode === "EDIT" ? (
<>
@@ -42,7 +44,7 @@ export const TaskControls = ({
isDisabled={taskStatus.replyValidity === "INVALID"}
onClick={onReview}
>
Review
{t("review")}
</SubmitButton>
</>
) : (
@@ -56,7 +58,7 @@ export const TaskControls = ({
isDisabled={taskStatus.mode === "SUBMITTED"}
onClick={onSubmit}
>
Submit
{t("submit")}
</SubmitButton>
</>
)}
+4 -2
View File
@@ -1,4 +1,5 @@
import { Box, Flex, Text, TextProps, useColorModeValue } from "@chakra-ui/react";
import { useTranslation } from "next-i18next";
const TitleClasses: TextProps = {
fontWeight: "semibold",
@@ -13,6 +14,7 @@ const LabelClasses: TextProps = {
};
export const TaskInfo = ({ id, output }: { id: string; output: string }) => {
const { t } = useTranslation();
const titleColor = useColorModeValue("gray.700", "gray.400");
return (
@@ -20,7 +22,7 @@ export const TaskInfo = ({ id, output }: { id: string; output: string }) => {
<Flex direction="column">
<Flex alignItems="center" gap="2">
<Text {...TitleClasses} color={titleColor}>
Prompt
{t("prompt")}
</Text>
<Text {...LabelClasses} data-cy="task-id">
{id}
@@ -28,7 +30,7 @@ export const TaskInfo = ({ id, output }: { id: string; output: string }) => {
</Flex>
<Flex alignItems="center" gap="2">
<Text {...TitleClasses} color={titleColor}>
Output
{t("output")}
</Text>
<Text {...LabelClasses}>{output}</Text>
</Flex>
+4 -4
View File
@@ -5,7 +5,7 @@ import { useSession } from "next-auth/react";
import React from "react";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
import { Pencil } from "lucide-react";
import { useTranslation } from "react-i18next";
import { useTranslation } from "next-i18next";
import { SurveyCard } from "src/components/Survey/SurveyCard";
import { get } from "src/lib/api";
import { getTypeSafei18nKey } from "src/lib/i18n";
@@ -41,15 +41,15 @@ export default function Account() {
<Title>{t("your_account")}</Title>
<Divider />
<Grid gridTemplateColumns="repeat(2, max-content)" alignItems="center" gap={6} py={4}>
<Text as="b">Username</Text>
<Text as="b">{t("username")}</Text>
<Flex gap={2}>
{session.user.name ?? "(No username)"}
{session.user.name ?? t("no_username")}
<Link href="/account/edit">
<Icon boxSize={5} as={Pencil} size="1em" />
</Link>
</Flex>
<Text as="b">Email</Text>
<Text>{session.user.email ?? "(No Email)"}</Text>
<Text>{session.user.email ?? t("no_email")}</Text>
</Grid>
</SurveyCard>
<SurveyCard>