Skip to content

Commit

Permalink
Merge pull request #5323 from EdgeApp/jon/fix/uk-compliance-2
Browse files Browse the repository at this point in the history
Jon/fix/uk-compliance-2
  • Loading branch information
Jon-edge authored Oct 25, 2024
2 parents 7fa75b7 + 540b05c commit ca17e75
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/components/scenes/GuiPluginListScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ class GuiPluginList extends React.PureComponent<Props, State> {
<>
<EdgeAnim style={styles.header} enter={fadeInUp90}>
<SceneHeader
title={direction === 'buy' ? getUkCompliantString(countryCode, 'buy_1s', titleAsset) : getUkCompliantString(countryCode, 'sell_1s', titleAsset)}
title={
direction === 'buy' ? getUkCompliantString(countryCode, 'buy_1s_title', titleAsset) : getUkCompliantString(countryCode, 'sell_1s', titleAsset)
}
underline
withTopMargin
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/themed/TransactionListTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class TransactionListTopComponent extends React.PureComponent<Props, Stat
/>
<SelectableRow
marginRem={0.5}
title={sprintf(lstrings.sell_1s, sceneCurrencyCode)}
title={getUkCompliantString(this.state.countryCode, 'sell_1s', sceneCurrencyCode)}
onPress={() => this.handleTradeSell(bridge)}
icon={
<View style={styles.dualIconContainer}>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,7 @@ const strings = {

uk_ways_to_buy_1s: 'Ways to Buy %1$s',
uk_ways_to_sell_1s: 'Ways to Sell %1$s',
uk_get_quote_provider_1s: 'Get %1$s Quote from 3rd Party Provider',

// #endregion UK Compliance

Expand Down
1 change: 1 addition & 0 deletions src/locales/strings/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@
"button_support": "Contact Support",
"uk_ways_to_buy_1s": "Ways to Buy %1$s",
"uk_ways_to_sell_1s": "Ways to Sell %1$s",
"uk_get_quote_provider_1s": "Get %1$s Quote from 3rd Party Provider",
"redacted_placeholder": "●●●●",
"insufficient_funds_2s": "Insufficient %1$s (%2$s).",
"split_from_1s": "Split from %1$s",
Expand Down
18 changes: 10 additions & 8 deletions src/util/ukComplianceUtils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { LocaleStringKey } from '../locales/en_US'
import { lstrings } from '../locales/strings'

const UK_COMPLIANT_STRING_MAP: { [key: string]: LocaleStringKey } = {
buy_1s: 'uk_ways_to_buy_1s',
sell_1s: 'uk_ways_to_sell_1s',
stake_earn_1s: 'stake_stake_1s',
stake_earn_button_label: 'fragment_stake_label',
stake_x_to_earn_y: 'transaction_details_stake_subcat_1s'
const UK_COMPLIANT_STRING_MAP: { [key: string]: { default: LocaleStringKey; gb: LocaleStringKey } } = {
buy_1s: { default: 'buy_1s', gb: 'uk_ways_to_buy_1s' },
buy_1s_title: { default: 'buy_1s', gb: 'uk_get_quote_provider_1s' },
sell_1s: { default: 'sell_1s', gb: 'uk_ways_to_sell_1s' },
stake_earn_1s: { default: 'stake_earn_1s', gb: 'stake_stake_1s' },
stake_earn_button_label: { default: 'stake_earn_button_label', gb: 'fragment_stake_label' },
stake_x_to_earn_y: { default: 'stake_x_to_earn_y', gb: 'transaction_details_stake_subcat_1s' }
}

const formatString = (template: string, values: string[]): string => {
return template.replace(/%(\d+)\$s/g, (_, index) => values[parseInt(index) - 1] || '')
}

export const getUkCompliantString = (countryCode: string | undefined, key: LocaleStringKey, ...values: string[]): string => {
const template = countryCode === 'GB' ? lstrings[UK_COMPLIANT_STRING_MAP[key]] : lstrings[key]
export const getUkCompliantString = (countryCode: string | undefined, key: string, ...values: string[]): string => {
const compliantStringKeys = UK_COMPLIANT_STRING_MAP[key]
const template = countryCode === 'GB' ? lstrings[compliantStringKeys.gb] : lstrings[compliantStringKeys.default]
return formatString(template, values)
}

0 comments on commit ca17e75

Please sign in to comment.