From a70b42a1e27f5ec7cba749a61b63836323efad2e Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Mon, 4 Nov 2024 12:55:26 +0900 Subject: [PATCH] Finish localization --- .../components/default/vpn/vpn_card.tsx | 45 ++++++------------- .../containers/newTab/index.tsx | 2 +- .../containers/newTab/settings/cards.tsx | 4 +- .../resources/panel/stories/locale.ts | 8 +++- .../resources/panel/stories/mock-data/api.ts | 1 - .../resources/brave_components_strings.grd | 3 -- components/resources/brave_vpn_strings.grdp | 21 +++++++++ components/webui/webui_resources.cc | 19 ++++++-- 8 files changed, 61 insertions(+), 42 deletions(-) diff --git a/components/brave_new_tab_ui/components/default/vpn/vpn_card.tsx b/components/brave_new_tab_ui/components/default/vpn/vpn_card.tsx index fdedd368c6a7..9bb2c9eb65a2 100644 --- a/components/brave_new_tab_ui/components/default/vpn/vpn_card.tsx +++ b/components/brave_new_tab_ui/components/default/vpn/vpn_card.tsx @@ -7,34 +7,17 @@ import * as React from 'react' import { useDispatch } from 'react-redux' import Toggle from '@brave/leo/react/toggle' +import { getLocale } from '$web-common/locale' import * as S from './styles' import VPNShieldsConnecting from './vpn-shields-connecting' import * as Actions from '../../../actions/brave_vpn_actions' import { ConnectionState, Region } from '../../../api/braveVpn' -// Delete this. -const locales = { - firewallVpn: 'Brave VPN', - connected: 'Connected', - connecting: 'Connecting', - disconnected: 'Disconnected', - disconnecting: 'Disconnecting', - change: 'Change', - optimal: 'Optimal', - - promo: { - heading: 'Extra privacy & security online', - poweredBy: 'Powered by', - cta: 'Start free trial', - freeTrial: '7-day free trial' - } -} - export const VPNWidgetTitle = () => { return ( <> - {locales.firewallVpn} + {getLocale('braveVpnWidgetTitle')} ) } @@ -52,9 +35,9 @@ export const VPNPromoWidget = () => { const featureList = React.useMemo( () => [ - 'Extra privacy & security online', - 'Hide your IP & change your location', - 'Protect every app on your device' + getLocale('braveVpnFeature1'), + getLocale('braveVpnFeature2'), + getLocale('braveVpnWidgetFeature3') ], [] ) @@ -64,7 +47,7 @@ export const VPNPromoWidget = () => { - {locales.promo.poweredBy} + {getLocale('braveVpnPoweredBy')} @@ -79,9 +62,9 @@ export const VPNPromoWidget = () => { dispatch(Actions.openVPNAccountPage())} > - {locales.promo.cta} + {getLocale('braveVpnCTA')} - {locales.promo.freeTrial} + {getLocale('braveVpnFreeTrial')} @@ -91,16 +74,16 @@ export const VPNPromoWidget = () => { function GetConnectionStateLabel(connectionState: ConnectionState) { switch (connectionState) { case ConnectionState.CONNECTED: - return locales.connected + return getLocale('braveVpnConnected') case ConnectionState.CONNECTING: - return locales.connecting + return getLocale('braveVpnConnecting') case ConnectionState.DISCONNECTING: - return locales.disconnecting + return getLocale('braveVpnDisconnecting') default: break } - return locales.disconnected + return getLocale('braveVpnDisconnected') } interface MainWidgetProps { @@ -133,12 +116,12 @@ export const VPNMainWidget = (props: MainWidgetProps) => { dispatch(Actions.launchVPNPanel())} > - {locales.change} + {getLocale('braveVpnChangeRegion')} {props.selectedRegion.namePretty === props.selectedRegion.country - ? locales.optimal + ? getLocale('braveVpnOptimal') : props.selectedRegion.namePretty} diff --git a/components/brave_new_tab_ui/containers/newTab/index.tsx b/components/brave_new_tab_ui/containers/newTab/index.tsx index 04eaff75e2d3..7775d5a558af 100644 --- a/components/brave_new_tab_ui/containers/newTab/index.tsx +++ b/components/brave_new_tab_ui/containers/newTab/index.tsx @@ -607,7 +607,7 @@ class NewTabPage extends React.Component { paddingType={'none'} menuPosition={'left'} textDirection={textDirection} - widgetTitle={getLocale('braveVPNWidgetTitle')} + widgetTitle={getLocale('braveVpnWidgetTitle')} onShowContent={this.setForegroundStackWidget.bind(this, 'braveVPN')} isForeground={showContent} showContent={showContent} diff --git a/components/brave_new_tab_ui/containers/newTab/settings/cards.tsx b/components/brave_new_tab_ui/containers/newTab/settings/cards.tsx index a494bdd55b17..82250f90bc51 100644 --- a/components/brave_new_tab_ui/containers/newTab/settings/cards.tsx +++ b/components/brave_new_tab_ui/containers/newTab/settings/cards.tsx @@ -92,10 +92,10 @@ function CardSettings({ toggleShowBraveTalk, showBraveTalk, braveTalkSupported, - {getLocale('braveVPNWidgetSettingTitle')} + {getLocale('braveVpnWidgetSettingTitle')} - {getLocale('braveVPNWidgetSettingDesc')} + {getLocale('braveVpnWidgetSettingDesc')} diff --git a/components/brave_vpn/resources/panel/stories/locale.ts b/components/brave_vpn/resources/panel/stories/locale.ts index b2c8290bebd6..28f32ee2b5d6 100644 --- a/components/brave_vpn/resources/panel/stories/locale.ts +++ b/components/brave_vpn/resources/panel/stories/locale.ts @@ -83,5 +83,11 @@ provideStrings({ 'VPN connection failed. Please try connecting again, and be sure to click "Allow" to enable Brave\'s VPN configuration.', braveVpnSessionExpiredTitle: 'Session expired', braveVpnSessionExpiredContent: - 'Please log in to your $1Brave Account$2 to refresh your VPN session.' + 'Please log in to your $1Brave Account$2 to refresh your VPN session.', + braveVpnWidgetTitle: 'Brave VPN', + braveVpnWidgetFeature3: 'Protect every app on your device', + braveVpnOptimal: 'Optimal', + braveVpnChangeRegion: 'Change', + braveVpnCTA: 'Start free trial', + braveVpnFreeTrial: '7-day free trial' }) diff --git a/components/brave_vpn/resources/panel/stories/mock-data/api.ts b/components/brave_vpn/resources/panel/stories/mock-data/api.ts index c910dd871431..77f01e5d707d 100644 --- a/components/brave_vpn/resources/panel/stories/mock-data/api.ts +++ b/components/brave_vpn/resources/panel/stories/mock-data/api.ts @@ -21,7 +21,6 @@ BraveVPN.setPanelBrowserApiForTesting({ }, serviceHandler: { addObserver: doNothing, - initialize: doNothing, getPurchasedState: () => Promise.resolve({ state: loadingState }), getConnectionState: () => Promise.resolve({ state: BraveVPN.ConnectionState.CONNECTED }), resetConnectionState: doNothing, diff --git a/components/resources/brave_components_strings.grd b/components/resources/brave_components_strings.grd index 5ca8acfa42d6..b95345040460 100644 --- a/components/resources/brave_components_strings.grd +++ b/components/resources/brave_components_strings.grd @@ -756,9 +756,6 @@ Start call About your data - Brave VPN - Extra privacy & security online - Wallet diff --git a/components/resources/brave_vpn_strings.grdp b/components/resources/brave_vpn_strings.grdp index aadf24a2ccaf..1c9c561e1d46 100644 --- a/components/resources/brave_vpn_strings.grdp +++ b/components/resources/brave_vpn_strings.grdp @@ -424,4 +424,25 @@ Let's get you connected! Remove icon + + + + Protect every app on your device + + + Brave VPN + + + Extra privacy & security online. + + + Change + + + Start free trial + + + 7-day free trial + + diff --git a/components/webui/webui_resources.cc b/components/webui/webui_resources.cc index 815e00491bac..5318e62121a1 100644 --- a/components/webui/webui_resources.cc +++ b/components/webui/webui_resources.cc @@ -413,9 +413,22 @@ base::span GetWebUILocalizedStrings( {"loading", IDS_BRAVE_REWARDS_LOADING_LABEL}, // Brave VPN Widget - {"braveVPNWidgetTitle", IDS_BRAVE_VPN_WIDGET_TITLE}, - {"braveVPNWidgetSettingTitle", IDS_BRAVE_VPN_WIDGET_TITLE}, - {"braveVPNWidgetSettingDesc", IDS_BRAVE_VPN_WIDGET_SETTING_DESC}, + {"braveVpnWidgetTitle", IDS_BRAVE_VPN_WIDGET_TITLE}, + {"braveVpnWidgetSettingTitle", IDS_BRAVE_VPN_WIDGET_TITLE}, + {"braveVpnWidgetSettingDesc", IDS_BRAVE_VPN_WIDGET_SETTING_DESC}, + {"braveVpnFeature1", IDS_BRAVE_VPN_FEATURE_1}, + {"braveVpnFeature2", IDS_BRAVE_VPN_FEATURE_2}, + {"braveVpnWidgetFeature3", IDS_BRAVE_VPN_WIDGET_FEATURE_3}, + {"braveVpnConnected", IDS_BRAVE_VPN_CONNECTED}, + {"braveVpnConnecting", IDS_BRAVE_VPN_CONNECTING}, + {"braveVpnDisconnected", IDS_BRAVE_VPN_DISCONNECTED}, + {"braveVpnDisconnecting", IDS_BRAVE_VPN_DISCONNECTING}, + {"braveVpnPoweredBy", IDS_BRAVE_VPN_POWERED_BY}, + {"braveVpnOptimal", + IDS_BRAVE_VPN_SERVER_SELECTION_OPTIMAL_LABEL}, + {"braveVpnChangeRegion", IDS_BRAVE_VPN_WIDGET_CHANGE_LABEL}, + {"braveVpnCTA", IDS_BRAVE_VPN_WIDGET_CTA}, + {"braveVpnFreeTrial", IDS_BRAVE_VPN_WIDGET_FREE_TRIAL}, // Brave Talk Widget {"braveTalkWidgetTitle", IDS_BRAVE_TALK_WIDGET_TITLE},