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

Localization #899

Merged
merged 34 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a0fbfe8
Localization initialization
DLatouche Aug 19, 2022
09c1131
Add formatted component to translate with inside component
DLatouche Aug 29, 2022
7cf0deb
Add translations for 404 and 505 page
DLatouche Aug 29, 2022
b38b972
Add menu translation, update formatted component for <br/> component
DLatouche Aug 29, 2022
9501bca
Add translations of trade-clipboard
DLatouche Aug 30, 2022
5264a78
Add translations of pools
DLatouche Aug 30, 2022
6678ccd
Add translations of pool
DLatouche Aug 31, 2022
5491b6b
Add translation of assets
DLatouche Aug 31, 2022
7d10bb7
Add translations for toasts
DLatouche Sep 1, 2022
27f4e92
Move error translations to root of json file
DLatouche Sep 1, 2022
23b9e96
Review of french translations
DLatouche Sep 4, 2022
98e8844
Remove unused import
DLatouche Sep 19, 2022
c013d21
Merge branch 'jonator/redesign/assets-page' into dorian/localization
DLatouche Oct 5, 2022
0aa684e
Add some missing translations
DLatouche Oct 6, 2022
a3edd6b
fix typo
DLatouche Oct 7, 2022
d22cc73
Add language setting and language-select
DLatouche Oct 7, 2022
1f55e33
Remove unnecessary comments
DLatouche Oct 7, 2022
1ca1fa1
fix menu dropdown icon
DLatouche Oct 7, 2022
c5ac4d0
use tailwind name
DLatouche Oct 10, 2022
3e8def7
refractor icon dropdown
DLatouche Oct 10, 2022
34b78ff
Add icon dropdown for mobile
DLatouche Oct 10, 2022
df23ab9
Add method getLabel in User setting to get translated label
DLatouche Oct 10, 2022
3fee5a8
fix dropdown label, fix dependency of create pool button
DLatouche Oct 10, 2022
ce2fad1
Fix dayjs translation
DLatouche Oct 10, 2022
1cafbf3
Add translation for pool creation
DLatouche Oct 11, 2022
bc6df04
Merge branch 'jonator/redesign/assets-page' into dorian/localization
DLatouche Oct 11, 2022
6f30a80
remove package-lock.json
DLatouche Oct 13, 2022
692febf
Add documentation for Formatted
DLatouche Oct 16, 2022
84b3a2b
add t in useMemo dependencies
DLatouche Oct 17, 2022
985ba58
remove unused comments
DLatouche Oct 17, 2022
b2119b1
refractor ShowDust constructor
DLatouche Oct 17, 2022
c501075
language-select refactoring, add generic component (IconDropdown), fi…
DLatouche Oct 19, 2022
d264ec6
Merge branch 'feat/redesign' into dorian/localization
DLatouche Oct 20, 2022
b0c4dde
Improve localization imports
DLatouche Oct 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 61 additions & 51 deletions packages/web/components/alert/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Image from "next/image";
import { FunctionComponent } from "react";
import { useTranslation } from "react-multi-lang";
import { toast, ToastOptions } from "react-toastify";
import { Alert, ToastType } from "./types";

Expand Down Expand Up @@ -48,63 +49,72 @@ export function displayToast(
}
}

const LoadingToast: FunctionComponent<Alert> = ({ message, caption }) => (
<div className="flex items-center md:gap-2 gap-3">
<div className="flex items-center animate-spin h-8 w-8 shrink-0">
<Image
alt="loading"
src="/icons/loading-blue.svg"
height={32}
width={32}
/>
const LoadingToast: FunctionComponent<Alert> = ({ message, caption }) => {
const t = useTranslation();
return (
<div className="flex items-center md:gap-2 gap-3">
<div className="flex items-center animate-spin h-8 w-8 shrink-0">
<Image
alt="loading"
src="/icons/loading-blue.svg"
height={32}
width={32}
/>
</div>
<div className="text-white-high">
<h6 className="mb-2 md:text-base text-lg">{t(message)}</h6>
{caption && <p className="md:text-xs text-sm">{t(caption)}</p>}
</div>
</div>
<div className="text-white-high">
<h6 className="mb-2 md:text-base text-lg">{message}</h6>
{caption && <p className="md:text-xs text-sm">{caption}</p>}
</div>
</div>
);
);
};

const ErrorToast: FunctionComponent<Alert> = ({ message, caption }) => (
<div className="flex items-center md:gap-2 gap-3">
<div className="w-8 h-8 shrink-0">
<Image alt="failed" src="/icons/error-x.svg" height={32} width={32} />
</div>
<div className="text-white-high">
<h6 className="mb-2 md:text-base text-lg">{message}</h6>
{caption && <p className="md:text-xs text-sm">{caption}</p>}
const ErrorToast: FunctionComponent<Alert> = ({ message, caption }) => {
const t = useTranslation();
return (
<div className="flex items-center md:gap-2 gap-3">
<div className="w-8 h-8 shrink-0">
<Image alt="failed" src="/icons/error-x.svg" height={32} width={32} />
</div>
<div className="text-white-high">
<h6 className="mb-2 md:text-base text-lg">{t(message)}</h6>
{caption && <p className="md:text-xs text-sm">{t(caption)}</p>}
</div>
</div>
</div>
);
);
};

const SuccessToast: FunctionComponent<Alert> = ({
message,
learnMoreUrl,
learnMoreUrlCaption,
}) => (
<div className="flex items-center md:gap-2 gap-3">
<div className="w-8 h-8 shrink-0">
<Image alt="b" src="/icons/check-circle.svg" height={32} width={32} />
</div>
<div className="text-white-high">
<h6 className="mb-2 md:text-base text-lg">{message}</h6>
{learnMoreUrl && (
<a
target="__blank"
href={learnMoreUrl}
className="md:text-xs text-sm inline hover:opacity-75 cursor-pointer"
>
{learnMoreUrlCaption ?? "Learn more"}
<div className="inline-block ml-2 mb-0.75">
<Image
alt="link"
src="/icons/link-deco.svg"
height={12}
width={12}
/>
</div>
</a>
)}
}) => {
const t = useTranslation();
return (
<div className="flex items-center md:gap-2 gap-3">
<div className="w-8 h-8 shrink-0">
<Image alt="b" src="/icons/check-circle.svg" height={32} width={32} />
</div>
<div className="text-white-high">
<h6 className="mb-2 md:text-base text-lg">{t(message)}</h6>
{learnMoreUrl && (
<a
target="__blank"
href={learnMoreUrl}
className="md:text-xs text-sm inline hover:opacity-75 cursor-pointer"
>
{learnMoreUrlCaption ?? t("Learn more")}
<div className="inline-block ml-2 mb-0.75">
<Image
alt="link"
src="/icons/link-deco.svg"
height={12}
width={12}
/>
</div>
</a>
)}
</div>
</div>
</div>
);
);
};
40 changes: 22 additions & 18 deletions packages/web/components/buttons/show-more.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@ import { FunctionComponent } from "react";
import classNames from "classnames";
import { ToggleProps } from "../control";
import { CustomClasses } from "../types";
import { useTranslation } from "react-multi-lang";

export const ShowMoreButton: FunctionComponent<ToggleProps & CustomClasses> = ({
isOn,
onToggle,
className,
}) => (
<button
className={classNames("flex flex-col gap-1 button", className)}
onClick={() => onToggle(isOn)}
>
<span className="body2 md:caption text-white-mid">
{isOn ? "View less" : "View all"}
</span>
<div className="m-auto">
<Image
alt={isOn ? "view less" : "view all"}
src={isOn ? "/icons/chevron-up.svg" : "/icons/chevron-down.svg"}
height={14}
width={14}
/>
</div>
</button>
);
}) => {
const t = useTranslation();
return (
<button
className={classNames("flex flex-col gap-1 button", className)}
onClick={() => onToggle(isOn)}
>
<span className="body2 md:caption text-white-mid">
{isOn ? t("components.show.less") : t("components.show.more")}
</span>
<div className="m-auto">
<Image
alt={isOn ? t("components.show.less") : t("components.show.more")}
src={isOn ? "/icons/chevron-up.svg" : "/icons/chevron-down.svg"}
height={14}
width={14}
/>
</div>
</button>
);
};
48 changes: 27 additions & 21 deletions packages/web/components/cards/go-superfluid.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { FunctionComponent } from "react";
import { useTranslation } from "react-multi-lang";
import { Formatted } from "../localization";
import { MobileProps } from "../types";

export const GoSuperfluidCard: FunctionComponent<
{
goSuperfluid: () => void;
} & MobileProps
> = ({ goSuperfluid, isMobile = false }) => (
<div className="mt-5 bg-card p-5 rounded-2xl flex md:flex-col gap-2 items-center justify-between font-body">
<div>
<div className="text-base font-semibold text-white-high">
{isMobile
? "You're not Superfluid Staking"
: "Superfluid Staking Inactive"}
</div>
<div className="mt-2 text-sm font-medium text-iconDefault">
You have superfluid eligible bonded liquidity.
<br />
Choose a Superfluid Staking validator to earn additional rewards.
> = ({ goSuperfluid, isMobile = false }) => {
const t = useTranslation();
return (
<div className="mt-5 bg-card p-5 rounded-2xl flex md:flex-col gap-2 items-center justify-between font-body">
<div>
<div className="text-base font-semibold text-white-high">
{isMobile
? t("pool.goSuperfluid.titleMobile")
: t("pool.goSuperfluid.title")}
</div>
<div className="mt-2 text-sm font-medium text-iconDefault">
<Formatted
translationKey="pool.goSuperfluid.info"
components={{ "<br/>": <br /> }}
/>
</div>
</div>
<button
className="button bg-superfluid rounded-lg py-2 px-8 text-white-high font-semibold text-sm shadow-elevation-04dp"
type="button"
onClick={goSuperfluid}
>
{t("pool.goSuperfluid.button")}
</button>
</div>
<button
className="button bg-superfluid rounded-lg py-2 px-8 text-white-high font-semibold text-sm shadow-elevation-04dp"
type="button"
onClick={goSuperfluid}
>
Go Superfluid
</button>
</div>
);
);
};
8 changes: 6 additions & 2 deletions packages/web/components/cards/pool-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PoolAssetInfo } from "../assets/types";
import { Metric } from "../types";
import { CustomClasses } from "../types";
import { useWindowSize } from "../../hooks";
import { useTranslation } from "react-multi-lang";

export const PoolCard: FunctionComponent<
{
Expand All @@ -28,6 +29,7 @@ export const PoolCard: FunctionComponent<
className,
}) => {
const { isMobile } = useWindowSize();
const t = useTranslation();

// <Link /> notes: turn off prefetch to avoid loading tons of pools and lagging the client, many pools will be in viewport. They will still be fetched on hover.
// See : https://nextjs.org/docs/api-reference/next/link
Expand Down Expand Up @@ -56,7 +58,7 @@ export const PoolCard: FunctionComponent<
assetDenoms={poolAssets.map((asset) => asset.coinDenom)}
/>
<span className="caption text-white-disabled">
Pool #{poolId}
{t("pools.poolId", { id: poolId })}
</span>
</div>
</div>
Expand Down Expand Up @@ -102,7 +104,9 @@ export const PoolCard: FunctionComponent<
size="md"
assetDenoms={poolAssets.map((asset) => asset.coinDenom)}
/>
<div className="subtitle1 text-white-mid">{`Pool #${poolId}`}</div>
<div className="subtitle1 text-white-mid">
{t("pools.poolId", { id: poolId })}
</div>
</div>
</div>
<div className="flex place-content-between">
Expand Down
65 changes: 40 additions & 25 deletions packages/web/components/cards/pool-gauge-bonus.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FunctionComponent } from "react";
import { useTranslation } from "react-multi-lang";
import { MetricLoader } from "../loaders";
import { LoadingProps, MobileProps } from "../types";

Expand All @@ -9,30 +10,44 @@ export const PoolGaugeBonusCard: FunctionComponent<
remainingEpochs?: string;
} & LoadingProps &
MobileProps
> = ({ bonusValue, days, remainingEpochs, isLoading, isMobile = false }) => (
<div className="flex flex-col w-full min-w-[220px] gap-1 bg-card rounded-xl md:pl-[30%] md:p-3.5 py-5 px-7 border border-white-mid">
{isMobile ? (
<span className="subtitle1">{`${days} bonus reward`}</span>
) : (
<h5>Bonus bonding reward</h5>
)}
{!isMobile && (
<p className="text-white-mid">
<MetricLoader isLoading={isLoading}>
This pool bonding over {days ?? "0"} will earn additional bonding
incentives for {remainingEpochs ?? "0"} days.
> = ({ bonusValue, days, remainingEpochs, isLoading, isMobile = false }) => {
const t = useTranslation();

return (
<div className="flex flex-col w-full min-w-[220px] gap-1 bg-card rounded-xl md:pl-[30%] md:p-3.5 py-5 px-7 border border-white-mid">
{isMobile ? (
<span className="subtitle1">
{t("pool.gauges.bonus.titleMobile", { days: days ?? "0" })}
</span>
) : (
<h5>{t("pool.gauges.bonus.title")}</h5>
)}
{!isMobile && (
<p className="text-white-mid">
<MetricLoader isLoading={isLoading}>
{t("pool.gauges.bonus.info", {
days: days ?? "0",
remainingEpochs: remainingEpochs ?? "0",
})}
</MetricLoader>
</p>
)}
<p className="font-caption text-lg text-secondary-200 md:subtitle2">
<MetricLoader
className="h-6 md:h-4"
isLoading={isLoading || !bonusValue}
>
{isMobile
? t("pool.gauges.bonus.remainingMobile")
: t("pool.gauges.bonus.remaining")}{" "}
{bonusValue ?? "0"}
</MetricLoader>
</p>
)}
<p className="font-caption text-lg text-secondary-200 md:subtitle2">
<MetricLoader className="h-6 md:h-4" isLoading={isLoading || !bonusValue}>
{isMobile ? "Bonus:" : "Remaining:"} {bonusValue ?? "0"}
</MetricLoader>
</p>
{isMobile && remainingEpochs && !isLoading && (
<span className="subtitle2 text-secondary-200">
{remainingEpochs} days remaining
</span>
)}
</div>
);
{isMobile && remainingEpochs && !isLoading && (
<span className="subtitle2 text-secondary-200">
{t("pool.gauges.bonus.remainingEpochs", { remainingEpochs })}
</span>
)}
</div>
);
};
Loading