diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 2f176ef..3f77059 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -148,7 +148,8 @@
                         break;
                 }
             }
-            preference.setSummary(resId);
+            preference.setSummary(
+                    SubscriptionManager.getResourcesForSubId(mContext, mSubId).getText(resId));
         }
         preference.setEnabled(mCallState == TelephonyManager.CALL_STATE_IDLE);
     }
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 8447fcf..025375c 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -340,19 +340,45 @@
             }
         }
 
-        if (!isWifiOnlySupported) {
-            mButtonWfcMode.setEntries(R.array.wifi_calling_mode_choices_without_wifi_only);
-            mButtonWfcMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only);
-            mButtonWfcMode.setEntrySummaries(R.array.wifi_calling_mode_summaries_without_wifi_only);
+        Resources res = getResourcesForSubId();
+        mButtonWfcMode.setTitle(res.getString(R.string.wifi_calling_mode_title));
+        mButtonWfcMode.setDialogTitle(res.getString(R.string.wifi_calling_mode_dialog_title));
+        mButtonWfcRoamingMode.setTitle(res.getString(R.string.wifi_calling_roaming_mode_title));
+        mButtonWfcRoamingMode.setDialogTitle(
+                res.getString(R.string.wifi_calling_roaming_mode_dialog_title));
 
+        if (isWifiOnlySupported) {
+            // Set string resources WITH option wifi only in mButtonWfcMode.
+            mButtonWfcMode.setEntries(
+                    res.getStringArray(R.array.wifi_calling_mode_choices));
+            mButtonWfcMode.setEntryValues(res.getStringArray(R.array.wifi_calling_mode_values));
+            mButtonWfcMode.setEntrySummaries(
+                    res.getStringArray(R.array.wifi_calling_mode_summaries));
+
+            // Set string resources WITH option wifi only in mButtonWfcRoamingMode.
             mButtonWfcRoamingMode.setEntries(
-                    R.array.wifi_calling_mode_choices_v2_without_wifi_only);
+                    res.getStringArray(R.array.wifi_calling_mode_choices_v2));
             mButtonWfcRoamingMode.setEntryValues(
-                    R.array.wifi_calling_mode_values_without_wifi_only);
+                    res.getStringArray(R.array.wifi_calling_mode_values));
             mButtonWfcRoamingMode.setEntrySummaries(
-                    R.array.wifi_calling_mode_summaries_without_wifi_only);
-        }
+                    res.getStringArray(R.array.wifi_calling_mode_summaries));
+        } else {
+            // Set string resources WITHOUT option wifi only in mButtonWfcMode.
+            mButtonWfcMode.setEntries(
+                    res.getStringArray(R.array.wifi_calling_mode_choices_without_wifi_only));
+            mButtonWfcMode.setEntryValues(
+                    res.getStringArray(R.array.wifi_calling_mode_values_without_wifi_only));
+            mButtonWfcMode.setEntrySummaries(
+                    res.getStringArray(R.array.wifi_calling_mode_summaries_without_wifi_only));
 
+            // Set string resources WITHOUT option wifi only in mButtonWfcRoamingMode.
+            mButtonWfcRoamingMode.setEntries(
+                    res.getStringArray(R.array.wifi_calling_mode_choices_v2_without_wifi_only));
+            mButtonWfcRoamingMode.setEntryValues(
+                    res.getStringArray(R.array.wifi_calling_mode_values_without_wifi_only));
+            mButtonWfcRoamingMode.setEntrySummaries(
+                    res.getStringArray(R.array.wifi_calling_mode_summaries_without_wifi_only));
+        }
 
         // NOTE: Buttons will be enabled/disabled in mPhoneStateListener
         final boolean wfcEnabled = mImsManager.isWfcEnabledByUser()
@@ -589,7 +615,7 @@
         return true;
     }
 
-    private int getWfcModeSummary(int wfcMode) {
+    private CharSequence getWfcModeSummary(int wfcMode) {
         int resId = com.android.internal.R.string.wifi_calling_off_summary;
         if (mImsManager.isWfcEnabledByUser()) {
             switch (wfcMode) {
@@ -606,7 +632,7 @@
                     Log.e(TAG, "Unexpected WFC mode value: " + wfcMode);
             }
         }
-        return resId;
+        return getResourcesForSubId().getString(resId);
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 68a4b40..967146c 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -25,6 +25,7 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.res.Resources;
 import android.net.Uri;
 import android.os.PersistableBundle;
 import android.provider.Settings;
@@ -131,6 +132,7 @@
      */
     public Slice createWifiCallingSlice(Uri sliceUri) {
         final int subId = getDefaultVoiceSubId();
+        Resources res = getResourcesForSubId(subId);
 
         if (subId <= SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             Log.d(TAG, "Invalid subscription Id");
@@ -157,12 +159,11 @@
                 // Activation needed for the next action of the user
                 // Give instructions to go to settings app
                 return getNonActionableWifiCallingSlice(
-                        mContext.getText(R.string.wifi_calling_settings_title),
-                        mContext.getText(
-                                R.string.wifi_calling_settings_activation_instructions),
+                        res.getText(R.string.wifi_calling_settings_title),
+                        res.getText(R.string.wifi_calling_settings_activation_instructions),
                         sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY));
             }
-            return getWifiCallingSlice(sliceUri, isWifiCallingEnabled);
+            return getWifiCallingSlice(sliceUri, isWifiCallingEnabled, subId);
         } catch (InterruptedException | TimeoutException | ExecutionException e) {
             Log.e(TAG, "Unable to read the current WiFi calling status", e);
             return null;
@@ -188,13 +189,14 @@
      * Builds a toggle slice where the intent takes you to the wifi calling page and the toggle
      * enables/disables wifi calling.
      */
-    private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled) {
+    private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled, int subId) {
         final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
+        Resources res = getResourcesForSubId(subId);
 
         return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
                 .setAccentColor(Utils.getColorAccentDefaultColor(mContext))
                 .addRow(new RowBuilder()
-                        .setTitle(mContext.getText(R.string.wifi_calling_settings_title))
+                        .setTitle(res.getText(R.string.wifi_calling_settings_title))
                         .addEndItem(
                                 SliceAction.createToggle(
                                         getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
@@ -203,7 +205,7 @@
                                 getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
                                 icon,
                                 ListBuilder.ICON_IMAGE,
-                                mContext.getText(R.string.wifi_calling_settings_title))))
+                                res.getText(R.string.wifi_calling_settings_title))))
                 .build();
     }
 
@@ -259,14 +261,15 @@
         }
         if (!isWifiCallingEnabled) {
             // wifi calling is not enabled. Ask user to enable wifi calling
+            Resources res = getResourcesForSubId(subId);
             return getNonActionableWifiCallingSlice(
-                    mContext.getText(R.string.wifi_calling_mode_title),
-                    mContext.getText(R.string.wifi_calling_turn_on),
+                    res.getText(R.string.wifi_calling_mode_title),
+                    res.getText(R.string.wifi_calling_turn_on),
                     sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY));
         }
         // Return the slice to change wifi calling preference
         return getWifiCallingPreferenceSlice(
-                isWifiOnlySupported, wfcMode, sliceUri);
+                isWifiOnlySupported, wfcMode, sliceUri, subId);
     }
 
     /**
@@ -275,40 +278,43 @@
      * @param isWifiOnlySupported adds row for wifi only if this is true
      * @param currentWfcPref      current Preference {@link ImsConfig}
      * @param sliceUri            sliceUri
+     * @param subId               subscription id
      * @return Slice for actionable wifi calling preference settings
      */
     private Slice getWifiCallingPreferenceSlice(boolean isWifiOnlySupported,
             int currentWfcPref,
-            Uri sliceUri) {
+            Uri sliceUri,
+            int subId) {
         final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
+        Resources res = getResourcesForSubId(subId);
         // Top row shows information on current preference state
         final ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
                 .setAccentColor(Utils.getColorAccentDefaultColor(mContext));
         listBuilder.setHeader(new ListBuilder.HeaderBuilder()
-                .setTitle(mContext.getText(R.string.wifi_calling_mode_title))
-                .setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref))
+                .setTitle(res.getText(R.string.wifi_calling_mode_title))
+                .setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref, subId))
                 .setPrimaryAction(SliceAction.createDeeplink(
                         getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
                         icon,
                         ListBuilder.ICON_IMAGE,
-                        mContext.getText(R.string.wifi_calling_mode_title))));
+                        res.getText(R.string.wifi_calling_mode_title))));
 
         if (isWifiOnlySupported) {
             listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
                     com.android.internal.R.string.wfc_mode_wifi_only_summary,
                     ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY,
-                    currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_ONLY));
+                    currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_ONLY, subId));
         }
 
         listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
                 com.android.internal.R.string.wfc_mode_wifi_preferred_summary,
                 ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED,
-                currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED));
+                currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED, subId));
 
         listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
                 com.android.internal.R.string.wfc_mode_cellular_preferred_summary,
                 ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED,
-                currentWfcPref == ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
+                currentWfcPref == ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, subId));
 
         return listBuilder.build();
     }
@@ -319,16 +325,18 @@
      * @param listBuilder          ListBuilder that will be the parent for this RowBuilder
      * @param preferenceTitleResId resource Id for the preference row title
      * @param action               action to be added for the row
+     * @param subId                subscription id
      * @return RowBuilder for the row
      */
     private RowBuilder wifiPreferenceRowBuilder(ListBuilder listBuilder,
-            int preferenceTitleResId, String action, boolean checked) {
+            int preferenceTitleResId, String action, boolean checked, int subId) {
         final IconCompat icon =
                 IconCompat.createWithResource(mContext, R.drawable.radio_button_check);
+        Resources res = getResourcesForSubId(subId);
         return new RowBuilder()
-                .setTitle(mContext.getText(preferenceTitleResId))
+                .setTitle(res.getText(preferenceTitleResId))
                 .setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
-                        icon, mContext.getText(preferenceTitleResId), checked));
+                        icon, res.getText(preferenceTitleResId), checked));
     }
 
 
@@ -338,16 +346,17 @@
      * @param wfcMode ImsConfig constant for the preference {@link ImsConfig}
      * @return summary/name of the wifi calling preference
      */
-    private CharSequence getWifiCallingPreferenceSummary(int wfcMode) {
+    private CharSequence getWifiCallingPreferenceSummary(int wfcMode, int subId) {
+        Resources res = getResourcesForSubId(subId);
         switch (wfcMode) {
             case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
-                return mContext.getText(
+                return res.getText(
                         com.android.internal.R.string.wfc_mode_wifi_only_summary);
             case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
-                return mContext.getText(
+                return res.getText(
                         com.android.internal.R.string.wfc_mode_wifi_preferred_summary);
             case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
-                return mContext.getText(
+                return res.getText(
                         com.android.internal.R.string.wfc_mode_cellular_preferred_summary);
             default:
                 return null;
@@ -573,4 +582,8 @@
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
     }
+
+    private Resources getResourcesForSubId(int subId) {
+        return SubscriptionManager.getResourcesForSubId(mContext, subId);
+    }
 }
