diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift index a1d07f495..7bdb7e496 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift @@ -13,6 +13,7 @@ import ParticlesKit import PlatformUI import PlatformUIJedio import JedioKit +import dydxStateManager class SettingsLandingViewPresenter: SettingsViewPresenter { @@ -31,13 +32,13 @@ class SettingsLandingViewPresenter: SettingsViewPresenter { } } - var localizerKeyLookup: [String: String] { + var localizerKeyLookup: [String: String]? { switch self { // extracting the localizer key lookup from the definition file reduces sources of truth for the key value mapping case .language: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_language.json") case .theme: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_theme.json") // this one is hardcoded for now, there is no field input definition file for environment selection yet - case .env: return envLocalizerKeyLookup + case .env: return nil case .colorPreference: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_direction_color_preference.json") } } @@ -58,21 +59,19 @@ class SettingsLandingViewPresenter: SettingsViewPresenter { return dictionary } - private static let envLocalizerKeyLookup: [String: String] = [ - "dydxprotocol-testnet": "APP.HEADER.TESTNET", - "1": "APP.HEADER.MAINNET" - ] - override func createOutputItem(output: FieldOutput) -> FieldOutputTextViewModel { let textViewModel = super.createOutputItem(output: output) guard let link = output.link, let deepLink = DeepLink(rawValue: link), - let localizerKey = SettingsStore.shared?.value(forKey: deepLink.settingsStoreKey) as? String, - let displayTextKey = deepLink.localizerKeyLookup[localizerKey] + let localizerKey = SettingsStore.shared?.value(forKey: deepLink.settingsStoreKey) as? String else { return textViewModel } - textViewModel.text = DataLocalizer.shared?.localize(path: displayTextKey, params: nil) + if let displayTextKey = deepLink.localizerKeyLookup?[localizerKey] { + textViewModel.text = DataLocalizer.shared?.localize(path: displayTextKey, params: nil) + } else if let env = AbacusStateManager.shared.availableEnvironments.first(where: { $0.type == localizerKey }) { + textViewModel.text = env.localizedString + } return textViewModel }