Skip to content

Commit bec1e54

Browse files
feat(internationalization): add internationalization to CoW Swap (#6198)
* fix: import * New Crowdin updates (#18) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> * Update apps/cowswap-frontend/src/locales/es-ES.po Co-authored-by: Copilot <[email protected]> * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * fix: eslint warning * feat: add feature flag to enable or disable locale loading (#19) * feat: add feature flag to enable or disable locale loading * fix: load default catalog * chore: update catalog * New Crowdin updates (#23) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update apps/cowswap-frontend/src/locales/es-ES.po Co-authored-by: Copilot <[email protected]> * Update apps/cowswap-frontend/src/locales/es-ES.po Co-authored-by: Copilot <[email protected]> * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * New Crowdin updates (#24) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * New Crowdin updates (#25) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New Crowdin updates (#26) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: comment wording * feat: add languages menu as settings dropdown item * fix: add flag * New Crowdin updates (#32) * New translations en-us.po (French) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: a few mobile issues * chore: add missing lingui macro * chore: update catalog * New Crowdin updates (#34) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> * Update apps/cowswap-frontend/src/locales/ru-RU.po Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * chore: update catalog * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * fix: usage of t inside string literals * chore: update catalog * New Crowdin updates (#37) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * fix: #6198 (comment) * chore: update catalog * New Crowdin updates (#38) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: #6198 (comment) * fix: #6198 (comment) * Update apps/cowswap-frontend/src/modules/orderProgressBar/pure/steps/FinishedStep.tsx Co-authored-by: Copilot <[email protected]> * chore: update catalog * fix: trans contents * chore: update catalog * New Crowdin updates (#39) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: update catalog * New Crowdin updates (#40) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: update catalog * chore: remove unused po file * fix: unnecessary symbol * fix: put back the fortune cookie svg * fix: display flags correctly in all operative systems * fix: limit translation * fix: dropdown layout issues * fix: order details layout * fix: translate order type * fix: title date * fix: locale time format * fix: view on explorer translation * fix: notifications date localization * fix: tooltip localization * fix: string concatenation * fix: add missing translation * fix: add localization to several dates * fix: add missing translation * fix: missing date localization * fix: broken translations * fix: broken translations * fix: wrong spaces in translation * fix: missing spaces in translation * fix: missing spaces in tooltip's text * fix: broken translation strings * fix: make some room so words fit better * fix: broken translation * fix: broken translation * chore: add missing translations * chore: add missing translations * chore: update catalog * chore: add missing translation * fix: broken translation * chore: add missing translation * fix: unfinished translation * chore: add missing macros * chore: add missing macros * feat: add correct locales to timeago.js * chore: add missing macros * fix: translations not updating on change * fix: localization format * chore: add t tags * chore: add trans tags * chore: add missing t macro * fix: pill width * chore: add missing macros * chore: update language catalogs * chore: update crowdin project id * New Crowdin updates (#44) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * fix: translation * fix: add missing dependency * chore: update language catalog * New Crowdin updates (#45) * New translations en-us.po (Spanish) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * chore: add missing t macro * chore: add some missing translation macros * chore: update catalog * fix: fortune cookie icon z-index * New Crowdin updates (#47) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * chore: update language catalog * New Crowdin updates (#49) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: word wrapping in menus * New Crowdin updates (#51) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: page title update on language switching * chore: update catalog * chore: update crowdin project id * New Crowdin updates (#54) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: localize unlocalized date * chore: update catalog * New Crowdin updates (#56) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: update catalog * New Crowdin updates (#58) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: wrong translation * fix: wrong translation * fix: order id string not updating when changing language * fix: order id string not updating when changing language * chore: add localization macros to partial approval feature * chore: update catalog * New Crowdin updates (#60) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Russian) * fix: order type appears to be translated to Spanish in the Account modal * fix: swap confirmation modal word wrapping * chore: add localization macros * fix: swap and bridge, route not supported is not translated * fix: approve is still not transalted * fix: swap and bridge orders: " view on..' is not translated * fix: notifications panel name is still not translated * chore: update catalog * fix: change macro for hook * fix: message descriptor missing i18n function * chore: update catalog * New Crowdin updates (#61) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: fortune cookie z-index * fix: hooks section appears to be shifted for a swap and bridge order details * fix: swap and bridge orders space is missing between a preposition and a chain * fix: revert table cell widths to original size * fix: table cell width * chore: update catalog * New Crowdin updates (#62) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: update catalog * New Crowdin updates (#63) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: add new translations * chore: update catalog * New Crowdin updates (#64) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: update catalog * chore: add new translations * chore: update catalog * New Crowdin updates (#65) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: add new translations * fix: localization macros placement * fix: add styles for the browser to break long words in the unlock widgets * fix: remove period at the end of sentence * chore: add missing translation macros * fix: make browser to break long words using hypens * fix: align 'Quote refresh in' to the right * fix: word wrapping * chore: update catalog * New Crowdin updates (#66) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: countdown font size * chore: add missing localization macro * chore: update catalog * New Crowdin updates (#67) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) (#68) * fix: some minor layout issues * chore: update catalog * chore: update crowdin project id * New Crowdin updates (#69) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: update catalog * New Crowdin updates (#70) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: move selected token string to a constant * refactor: remove export default * chore: update catalog * fix: remove space from string * chore: update catalog * New Crowdin updates (#71) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: wrong string was being localized * chore: update catalog * New Crowdin updates (#72) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * chore: update catalog * chore: add new string localizations * chore: update catalog * New Crowdin updates (#73) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: revert localized string to original state * chore: add localization readme * chore: remove commented code * chore: add missing localization macros * chore: update catalog * New Crowdin updates (#74) * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * Update source file en-US.po * New translations en-us.po (Spanish) * New translations en-us.po (Russian) * fix: explorer build errors * fix: cow.fi build issues * fix: lingui-related issues in tests * refactor: rename jest lingui provider * fix: add vite lingui plugin configuration * fix: add vite lingui plugin configuration * fix: text wrapping in menu button --------- Co-authored-by: Copilot <[email protected]>
1 parent 28d7206 commit bec1e54

File tree

493 files changed

+24255
-3710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

493 files changed

+24255
-3710
lines changed

apps/cowswap-frontend/.env

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,14 @@ INTEGRATION_TESTS_INFURA_KEY=
133133
# Path regex (to detect environment)
134134
# REACT_APP_PATH_REGEX_ENS="/ipfs"
135135

136-
137136
# CMS base URL
138137
# REACT_APP_CMS_BASE_URL=http://localhost:1337/api
139138

140139
# Notifications Telegram bot ID
141140
# REACT_APP_TG_BOT_ID=3713371337
141+
142+
#######################################
143+
# Internationalization
144+
#######################################
145+
146+
#REACT_APP_LINGUI_INTERNATIONALIZATION=true

apps/cowswap-frontend/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# See https://help.github.com/ignore-files/ for more about ignoring files.
22

3-
# generated contract types
3+
# generated language types
44
/src/lib/locales/**/*.js
55
/src/lib/locales/**/en-US.po
66
/src/lib/locales/**/pseudo.po
77
/src/locales/**/*.js
88
/src/locales/**/*.ts
99
/src/locales/**/*.json
10-
/src/locales/**/en-US.po
1110
/src/locales/**/pseudo.po
1211

1312
# dependencies
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { FC, ReactNode } from 'react'
2+
3+
import { DEFAULT_LOCALE } from '@cowprotocol/common-const'
4+
5+
import { i18n } from '@lingui/core'
6+
import { I18nProvider } from '@lingui/react'
7+
8+
interface ProviderProps {
9+
children: ReactNode
10+
}
11+
12+
i18n.load(DEFAULT_LOCALE, {})
13+
i18n.activate(DEFAULT_LOCALE)
14+
15+
export const LinguiWrapper: FC<ProviderProps> = ({ children }) => {
16+
return <I18nProvider i18n={i18n}>{children}</I18nProvider>
17+
}

apps/cowswap-frontend/src/api/cowProtocol/errors/OperatorError.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { t } from '@lingui/core/macro'
2+
13
type ApiActionType = 'get' | 'create' | 'delete'
24

35
export interface ApiErrorObject {
@@ -108,7 +110,7 @@ function _mapActionToErrorDetail(action?: ApiActionType) {
108110
console.error(
109111
'[OperatorError::_mapActionToErrorDetails] Uncaught error mapping error action type to server error. Please try again later.',
110112
)
111-
return 'Something failed. Please try again later.'
113+
return `Something failed. Please try again later.`
112114
}
113115
}
114116

@@ -144,23 +146,33 @@ export default class OperatorError extends Error {
144146
case 404:
145147
return this.getErrorMessage(errorObject, action)
146148

147-
case 403:
148-
return `The order cannot be ${action === 'create' ? 'accepted' : 'cancelled'}. Your account is deny-listed.`
149+
case 403: {
150+
const acceptedText = t`accepted`
151+
const cancelledText = t`cancelled`
152+
const statusText = action === 'create' ? acceptedText : cancelledText
153+
return t`The order cannot be ${statusText}. Your account is deny-listed.`
154+
}
149155

150-
case 429:
151-
return `The order cannot be ${
152-
action === 'create' ? 'accepted. Too many order placements' : 'cancelled. Too many order cancellations'
153-
}. Please, retry in a minute`
156+
case 429: {
157+
const placementsText = t`accepted. Too many order placements`
158+
const cancellationsText = t`cancelled. Too many order cancellations`
159+
const msg = action === 'create' ? placementsText : cancellationsText
160+
return t`The order cannot be ${msg}. Please, retry in a minute`
161+
}
154162

155163
case 500:
156-
default:
164+
default: {
157165
console.error(
158166
`[OperatorError::getErrorFromStatusCode] Error ${
159167
action === 'create' ? 'creating' : 'cancelling'
160168
} the order, status code:`,
161169
statusCode || 'unknown',
162170
)
163-
return `Error ${action === 'create' ? 'creating' : 'cancelling'} the order`
171+
const creatingText = t`creating`
172+
const cancellingText = t`cancelling`
173+
const verb = action === 'create' ? creatingText : cancellingText
174+
return t`Error ${verb} the order`
175+
}
164176
}
165177
}
166178
constructor(apiError: ApiErrorObject) {

apps/cowswap-frontend/src/common/constants/routes.ts

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import EXPERIMENT_ICON from '@cowprotocol/assets/cow-swap/experiment.svg'
22
import { isInjectedWidget } from '@cowprotocol/common-utils'
33
import { BadgeTypes } from '@cowprotocol/ui'
44

5+
import { MessageDescriptor } from '@lingui/core'
6+
import { msg } from '@lingui/core/macro'
7+
58
export const TRADE_WIDGET_PREFIX = isInjectedWidget() ? '/widget' : ''
69

710
export const Routes = {
@@ -54,25 +57,45 @@ export interface IMenuItem {
5457
badgeType?: (typeof BadgeTypes)[keyof typeof BadgeTypes]
5558
}
5659

57-
export const MENU_ITEMS: IMenuItem[] = [
58-
{ route: Routes.SWAP, label: 'Swap', description: 'Trade tokens' },
59-
{ route: Routes.LIMIT_ORDER, label: 'Limit', fullLabel: 'Limit order', description: 'Set your own price' },
60-
{ route: Routes.ADVANCED_ORDERS, label: 'TWAP', description: 'Place orders with a time-weighted average price' },
60+
export interface I18nIMenuItem extends Omit<IMenuItem, 'label' | 'fullLabel' | 'description' | 'badge'> {
61+
label: MessageDescriptor
62+
fullLabel?: MessageDescriptor
63+
description: MessageDescriptor
64+
badge?: MessageDescriptor
65+
}
66+
67+
export const MENU_ITEMS: I18nIMenuItem[] = [
68+
{
69+
route: Routes.SWAP,
70+
label: msg`Swap`,
71+
description: msg`Trade tokens`,
72+
},
73+
{
74+
route: Routes.LIMIT_ORDER,
75+
label: msg`Limit`,
76+
fullLabel: msg`Limit order`,
77+
description: msg`Set your own price`,
78+
},
79+
{
80+
route: Routes.ADVANCED_ORDERS,
81+
label: msg`TWAP`,
82+
description: msg`Place orders with a time-weighted average price`,
83+
},
6184
]
6285

63-
export const HOOKS_STORE_MENU_ITEM: IMenuItem = {
86+
export const HOOKS_STORE_MENU_ITEM: I18nIMenuItem = {
6487
route: Routes.HOOKS,
65-
label: 'Hooks',
66-
description: 'Powerful tool to generate pre/post interaction for CoW Protocol',
88+
label: msg`Hooks`,
89+
description: msg`Powerful tool to generate pre/post interaction for CoW Protocol`,
6790
badgeImage: EXPERIMENT_ICON,
6891
badgeType: BadgeTypes.INFORMATION,
6992
}
7093

71-
export const YIELD_MENU_ITEM: IMenuItem = {
94+
export const YIELD_MENU_ITEM: I18nIMenuItem = {
7295
route: Routes.YIELD,
73-
label: 'Yield',
74-
fullLabel: 'Yield',
75-
description: 'Provide liquidity',
76-
badge: 'New',
96+
label: msg`Yield`,
97+
fullLabel: msg`Yield`,
98+
description: msg`Provide liquidity`,
99+
badge: msg`New`,
77100
badgeType: BadgeTypes.ALERT,
78101
}

apps/cowswap-frontend/src/common/containers/CoWAmmBanner/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { ClosableBanner } from '@cowprotocol/ui'
88
import { useIsSmartContractWallet, useWalletInfo } from '@cowprotocol/wallet'
99
import { CurrencyAmount } from '@uniswap/sdk-core'
1010

11+
import { t } from '@lingui/core/macro'
12+
1113
import { useIsDarkMode } from 'legacy/state/user/hooks'
1214

1315
import { useTradeNavigate } from 'modules/trade'
@@ -80,8 +82,8 @@ export function CoWAmmBanner({ isTokenSelectorView }: BannerProps) {
8082
<CoWAmmBannerContent
8183
id={bannerId}
8284
isDarkMode={isDarkMode}
83-
title="CoW AMM"
84-
ctaText={isSmartContractWallet ? 'Booooost APR!' : 'Booooost APR gas-free!'}
85+
title={t`CoW AMM`}
86+
ctaText={isSmartContractWallet ? t`Booooost APR!` : t`Booooost APR gas-free!`}
8587
isTokenSelectorView={!!isTokenSelectorView}
8688
vampireAttackContext={vampireAttackContext}
8789
tokensByAddress={tokensByAddress}

apps/cowswap-frontend/src/common/containers/ConfirmationModal/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useAtomValue } from 'jotai'
22

3-
import { confirmationModalContextAtom } from 'common/hooks/useConfirmationRequest'
3+
import { t } from '@lingui/core/macro'
4+
5+
import { confirmationModalContextAtom, DEFAULT_CONFIRMATION_MODAL_CONTEXT } from 'common/hooks/useConfirmationRequest'
46
import { ConfirmationModal as Pure, ConfirmationModalProps } from 'common/pure/ConfirmationModal'
57

68
// TODO: Add proper return type annotation
@@ -13,12 +15,12 @@ export function ConfirmationModal({ isOpen, onDismiss }: Pick<ConfirmationModalP
1315
<Pure
1416
isOpen={isOpen}
1517
onDismiss={onDismiss}
16-
title={title}
17-
callToAction={callToAction}
18+
title={title === DEFAULT_CONFIRMATION_MODAL_CONTEXT.title ? t`Confirm Action` : title}
19+
callToAction={callToAction === DEFAULT_CONFIRMATION_MODAL_CONTEXT.callToAction ? t`Confirm` : callToAction}
1820
description={description}
1921
onEnable={onEnable}
2022
warning={warning}
21-
confirmWord={confirmWord}
23+
confirmWord={confirmWord === DEFAULT_CONFIRMATION_MODAL_CONTEXT.confirmWord ? t`confirm` : confirmWord}
2224
action={action}
2325
skipInput={skipInput}
2426
/>

apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ReactNode } from 'react'
22

3+
import { Trans } from '@lingui/react/macro'
4+
35
import { useLocalTimeOffset } from './localTimeOffsetState'
46

57
import { GlobalWarning } from '../../pure/GlobalWarning'
@@ -18,7 +20,10 @@ export function InvalidLocalTimeWarning(): ReactNode | null {
1820

1921
return (
2022
<GlobalWarning>
21-
Local device time is not accurate, CoW Swap most likely will not work correctly. Please adjust your device's time.
23+
<Trans>
24+
Local device time is not accurate, CoW Swap most likely will not work correctly. Please adjust your device's
25+
time.
26+
</Trans>
2227
</GlobalWarning>
2328
)
2429
}

apps/cowswap-frontend/src/common/containers/MultipleOrdersCancellationModal/index.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { Command } from '@cowprotocol/types'
66
import { ButtonPrimary } from '@cowprotocol/ui'
77
import { useWalletInfo } from '@cowprotocol/wallet'
88

9+
import { t } from '@lingui/core/macro'
10+
import { Trans } from '@lingui/react/macro'
11+
912
import { LegacyConfirmationModalContent } from 'legacy/components/TransactionConfirmationModal/LegacyConfirmationModalContent'
1013
import { useRequestOrderCancellation } from 'legacy/state/orders/hooks'
1114

@@ -68,7 +71,7 @@ export function MultipleOrdersCancellationModal(props: Props): ReactNode {
6871

6972
if (cancellationError) {
7073
const errorMessage = isRejectRequestProviderError(cancellationError)
71-
? 'User rejected signing the cancellation'
74+
? t`User rejected signing the cancellation`
7275
: getIsOrderBookTypedError(cancellationError)
7376
? cancellationError.body.description || cancellationError.body.errorType
7477
: (getProviderErrorMessage(cancellationError) ?? String(cancellationError))
@@ -86,9 +89,9 @@ export function MultipleOrdersCancellationModal(props: Props): ReactNode {
8689
<ConfirmationPendingContent
8790
modalMode
8891
onDismiss={onDismiss}
89-
title={<>Cancelling {ordersCount} orders</>}
90-
description="Canceling your order"
91-
operationLabel="cancellation"
92+
title={t`Cancelling ${ordersCount} orders`}
93+
description={t`Canceling your order`}
94+
operationLabel={t`cancellation`}
9295
/>
9396
</Modal>
9497
)
@@ -97,20 +100,24 @@ export function MultipleOrdersCancellationModal(props: Props): ReactNode {
97100
return (
98101
<Modal isOpen={isOpen} onDismiss={onDismiss}>
99102
<LegacyConfirmationModalContent
100-
title={`Cancel multiple orders: ${ordersCount}`}
103+
title={t`Cancel multiple orders: ${ordersCount}`}
101104
onDismiss={onDismiss}
102105
// TODO: Extract nested component outside render function
103106
// eslint-disable-next-line react/no-unstable-nested-components
104107
topContent={() => (
105108
<div>
106-
<p>Are you sure you want to cancel {ordersCount} orders?</p>
109+
<p>
110+
<Trans>Are you sure you want to cancel {ordersCount} orders?</Trans>
111+
</p>
107112
</div>
108113
)}
109114
// TODO: Extract nested component outside render function
110115
// eslint-disable-next-line react/no-unstable-nested-components
111116
bottomContent={() => (
112117
<div>
113-
<ButtonPrimary onClick={signAndSendCancellation}>Request cancellations</ButtonPrimary>
118+
<ButtonPrimary onClick={signAndSendCancellation}>
119+
<Trans>Request cancellations</Trans>
120+
</ButtonPrimary>
114121
</div>
115122
)}
116123
/>

apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { useState } from 'react'
22

33
import { CowHookDetails, HookToDappMatch } from '@cowprotocol/hook-dapp-lib'
44

5+
import { t } from '@lingui/core/macro'
6+
import { Trans, useLingui } from '@lingui/react/macro'
57
import { ChevronDown, ChevronUp } from 'react-feather'
68

79
import { useSimulationData } from 'modules/tenderly/hooks/useSimulationData'
@@ -13,12 +15,13 @@ import * as styledEl from './styled'
1315
// TODO: Break down this large function into smaller functions
1416
// TODO: Add proper return type annotation
1517
// TODO: Reduce function complexity by extracting logic
16-
// eslint-disable-next-line max-lines-per-function, @typescript-eslint/explicit-function-return-type, complexity
18+
// eslint-disable-next-line max-lines-per-function, @typescript-eslint/explicit-function-return-type
1719
export function HookItem({ details, item, index }: { details?: CowHookDetails; item: HookToDappMatch; index: number }) {
1820
const [isOpen, setIsOpen] = useState(false)
1921
const simulationData = useSimulationData(details?.uuid)
22+
const { i18n } = useLingui()
2023

21-
const dappName = item.dapp?.name || 'Unknown Hook'
24+
const dappName = item.dapp?.name || t`Unknown Hook`
2225

2326
return (
2427
<styledEl.HookItemWrapper as="li">
@@ -34,11 +37,13 @@ export function HookItem({ details, item, index }: { details?: CowHookDetails; i
3437
<styledEl.HookNumber>{index + 1}</styledEl.HookNumber>
3538
{item.dapp ? (
3639
<>
37-
<img src={item.dapp.image} alt={item.dapp.name} />
38-
<span>{item.dapp.name}</span>
40+
<img src={item.dapp.image} alt={i18n._(item.dapp.name)} />
41+
<span>{i18n._(item.dapp.name)}</span>
3942
</>
4043
) : (
41-
<span>Unknown hook dapp</span>
44+
<span>
45+
<Trans>Unknown hook dapp</Trans>
46+
</span>
4247
)}
4348
</styledEl.HookItemInfo>
4449
<styledEl.ToggleIcon isOpen={isOpen}>
@@ -51,7 +56,9 @@ export function HookItem({ details, item, index }: { details?: CowHookDetails; i
5156
<>
5257
{simulationData && (
5358
<p>
54-
<b>Simulation:</b>
59+
<b>
60+
<Trans>Simulation:</Trans>
61+
</b>
5562
<styledEl.SimulationLink status={simulationData.status}>
5663
<a
5764
href={simulationData.link}
@@ -63,19 +70,27 @@ export function HookItem({ details, item, index }: { details?: CowHookDetails; i
6370
label: `${dappName} - ${simulationData.status ? 'Success' : 'Failed'}`,
6471
})}
6572
>
66-
{simulationData.status ? 'Simulation successful' : 'Simulation failed'}
73+
{simulationData.status ? <Trans>Simulation successful</Trans> : <Trans>Simulation failed</Trans>}
6774
</a>
6875
</styledEl.SimulationLink>
6976
</p>
7077
)}
7178
<p>
72-
<b>Description:</b> {item.dapp.descriptionShort}
79+
<b>
80+
<Trans>Description</Trans>:
81+
</b>{' '}
82+
{item.dapp?.descriptionShort ? i18n._(item.dapp.descriptionShort) : ''}
7383
</p>
7484
<p>
75-
<b>Version:</b> {item.dapp.version}
85+
<b>
86+
<Trans>Version</Trans>:
87+
</b>{' '}
88+
{item.dapp.version}
7689
</p>
7790
<p>
78-
<b>Website:</b>{' '}
91+
<b>
92+
<Trans>Website</Trans>:
93+
</b>{' '}
7994
<a
8095
href={item.dapp.website}
8196
target="_blank"

0 commit comments

Comments
 (0)