Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
chore: resolve crowdin conf
Browse files Browse the repository at this point in the history
  • Loading branch information
behnaz-deriv committed Feb 29, 2024
2 parents 1aff165 + 45e7b64 commit f4c26d5
Show file tree
Hide file tree
Showing 42 changed files with 6,553 additions and 8,162 deletions.
15 changes: 10 additions & 5 deletions crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@
"421158556": "You may refer to <0>our terms</0> for more information. If you need help getting into your account, <1>contact us via live chat.</1>",
"421232681": "Additional terms",
"421563171": "What are vanilla options?",
"422844635": "Please read our <0>Terms and conditions</0>, <1>Risk disclosure</1>, and <2>Secure and responsible trading</2> to fully understand the risks involved before using our services. The information on this website does not constitute investment advice.",
"426355147": "<0> {{loss_percent}}% of retail investor accounts lose money when trading CFDs with Deriv, read our full Risk disclosure here.</0>",
"426923558": "The closer the barrier is to the spot price, the higher the chance for your turbo options contract to expire worthless (which means, your contract will expire without any payout or profit).",
"427008206": "Be transparent",
Expand Down Expand Up @@ -538,6 +537,7 @@
"510912921": "If the selected condition is not met or if the exit price is equal to either barrier, your stake is lost.",
"511244573": "If you select 'Touch', you receive the payout if the market price touches the barrier at any time during the contract period.",
"512031600": "The percentage of position value required as collateral. Calculated as (% x trade size).",
"512075488": "The products offered on our website are complex derivative products that carry a significant risk of potential loss. CFDs are complex instruments with a high risk of losing money rapidly due to leverage. You should consider whether you understand how these products work and whether you can afford to take the high risk of losing your money.",
"514514217": "If the selected condition is not met, your stake is lost.",
"515077577": "<0>10 lots</0> traded with DL on <0>XAU/USD</0> is split between:",
"517286342": "<p>To place a vanilla options contract, you’ll need to:</p><ul><li>Select the underlying asset you want to trade.</li><li>Determine your contract duration or end time.</li><li>Predict the asset’s price movement by choosing Call or Put.</li><li>Select your preferred strike price</li><li>Enter your stake.</li><li>Purchase the contract</li></ul>",
Expand Down Expand Up @@ -614,6 +614,7 @@
"581576971": "Hit <0>Reset</0> at the bottom of stats panel.",
"582048648": "Contact Us | Online Trading | Deriv.com",
"582179280": "Yes, your contract will close automatically if the market price touches the selected barrier at any time during the contract period, no matter which contract type you are trading.",
"582187360": "Deriv (FX) Ltd is licensed by the Labuan Financial Services Authority.",
"582602639": "If you have been contacted by a potential impersonator or if you have any questions, contact us <0>via live chat</0>.",
"583345172": "Deriv X widgets to customise your CFD trading",
"586006302": "<0>Over/Under:</0> Predict whether the last digit of the last tick of a contract will be higher or lower than a specific number.",
Expand Down Expand Up @@ -738,6 +739,7 @@
"701775446": "Volatility 200 Index",
"701840176": "Commission per USD 100k turnover",
"702074152": "PARTNERS",
"702175212": "Make sure to read our <0>Terms and conditions</0>, <1>Risk disclosure</1>, and <2>Secure and responsible trading</2> to fully understand the risks involved before using our services. Please note that the information on this website does not constitute investment advice.",
"702303938": "affiliate ib",
"704465777": "After making your payment, share the receipt with the seller via the chat feature in Deriv P2P.",
"704532260": "Sign up with just your email. No credit card or minimum deposit required.",
Expand Down Expand Up @@ -967,6 +969,7 @@
"904780038": "Set the restart conditions",
"907733837": "Predict whether the market price will touch or not touch the chosen barrier (target) during the contract period.",
"909083576": "404 - Page not found | Deriv",
"909249493": "Deriv (V) Ltd is licensed and regulated by the Vanuatu Financial Services Commission.",
"910109245": "7-8 October 2024",
"910572263": "1. Create the following variables and place them under <0>Run once at start</0>:",
"910806943": "You’ll earn a fixed commission based on the volume of individual trades bought by your referred clients.",
Expand Down Expand Up @@ -1347,7 +1350,6 @@
"1280193494": "Mine for commodities.",
"1280380287": "Hungary",
"1280397222": "Have your own platform (for example, YouTube channel, blog, social media platforms, etc) to promote your link.",
"1280750550": "Deriv Investments (Europe) Limited is licensed and regulated by the Malta Financial Services Authority under the Investment Services Act (<0>licence</0>). Deriv (FX) Ltd is licensed by the Labuan Financial Services Authority (<1>licence</1>). Deriv (BVI) Ltd is licensed by the British Virgin Islands Financial Services Commission (<2>licence</2>). Deriv (V) Ltd is licensed by the Vanuatu Financial Services Commission (<3>licence</3>). Deriv (SVG) LLC has a registered office at First Floor, SVG Teachers Credit Union Uptown Building, Corner of James and Middle Street, Kingstown P.O., St Vincent and the Grenadines. The holding company for these subsidiaries is Deriv.com Limited, with the registration number 71479 and the registered address at 2nd Floor, 1 Cornet Street, St Peter Port, Guernsey, GY1 1BZ.",
"1281089964": "Help centre | Frequently asked questions | Payment Agent | Deriv",
"1282206384": "Cayman Islands – Our office | Deriv",
"1284073736": "3. To log in on your desktop, click Trade on web terminal.",
Expand Down Expand Up @@ -1546,6 +1548,7 @@
"1466788657": "For more info, <0>check out this blog post</0> on the basics of building a trading bot.",
"1467325385": "Global affiliate support",
"1467514183": "Virtual markets, real opportunities.",
"1467698554": "Make sure to read our <0>Terms and conditions</0>, <1>Risk disclosure</1>, and <2>Secure and responsible trading</2> to fully understand the risks involved before using our services. Please also note that the information on this website does not constitute investment advice. The value of investments may go down as well as up.",
"1468688914": "Make instant deposits using crypto to your fiat account.",
"1469255430": "terms and conditions",
"1469626982": "USD/CNH",
Expand Down Expand Up @@ -1946,7 +1949,6 @@
"1813020144": "Is there a minimum amount if I want to transfer my funds from one platform to another?",
"1813700208": "Boom 300 Index",
"1813703795": "Sign up as our affiliate and IB",
"1813982788": "Deriv (FX) Ltd is licensed by the Labuan Financial Services Authority <0>(licence)</0>. Deriv (BVI) Ltd is licensed by the British Virgin Islands Financial Services Commission <1>(licence)</1>. Deriv (V) Ltd is licensed by the Vanuatu Financial Services Commission <2>(licence)</2>. Deriv (SVG) LLC has a registered office at First Floor, SVG Teachers Credit Union Uptown Building, Corner of James and Middle Street, Kingstown P.O., St Vincent and the Grenadines. The holding company for these subsidiaries is Deriv.com Limited, with the registration number 71479 and the registered address at 2nd Floor, 1 Cornet Street, St Peter Port, Guernsey, GY1 1BZ.",
"1815324634": "The minimum deposit and withdrawal amount varies depending on the payment method. The lowest deposit and withdrawal amount is 5 USD/EUR/GBP/AUD via e-wallets. See our <0>Payment methods</0> page for a complete list of payment methods and their minimum deposit and withdrawal amounts.",
"1816305227": "If you’re in the EU or UK:",
"1817888235": "Predict and gain from exciting spikes and dips with our Crash/Boom indices.",
Expand Down Expand Up @@ -2328,6 +2330,7 @@
"2136716746": "Partner with a trusted online trading provider",
"2137077186": "IVW.US",
"2137683344": "What is a dormant fee?",
"2137890937": "Deriv.com Limited, a company registered in Guernsey, is the holding company for these entities.",
"2139905716": "In addition to their simplicity to understand, the main reason traders choose to trade vanilla options is because they offer potentially high profit as they do not have a fixed payout, while losses are strictly limited to the initial stake amount.",
"2142042461": "Trading CFDs increases both potential profit and loss",
"2142117024": "Take profit amount in Up direction",
Expand Down Expand Up @@ -3165,8 +3168,10 @@
"-810716123": "Deriv Blog",
"-634625185": "Terms & conditions",
"-258641121": "Deriv Prime",
"-1353183095": "CFDs and other products offered on this website are complex instruments with high risk of losing money rapidly owing to leverage. You should consider whether you understand how these products work and whether you can afford to risk losing your money.",
"-69160574": "Deriv Investments (Europe) Limited is licensed and regulated by the Malta Financial Services Authority under the Investment Services Act <0>(licence)</0>. The holding company for this subsidiary is Deriv.com Limited, with the registration number 71479 and the registered address at 2nd Floor, 1 Cornet Street, St Peter Port, Guernsey, GY1 1BZ.",
"-1211482950": "Deriv (BVI) Ltd is licensed by the British Virgin Islands Financial Services Commission.",
"-1159954168": "Deriv (SVG) LLC has a registered office at First Floor, SVG Teachers Credit Union Uptown Building, Corner of James and Middle Street, Kingstown P.O., St Vincent and the Grenadines.",
"-175314456": "Deriv Investments (Europe) Limited is licensed and regulated by the Malta Financial Services Authority under the Investment Services Act.",
"-641279911": "Make sure to read our <0>Terms and conditions</0>, <1>Risk disclosure</1>, and <2>Secure and responsible trading</2> to fully understand the risks involved before using our services. Please also note that the information on this website does not constitute investment advice.",
"-1898146227": "get it on google play",
"-773544978": "Home",
"-1793603559": "Locations",
Expand Down
57 changes: 35 additions & 22 deletions src/common/websocket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const PING_INTERVAL = 30000
export class ApiManager {
private socket: WebSocket
public derivApi: TDerivApi
private pingInterval: NodeJS.Timer
private ready: boolean
public static readyState: number

public static instance: ApiManager
public static getInstance() {
Expand All @@ -34,22 +34,55 @@ export class ApiManager {
return ApiManager.instance
}

private setReadyState(state: number) {
ApiManager.readyState = state
}

public init(lang?: string) {
if (!this.ready) {
if (!this.socket) {
console.log('WS connecting...')
const language = lang === 'ach' ? getCrowdin() : lang?.replace('-', '_')
const socket_url = getSocketURL()
const app_id = getAppId()
const websocket_connection_url = `${socket_url}?app_id=${app_id}&l=${language}&brand=${brand_name.toLowerCase()}`

this.socket = new WebSocket(websocket_connection_url)
this.setReadyState(this.socket?.readyState)
}
this.derivApi = new DerivAPIBasic({ connection: this.socket })
this.registerKeepAlive()
this.socket.addEventListener('open', () => {
console.log('WS connected.')
this.setReadyState(this?.socket?.readyState)
})

this.socket.addEventListener('close', () => {
console.log('WS closed')
this.derivApi.disconnect()
this.ready = null
this.setReadyState(null)
})
this.ready = true
}
}

public reconnectIfNotConnected(lang?: string): Promise<void> {
console.log('WS reconnecting....')
return new Promise((resolve, reject) => {
if (this?.socket?.readyState !== 1) {
this.socket = null
this.ready = null
this.init(lang)
this?.socket?.addEventListener?.('open', () => {
console.log('WS connected using reconnect method.')
resolve()
})
} else {
resolve()
}
})
}

public augmentedSend<T extends TSocketEndpointNames>(
name: T,
request?: TSocketRequestProps<T> extends never ? undefined : TSocketRequestProps<T>,
Expand All @@ -70,25 +103,6 @@ export class ApiManager {
return this.derivApi.authorize({ authorize: token })
}

private registerKeepAlive() {
if (this.pingInterval) {
clearInterval(this.pingInterval)
}
this.socket.addEventListener('open', () => {
this.pingInterval = setInterval(() => {
this.socket.send(JSON.stringify({ ping: 1 }))
}, PING_INTERVAL)
})

this.socket.addEventListener('close', () => {
clearInterval(this.pingInterval)
})

this.socket.addEventListener('error', () => {
clearInterval(this.pingInterval)
})
}

public reset(language: string) {
const socket_url = getSocketURL()
const app_id = getAppId()
Expand All @@ -99,7 +113,6 @@ export class ApiManager {

this.socket = new WebSocket(websocket_connection_url)
this.derivApi = new DerivAPIBasic({ connection: this.socket })
this.registerKeepAlive()
}
}
let apiManager: ApiManager
Expand Down
20 changes: 19 additions & 1 deletion src/components/hooks/useWS.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useState } from 'react'
import { TSocketEndpointNames, TSocketResponseData } from 'common/websocket/types'
import apiManager from 'common/websocket'
import apiManager, { ApiManager } from 'common/websocket'
import { getLanguage, isBrowser } from 'common/utility'

const useWS = <T extends TSocketEndpointNames>(name: T) => {
const [is_loading, setIsLoading] = useState(false)
Expand All @@ -15,6 +16,23 @@ const useWS = <T extends TSocketEndpointNames>(name: T) => {
const send = useCallback(
async (data?: Parameters<typeof apiManager.augmentedSend<T>>[1]) => {
setIsLoading(true)
const readyState = parseInt(ApiManager.readyState)
if (readyState !== 1 && readyState !== 0) {
if (isBrowser()) {
const currentLanguage = getLanguage() ?? 'en'
try {
// Connect to WebSocket if not connected
await apiManager.reconnectIfNotConnected(currentLanguage)
} catch (e) {
setError(e)
setIsLoading(false)
return
}
} else {
setIsLoading(false)
return
}
}
try {
const response = await apiManager.augmentedSend(name, data)
setData(response[name] as TSocketResponseData<T>)
Expand Down
2 changes: 1 addition & 1 deletion src/features/components/templates/footer/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export const EuFooterNavData: FooterItems[] = [
]

export const warnText = (
<Localize translate_text="_t_CFDs and other products offered on this website are complex instruments with high risk of losing money rapidly owing to leverage. You should consider whether you understand how these products work and whether you can afford to risk losing your money._t_" />
<Localize translate_text="_t_The products offered on our website are complex derivative products that carry a significant risk of potential loss. CFDs are complex instruments with a high risk of losing money rapidly due to leverage. You should consider whether you understand how these products work and whether you can afford to take the high risk of losing your money._t_" />
)

export const socialButtonsROW = [
Expand Down
Loading

0 comments on commit f4c26d5

Please sign in to comment.