瀏覽代碼

Remove l11n unsafe direct string manipulation

Manav Rathi 1 年之前
父節點
當前提交
7c0ab6dd8a

+ 1 - 4
web/apps/photos/src/components/pages/gallery/PlanSelector/card/index.tsx

@@ -24,7 +24,6 @@ import {
     planForSubscription,
     updateSubscription,
 } from "utils/billing";
-import { reverseString } from "utils/common";
 import { getLocalUserDetails } from "utils/user";
 import { getTotalFamilyUsage, isPartOfFamily } from "utils/user/family";
 import FreeSubscriptionPlanSelectorCard from "./free";
@@ -130,9 +129,7 @@ function PlanSelectorCard(props: Props) {
             }
         } else if (hasStripeSubscription(subscription)) {
             appContext.setDialogMessage({
-                title: `${t("CONFIRM")} ${reverseString(
-                    t("UPDATE_SUBSCRIPTION"),
-                )}`,
+                title: t("update_subscription_title"),
                 content: t("UPDATE_SUBSCRIPTION_MESSAGE"),
                 proceed: {
                     text: t("UPDATE_SUBSCRIPTION"),

+ 1 - 6
web/apps/photos/src/utils/common/index.ts

@@ -13,12 +13,6 @@ export function downloadApp() {
     openLink(APP_DOWNLOAD_URL, true);
 }
 
-export function reverseString(title: string) {
-    return title
-        ?.split(" ")
-        .reduce((reversedString, currWord) => `${currWord} ${reversedString}`);
-}
-
 export function initiateEmail(email: string) {
     const a = document.createElement("a");
     a.href = "mailto:" + email;
@@ -33,6 +27,7 @@ export const preloadImage = (imgBasePath: string) => {
     }
     new Image().srcset = srcSet.join(",");
 };
+
 export function openLink(href: string, newTab?: boolean) {
     const a = document.createElement("a");
     a.href = href;

+ 1 - 0
web/packages/next/locales/en-US/translation.json

@@ -168,6 +168,7 @@
     "UPDATE_PAYMENT_METHOD": "Update payment method",
     "MONTHLY": "Monthly",
     "YEARLY": "Yearly",
+    "update_subscription_title": "Confirm plan change",
     "UPDATE_SUBSCRIPTION_MESSAGE": "Are you sure you want to change your plan?",
     "UPDATE_SUBSCRIPTION": "Change plan",
     "CANCEL_SUBSCRIPTION": "Cancel subscription",