Skip to content

Commit

Permalink
refactor lazy translation
Browse files Browse the repository at this point in the history
  • Loading branch information
vipineth committed Jun 6, 2023
1 parent b8b6047 commit 19c65c5
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 58 deletions.
3 changes: 1 addition & 2 deletions src/components/Exchange/FeesTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { i18n } from "@lingui/core";
import { t, Trans } from "@lingui/macro";
import ExternalLink from "components/ExternalLink/ExternalLink";
import StatsTooltipRow from "components/StatsTooltip/StatsTooltipRow";
Expand All @@ -22,7 +21,7 @@ function getFeeLabel(type: FeeType) {
deposit: t`Deposit Fee`,
execution: t`Execution Fee`,
};
return i18n._(/*i18n*/ labels[type]);
return labels[type];
}

function getExecutionFeeStr(chainId, executionFee, executionFeeUsd) {
Expand Down
17 changes: 8 additions & 9 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NavLink } from "react-router-dom";
import { isHomeSite, getAppBaseUrl, shouldShowRedirectModal } from "lib/legacy";
import { getFooterLinks, SOCIAL_LINKS } from "./constants";
import ExternalLink from "components/ExternalLink/ExternalLink";
import { i18n } from "@lingui/core";

type Props = { showRedirectModal?: (to: string) => void; redirectPopupTimestamp?: () => void };

Expand All @@ -29,37 +28,37 @@ export default function Footer({ showRedirectModal, redirectPopupTimestamp }: Pr
})}
</div>
<div className="Footer-links">
{getFooterLinks(isHome).map(({ external, text, link, isAppLink }) => {
{getFooterLinks(isHome).map(({ external, label, link, isAppLink }) => {
if (external) {
return (
<ExternalLink key={text} href={link} className="Footer-link">
{i18n._(/*i18n*/ text)}
<ExternalLink key={label} href={link} className="Footer-link">
{label}
</ExternalLink>
);
}
if (isAppLink) {
if (shouldShowRedirectModal(redirectPopupTimestamp)) {
return (
<div
key={text}
key={label}
className="Footer-link a"
onClick={() => showRedirectModal && showRedirectModal(link)}
>
{i18n._(/*i18n*/ text)}
{label}
</div>
);
} else {
const baseUrl = getAppBaseUrl();
return (
<a key={text} href={baseUrl + link} className="Footer-link">
{i18n._(/*i18n*/ text)}
<a key={label} href={baseUrl + link} className="Footer-link">
{label}
</a>
);
}
}
return (
<NavLink key={link} to={link} className="Footer-link" activeClassName="active">
{i18n._(/*i18n*/ text)}
{label}
</NavLink>
);
})}
Expand Down
27 changes: 13 additions & 14 deletions src/components/Footer/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import githubIcon from "img/ic_github.svg";
import substackIcon from "img/ic_substack.svg";

type Link = {
text: string;
label: string;
link: string;
external?: boolean;
isAppLink?: boolean;
Expand All @@ -19,20 +19,19 @@ type SocialLink = {
icon: string;
};

export const FOOTER_LINKS: { home: Link[]; app: Link[] } = {
home: [
{ text: t`Terms and Conditions`, link: "/terms-and-conditions" },
{ text: t`Referral Terms`, link: "/referral-terms" },
{ text: t`Media Kit`, link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { text: "Jobs", link: "/jobs", isAppLink: true },
],
app: [
{ text: t`Media Kit`, link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { text: "Jobs", link: "/jobs" },
],
};

export function getFooterLinks(isHome) {
const FOOTER_LINKS: { home: Link[]; app: Link[] } = {
home: [
{ label: t`Terms and Conditions`, link: "/terms-and-conditions" },
{ label: t`Referral Terms`, link: "/referral-terms" },
{ label: t`Media Kit`, link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { label: "Jobs", link: "/jobs", isAppLink: true },
],
app: [
{ label: t`Media Kit`, link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { label: "Jobs", link: "/jobs" },
],
};
return FOOTER_LINKS[isHome ? "home" : "app"];
}

Expand Down
47 changes: 23 additions & 24 deletions src/components/Header/HomeHeaderLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,30 @@ type Props = {

type HomeLink = { label: string; link: string; isHomeLink?: boolean | false };

const HOME_MENUS: HomeLink[] = [
{
label: t`App`,
isHomeLink: true,
link: "/trade",
},
{
label: t`Protocol`,
link: "https://github.com/gmx-io",
},
{
label: t`Governance`,
link: "https://gov.gmx.io/",
},
{
label: t`Voting`,
link: "https://snapshot.org/#/gmx.eth",
},
{
label: t`Docs`,
link: "https://gmxio.gitbook.io/gmx/",
},
];

export function HomeHeaderLinks({ small, clickCloseIcon, redirectPopupTimestamp, showRedirectModal }: Props) {
const HOME_MENUS: HomeLink[] = [
{
label: t`App`,
isHomeLink: true,
link: "/trade",
},
{
label: t`Protocol`,
link: "https://github.com/gmx-io",
},
{
label: t`Governance`,
link: "https://gov.gmx.io/",
},
{
label: t`Voting`,
link: "https://snapshot.org/#/gmx.eth",
},
{
label: t`Docs`,
link: "https://gmxio.gitbook.io/gmx/",
},
];
return (
<div className="App-header-links">
{small && (
Expand Down
6 changes: 3 additions & 3 deletions src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ msgstr "Ankündigung"

#: src/components/Header/HomeHeaderLinks.tsx
msgid "App"
msgstr ""
msgstr "App"

#: src/domain/tokens/approveTokens.tsx
msgid "Approval failed"
Expand Down Expand Up @@ -1079,7 +1079,7 @@ msgstr "Verteilung"
#: src/components/Header/AppHeaderLinks.tsx
#: src/components/Header/HomeHeaderLinks.tsx
msgid "Docs"
msgstr ""
msgstr "Dokumente"

#: src/components/ModalViews/RedirectModal.js
msgid "Don't show this message again for 30 days."
Expand Down Expand Up @@ -1515,7 +1515,7 @@ msgstr ""

#: src/components/Header/HomeHeaderLinks.tsx
msgid "Governance"
msgstr ""
msgstr "Governance"

#: src/components/Exchange/SwapBox.js
msgid "High Slippage, Swap Anyway"
Expand Down
6 changes: 3 additions & 3 deletions src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ msgstr "Anuncio"

#: src/components/Header/HomeHeaderLinks.tsx
msgid "App"
msgstr ""
msgstr "Aplicación"

#: src/domain/tokens/approveTokens.tsx
msgid "Approval failed"
Expand Down Expand Up @@ -1079,7 +1079,7 @@ msgstr "Distribución"
#: src/components/Header/AppHeaderLinks.tsx
#: src/components/Header/HomeHeaderLinks.tsx
msgid "Docs"
msgstr ""
msgstr "Documentos"

#: src/components/ModalViews/RedirectModal.js
msgid "Don't show this message again for 30 days."
Expand Down Expand Up @@ -1515,7 +1515,7 @@ msgstr ""

#: src/components/Header/HomeHeaderLinks.tsx
msgid "Governance"
msgstr ""
msgstr "Gobernanza"

#: src/components/Exchange/SwapBox.js
msgid "High Slippage, Swap Anyway"
Expand Down
6 changes: 3 additions & 3 deletions src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ msgstr "Annonce"

#: src/components/Header/HomeHeaderLinks.tsx
msgid "App"
msgstr ""
msgstr "Application"

#: src/domain/tokens/approveTokens.tsx
msgid "Approval failed"
Expand Down Expand Up @@ -1079,7 +1079,7 @@ msgstr "Distribution"
#: src/components/Header/AppHeaderLinks.tsx
#: src/components/Header/HomeHeaderLinks.tsx
msgid "Docs"
msgstr ""
msgstr "Documents"

#: src/components/ModalViews/RedirectModal.js
msgid "Don't show this message again for 30 days."
Expand Down Expand Up @@ -1515,7 +1515,7 @@ msgstr ""

#: src/components/Header/HomeHeaderLinks.tsx
msgid "Governance"
msgstr ""
msgstr "Gouvernance"

#: src/components/Exchange/SwapBox.js
msgid "High Slippage, Swap Anyway"
Expand Down

0 comments on commit 19c65c5

Please sign in to comment.