Skip to content

Commit c9ceefb

Browse files
fix(earn): extract the pool description for translation
1 parent c7d7e83 commit c9ceefb

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { BLEND_FIXED_POOL_IDS } from "@shared/constants/blend";
2+
import { NETWORKS } from "@shared/constants/stellar";
13
import i18n from "popup/helpers/localizationConfig";
24

35
/**
@@ -9,18 +11,29 @@ import i18n from "popup/helpers/localizationConfig";
911
* admin account is burned (master weight 0, no signers, all thresholds 0), so
1012
* "no admin" is a fact about that pool, not about Blend pools in general.
1113
*
14+
* Each entry is a thunk holding a literal `i18n.t` call, for two reasons. The
15+
* i18next scanner extracts keys by reading the literal argument of a `t()` call
16+
* (see `func.list` in webpack.extension.js), so passing a variable — a string
17+
* looked up out of this map — extracts nothing: the key never lands in
18+
* translation.json, i18next falls back to returning the key itself, and the copy
19+
* renders in English in every language while looking correct in en. And the
20+
* thunk keeps resolution lazy, where a bare `i18n.t` at module scope would run
21+
* before the language bundle has loaded.
22+
*
1223
* A pool with no entry renders no description rather than a wrong one.
1324
*/
14-
const POOL_DESCRIPTION_KEYS: Record<string, string> = {
25+
const POOL_DESCRIPTIONS: Record<string, () => string> = {
1526
// Fixed Pool v2 — mainnet
16-
CAJJZSGMMM3PD7N33TAPHGBUGTB43OC73HVIK2L2G6BNGGGYOSSYBXBD:
17-
"Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.",
27+
[BLEND_FIXED_POOL_IDS[NETWORKS.PUBLIC]!]: () =>
28+
i18n.t(
29+
"Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.",
30+
),
1831
// Fixed Pool v2 — testnet
19-
CCEBVDYM32YNYCVNRXQKDFFPISJJCV557CDZEIRBEE4NCV4KHPQ44HGF:
20-
"Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.",
32+
[BLEND_FIXED_POOL_IDS[NETWORKS.TESTNET]!]: () =>
33+
i18n.t(
34+
"Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.",
35+
),
2136
};
2237

23-
export const getPoolDescription = (poolId: string): string | null => {
24-
const description = POOL_DESCRIPTION_KEYS[poolId];
25-
return description ? i18n.t(description) : null;
26-
};
38+
export const getPoolDescription = (poolId: string): string | null =>
39+
POOL_DESCRIPTIONS[poolId]?.() ?? null;

extension/src/popup/locales/__tests__/translationParity.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ const earnKeys = [
5151
"Add XLM to your wallet to continue",
5252
"Transaction failed. Try again.",
5353
"Pool Details",
54+
// Reached through a lookup table rather than a literal `t()` argument, so the
55+
// scanner cannot see it — the one earn string that has to be listed here to
56+
// stay extracted. See PoolDetailsSheet/poolDescriptions.ts.
57+
"Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.",
5458
"Lending Interest",
5559
"Current Net APY",
5660
"Accepted tokens",

extension/src/popup/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@
478478
"Password": "Password",
479479
"Path": "Path",
480480
"Payment token logo": "Payment token logo",
481+
"Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.": "Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.",
481482
"Pin Freighter to the toolbar": "Pin Freighter to the toolbar",
482483
"Please check if the network information is correct and try again.": "Please check if the network information is correct and try again.",
483484
"Please check the asset code or address.": "Please check the asset code or address.",

extension/src/popup/locales/pt/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@
478478
"Password": "Senha",
479479
"Path": "Caminho",
480480
"Payment token logo": "Logotipo do token de pagamento",
481+
"Permissionless lending pool with no admin. Collateral factors, interest curves, and supported assets are locked at deployment.": "Pool de empréstimo sem permissão e sem administrador. Fatores de garantia, curvas de juros e ativos compatíveis são fixados na implantação.",
481482
"Pin Freighter to the toolbar": "Fixar Freighter na toolbar",
482483
"Please check if the network information is correct and try again.": "Por favor, verifique se as informações da rede estão corretas e tente novamente.",
483484
"Please check the asset code or address.": "Por favor, verifique o código do ativo ou endereço.",

0 commit comments

Comments
 (0)