Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

website: Add locale to Leaderboard and organize locale files #868

Merged
merged 3 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions website/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
"sign_in": "Sign In",
"sign_out": "Sign Out",
"terms_of_service": "Terms of Service",
"title": "Open Assistant",
"last_updated_at": "Last updated at: {{val, datetime}}"
"title": "Open Assistant"
}
13 changes: 6 additions & 7 deletions website/public/locales/en/index.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"title": "Open Assistant",
"subtitle": "Conversational AI for everyone.",
"description": "Conversational AI for everyone. An open source project to create a chat enabled GPT LLM run by LAION and contributors around the world.",
"blurb": "We believe we can create a revolution.",
"blurb1": "In the same way that Stable Diffusion helped the world make art and images in new ways, we want to improve the world by providing amazing conversational AI.",
"join_us_title": "Join us",
"join_us_description": "All open source projects begin with people like you. Open source is the belief that if we collaborate we can together gift our knowledge and technology to the world for the benefit of humanity. Are you in? Find us here:",
"faq_title": "Frequently Asked Questions",
"description": "Conversational AI for everyone. An open source project to create a chat enabled GPT LLM run by LAION and contributors around the world.",
"faq_items": {
"q0": "How far along is this project?",
"a0": "We are in the early stages of development, working from established research in applying RLHF to large language models.",
"q1": "Who is behind Open Assistant?",
"a1": "Open Assistant is a project organized by LAION and individuals around the world interested in bringing this technology to everyone."
}
},
"faq_title": "Frequently Asked Questions",
"join_us_description": "All open source projects begin with people like you. Open source is the belief that if we collaborate we can together gift our knowledge and technology to the world for the benefit of humanity. Are you in? Find us here:",
"join_us_title": "Join us",
"subtitle": "Conversational AI for everyone."
}
11 changes: 11 additions & 0 deletions website/public/locales/en/leaderboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
fozziethebeat marked this conversation as resolved.
Show resolved Hide resolved
"daily": "Daily",
"last_updated_at": "Last updated at: {{val, datetime}}",
"leaderboard": "Leaderboard",
"monthly": "Monthly",
"overall": "Overall",
"rank": "Rank",
"score": "Score",
"user": "User",
"weekly": "Weekly"
}
4 changes: 2 additions & 2 deletions website/src/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AnimatedCircles } from "./AnimatedCircles";
import { Container } from "./Container";

export function Hero() {
const { t } = useTranslation("index");
const { t } = useTranslation(["index", "common"]);
const { colorMode } = useColorMode();
const pTextColor = colorMode === "light" ? "text-gray-600" : "text-white";
const fancyTextGradientClasses =
Expand All @@ -17,7 +17,7 @@ export function Hero() {
<Box className="lg:grid lg:grid-cols-12 lg:gap-x-8 lg:gap-y-20">
<Box className="relative mx-auto max-w-2xl lg:col-span-7 lg:max-w-none lg:pt-6 xl:col-span-6">
<Text as="h1" className="text-5xl mb-6 font-bold tracking-tight">
{t("title")}
{t("common:title")}
</Text>
<Text
as="h2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { get } from "src/lib/api";
import { LeaderboardReply, LeaderboardTimeFrame } from "src/types/Leaderboard";
import useSWRImmutable from "swr/immutable";

const columns = [
const getColumns = (t) => [
{
Header: "Rank",
Header: t("rank"),
accessor: "rank",
style: { width: "90px" },
},
{
Header: "Score",
Header: t("score"),
accessor: "leader_score",
style: { width: "90px" },
},
{
Header: "User",
Header: t("user"),
accessor: "display_name",
},
];
Expand All @@ -27,11 +27,13 @@ const columns = [
* Presents a grid of leaderboard entries with more detailed information.
*/
const LeaderboardGridCell = ({ timeFrame }: { timeFrame: LeaderboardTimeFrame }) => {
const { t } = useTranslation();
const { t } = useTranslation(["leaderboard", "common"]);
const { data: reply } = useSWRImmutable<LeaderboardReply>(`/api/leaderboard?time_frame=${timeFrame}`, get, {
revalidateOnMount: true,
});

const columns = useMemo(() => getColumns(t), [t]);

const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
columns,
data: reply?.leaderboard ?? [],
Expand Down
10 changes: 2 additions & 8 deletions website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import Head from "next/head";
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useEffect } from "react";
import { CallToAction } from "src/components/CallToAction";
import { Faq } from "src/components/Faq";
import { Hero } from "src/components/Hero";
import { getTransparentHeaderLayout } from "src/components/Layout";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";

const Home = () => {
const router = useRouter();
const { status } = useSession();
const { t } = useTranslation("index");
const { t } = useTranslation();
useEffect(() => {
if (status === "authenticated") {
router.push("/dashboard");
Expand All @@ -37,10 +37,4 @@ const Home = () => {

Home.getLayout = getTransparentHeaderLayout;

export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["index", "common"])),
},
});

export default Home;
14 changes: 8 additions & 6 deletions website/src/pages/leaderboard.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import { Box, Heading, Tab, TabList, TabPanel, TabPanels, Tabs } from "@chakra-ui/react";
import Head from "next/head";
import { useTranslation } from "next-i18next";
import { getDashboardLayout } from "src/components/Layout";
import { LeaderboardGridCell } from "src/components/LeaderboardGridCell";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
import { LeaderboardTimeFrame } from "src/types/Leaderboard";

const Leaderboard = () => {
const { t } = useTranslation(["leaderboard", "common"]);
return (
<>
<Head>
<title>Leaderboard - Open Assistant</title>
<title>{`${t("leaderboard")} - ${t("common:title")}`}</title>
<meta name="description" content="Leaderboard Rankings" charSet="UTF-8" />
</Head>
<Box display="flex" flexDirection="column">
<Heading fontSize="2xl" fontWeight="bold" pb="4">
Leaderboard
{t("leaderboard")}
</Heading>
<Tabs isFitted isLazy>
<TabList>
<Tab>Daily</Tab>
<Tab>Weekly</Tab>
<Tab>Monthly</Tab>
<Tab>Overall</Tab>
<Tab>{t("daily")}</Tab>
<Tab>{t("weekly")}</Tab>
<Tab>{t("monthly")}</Tab>
<Tab>{t("overall")}</Tab>
</TabList>

<TabPanels>
Expand Down