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

Create language switcher and activate 5 languages #152

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/workflows/translations-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
with:
config: 'crowdin.yml'
upload_sources: true
upload_translations: true
upload_translations: false
download_translations: true
skip_untranslated_strings: true
export_only_approved: true
localization_branch_name: l10n_crowdin_translations
create_pull_request: true
Expand Down
1 change: 1 addition & 0 deletions bridge_ui/locales/ar-SA/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
303 changes: 1 addition & 302 deletions bridge_ui/locales/bg-BG/translation.json

Large diffs are not rendered by default.

586 changes: 293 additions & 293 deletions bridge_ui/locales/de-DE/translation.json

Large diffs are not rendered by default.

597 changes: 298 additions & 299 deletions bridge_ui/locales/el-GR/translation.json

Large diffs are not rendered by default.

303 changes: 1 addition & 302 deletions bridge_ui/locales/es-ES/translation.json

Large diffs are not rendered by default.

303 changes: 1 addition & 302 deletions bridge_ui/locales/fr-FR/translation.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bridge_ui/locales/hi-IN/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
596 changes: 298 additions & 298 deletions bridge_ui/locales/id-ID/translation.json

Large diffs are not rendered by default.

303 changes: 1 addition & 302 deletions bridge_ui/locales/it-IT/translation.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bridge_ui/locales/nl-NL/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
594 changes: 297 additions & 297 deletions bridge_ui/locales/pt-PT/translation.json

Large diffs are not rendered by default.

303 changes: 1 addition & 302 deletions bridge_ui/locales/ru-RU/translation.json

Large diffs are not rendered by default.

188 changes: 188 additions & 0 deletions bridge_ui/locales/th-TH/translation.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bridge_ui/locales/tr-TR/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
584 changes: 292 additions & 292 deletions bridge_ui/locales/vi-VN/translation.json

Large diffs are not rendered by default.

303 changes: 1 addition & 302 deletions bridge_ui/locales/zh-CN/translation.json

Large diffs are not rendered by default.

48 changes: 40 additions & 8 deletions bridge_ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions bridge_ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"dexie-react-hooks": "^1.1.1",
"ethereum-multicall": "^2.17.0",
"ethers": "^5.7.1",
"framer-motion": "^6.5.1",
"i18next": "^23.16.8",
"i18next-browser-languagedetector": "^8.0.2",
"js-base64": "^3.6.1",
"luxon": "^2.3.1",
"notistack": "^1.0.10",
Expand All @@ -43,6 +46,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^14.1.2",
"react-icons": "^5.4.0",
"react-modal": "^3.15.1",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
Expand Down
12 changes: 12 additions & 0 deletions bridge_ui/src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { makeStyles, Typography } from "@material-ui/core";
import { useTranslation } from "react-i18next";
import LanguageSwitch from "../localization/LanguageSwitch";
import styled from "styled-components";

const useStyles = makeStyles((theme) => ({
footer: {
Expand Down Expand Up @@ -67,6 +69,16 @@ export default function Footer() {
</Typography>
</div>
</div>
<LanguageSwitchContainer>
<LanguageSwitch />
</LanguageSwitchContainer>
</footer>
);
}

const LanguageSwitchContainer = styled.div`
padding: 15px 30px;
display: flex;
justify-content: space-between;
backdrop-filter: blur(20px);
`
2 changes: 1 addition & 1 deletion bridge_ui/src/components/Recovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import { selectTransferSourceChain, selectTransferTransferTx } from "../store/se
import { getEVMCurrentBlockNumber, isEVMTxConfirmed } from "../utils/evm";
import { Wallet, useWallet } from "@alephium/web3-react";
import { useTranslation } from "react-i18next";
import i18n from "../i18n";
import i18n from "../localization/i18n";

const useStyles = makeStyles((theme) => ({
mainCard: {
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useEthereumMigratorInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Signer } from "@ethersproject/abstract-signer";
import { formatUnits } from "@ethersproject/units";
import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import i18n from "../i18n";
import i18n from "../localization/i18n";

export type EthMigrationInfo = {
isLoading: boolean;
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useGetSourceParsedTokenAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ import { getRegisteredTokens, getTokenLogoAndSymbol } from "../utils/tokens";
import { useWallet } from "@alephium/web3-react";
import { Alert } from "@material-ui/lab";
import parseError from "../utils/parseError";
import i18n from "../i18n";
import i18n from "../localization/i18n";
import { useTranslation } from "react-i18next";

export function createParsedTokenAccount(
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useHandleAttest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { getSignedVAAWithRetry } from "../utils/getSignedVAAWithRetry";
import parseError from "../utils/parseError";
import { attestFromEthWithoutWait, waitEVMTxConfirmed, checkETHToken, checkBSCToken } from "../utils/evm";
import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react";
import i18n from "../i18n";
import i18n from "../localization/i18n";

async function evm(
dispatch: any,
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useHandleCreateWrapped.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import useAttestSignedVAA from "./useAttestSignedVAA";
import { createWrappedOnEthWithoutWait, updateWrappedOnEthWithoutWait } from "../utils/evm";
import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react";
import { MINIMAL_CONTRACT_DEPOSIT } from "@alephium/web3";
import i18n from "../i18n";
import i18n from "../localization/i18n";

async function evm(
dispatch: any,
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useHandleRedeem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import useTransferSignedVAA from "./useTransferSignedVAA";
import { redeemOnEthNativeWithoutWait, redeemOnEthWithoutWait } from "../utils/evm";
import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react";
import { SignerProvider } from "@alephium/web3";
import i18n from "../i18n";
import i18n from "../localization/i18n";

async function evm(
dispatch: any,
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useHandleTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { validateAlephiumRecipientAddress, waitALPHTxConfirmed, waitTxConfirmedA
import { ExecuteScriptResult } from "@alephium/web3";
import { transferFromEthNativeWithoutWait, transferFromEthWithoutWait, waitEVMTxConfirmed } from "../utils/evm";
import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react";
import i18n from "../i18n";
import i18n from "../localization/i18n";

async function evm(
dispatch: any,
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useOriginalAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import useIsWalletReady from "./useIsWalletReady";
import { NodeProvider } from "@alephium/web3";
import { getAlephiumTokenWrappedInfo, tryGetContractId } from "../utils/alephium";
import { useWallet } from "@alephium/web3-react";
import i18n from "../i18n";
import i18n from "../localization/i18n";
import { useTranslation } from "react-i18next";

export type OriginalAssetInfo = {
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useRelayersAvailable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Dispatch } from "@reduxjs/toolkit";
import axios from "axios";
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import i18n from "../i18n";
import i18n from "../localization/i18n";
import { DataWrapper } from "../store/helpers";
import { selectRelayerTokenInfo } from "../store/selectors";
import {
Expand Down
13 changes: 13 additions & 0 deletions bridge_ui/src/hooks/useStateWithLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useEffect, useState } from 'react'

const useStateWithLocalStorage = <T extends string>(localStorageKey: string, defaultValue: T) => {
const [value, setValue] = useState(localStorage.getItem(localStorageKey) || defaultValue)

useEffect(() => {
localStorage.setItem(localStorageKey, value)
}, [localStorageKey, value])

return [value as T, setValue] as const
}

export default useStateWithLocalStorage
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useTransactionFees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { NodeProvider } from "@alephium/web3";
import { setGasPrice } from "../store/transferSlice";
import { useDispatch } from "react-redux";
import { useWallet } from "@alephium/web3-react";
import i18n from "../i18n";
import i18n from "../localization/i18n";
import { useTranslation } from "react-i18next";

export type GasEstimate = {
Expand Down
35 changes: 0 additions & 35 deletions bridge_ui/src/i18n.ts

This file was deleted.

2 changes: 1 addition & 1 deletion bridge_ui/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./i18n";
import "./localization/i18n";

import { CssBaseline } from "@material-ui/core";
import { ThemeProvider } from "@material-ui/core/styles";
Expand Down
40 changes: 40 additions & 0 deletions bridge_ui/src/localization/LanguageSwitch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import i18next from "i18next";
import { useEffect } from "react";
import styled from "styled-components";

import { Language, languageOptions } from "./languages";
import useStateWithLocalStorage from "../hooks/useStateWithLocalStorage";
import Menu from "./Menu";

interface LanguageSwitchProps {
className?: string;
}

const LanguageSwitch: React.FC<LanguageSwitchProps> = ({ className }) => {
const [langValue, setLangValue] = useStateWithLocalStorage<Language>('language', 'en')

useEffect(() => {
i18next.changeLanguage(langValue)
}, [langValue])

const items = languageOptions.map((lang) => ({
text: lang.label,
onClick: () => setLangValue(lang.value)
}))

return (
<Menu
aria-label="Language"
label={languageOptions.find((o) => o.value === langValue)?.label || ''}
items={items}
direction="up"
className={className}
/>
);
};

export default styled(LanguageSwitch)`
border-radius: 8px;
background-color: #1B1B1F;
border: 1px solid rgba(255, 255, 255, 0.08);
`;
Loading
Loading