Parcourir la source

Set resource qualifier for german language, worked on serverlist screen multi lingual

Khubaib il y a 6 mois
Parent
commit
87e8c780bd

+ 1 - 1
app/src/main/java/com/vpn/fastestvpnservice/customItems/CountryItem.kt

@@ -180,7 +180,7 @@ fun CountryItem(
                         .align(Alignment.CenterVertically)
                 )
                 Spacer(modifier = Modifier.weight(1F))
-                Text(text = "$countryTotalServers locations",
+                Text(text = "$countryTotalServers ${context.getString(R.string.locations)}",
                     style = MaterialTheme.typography.bodySmall,
                     color = colorResource(id = R.color.dark_blue_gray_text),
                     modifier = Modifier

+ 27 - 15
app/src/main/java/com/vpn/fastestvpnservice/screens/ServerListScreen.kt

@@ -1,6 +1,7 @@
 package com.vpn.fastestvpnservice.screens
 
 import android.app.Activity
+import android.content.Context
 import android.content.res.Configuration
 import android.util.Log
 import androidx.compose.foundation.ExperimentalFoundationApi
@@ -141,18 +142,18 @@ fun ServerList(
         window.statusBarColor = Color.Transparent.toArgb()
         window.navigationBarColor = Color.Transparent.toArgb()
 
-        HeaderRowSL(navHostController = navHostController)
+        HeaderRowSL(navHostController = navHostController, context)
         Column(
             modifier = Modifier
                 .padding(horizontal = 16.dp)
                 .padding(top = 35.dp)
                 .background(Color.Transparent)
         ) {
-            ShowSearchBar(serverListViewModel, basePreferenceHelper, navHostController)
+            ShowSearchBar(serverListViewModel, basePreferenceHelper, navHostController, context)
 
             val currentPageIndex = if (Screen.ServerList.isTrue) 1 else 0
             val scope = rememberCoroutineScope()
-            val serverTabItems = listOf("Recommended", "All Locations")
+            val serverTabItems = listOf(context.getString(R.string.recommended), context.getString(R.string.all_locations))
             val pagerState = rememberPagerState(initialPage = currentPageIndex, pageCount = {serverTabItems.size})
             val selectedIndex by remember { derivedStateOf { pagerState.currentPage } }
 
@@ -236,7 +237,7 @@ fun ServerList(
                             .padding(top = 0.dp, bottom = 10.dp)
                     ) {
                         if (page == 0) {
-                            ShowRecommendedList(serverListViewModel, basePreferenceHelper, navHostController)
+                            ShowRecommendedList(serverListViewModel, basePreferenceHelper, navHostController, context)
                         }
                         else if (page == 1) {
                             ShowAllLocationsList(serverListViewModel, basePreferenceHelper, navHostController)
@@ -250,7 +251,7 @@ fun ServerList(
 
 @Composable
 fun BoxScope.HeaderRowSL(
-    navHostController: NavHostController) {
+    navHostController: NavHostController, context: Context) {
     IconButton(
         onClick = {
             navHostController.popBackStack()
@@ -277,7 +278,7 @@ fun BoxScope.HeaderRowSL(
             .padding(5.dp),
         color = colorResource(id = R.color.transparent)
     ) {
-        Text(text = "Select Location",
+        Text(text = context.getString(R.string.select_location),
             style = MaterialTheme.typography.bodyMedium,
             color = MaterialTheme.colorScheme.primary,
             modifier = Modifier.fillMaxHeight()
@@ -290,7 +291,8 @@ fun BoxScope.HeaderRowSL(
 fun ColumnScope.ShowRecommendedList(
     serverListViewModel: ServerListViewModel,
     prefHelper: BasePreferenceHelper,
-    navHostController: NavHostController
+    navHostController: NavHostController,
+    context: Context
 ) {
     CompositionLocalProvider(
         LocalOverscrollConfiguration provides null
@@ -330,7 +332,7 @@ fun ColumnScope.ShowRecommendedList(
                             .padding(bottom = 0.dp)
                             .size(19.dp)
                     )
-                    Text(text = "Favorite Location",
+                    Text(text = context.getString(R.string.favorite_location),
                         style = MaterialTheme.typography.titleSmall,
                         color = MaterialTheme.colorScheme.primary,
                         modifier = Modifier
@@ -375,7 +377,7 @@ fun ColumnScope.ShowRecommendedList(
                             .padding(bottom = 0.dp)
                             .size(19.dp)
                     )
-                    Text(text = "Smart Location",
+                    Text(text = context.getString(R.string.smart_location),
                         style = MaterialTheme.typography.titleSmall,
                         color = MaterialTheme.colorScheme.primary,
                         modifier = Modifier
@@ -407,7 +409,7 @@ fun ColumnScope.ShowRecommendedList(
                             .padding(bottom = 0.dp)
                             .size(19.dp)
                     )
-                    Text(text = "Recent Location",
+                    Text(text = context.getString(R.string.recent_location),
                         style = MaterialTheme.typography.titleSmall,
                         color = MaterialTheme.colorScheme.primary,
                         modifier = Modifier
@@ -447,7 +449,7 @@ fun ColumnScope.ShowRecommendedList(
                             .padding(bottom = 0.dp)
                             .size(19.dp)
                     )
-                    Text(text = "Recommended Location",
+                    Text(text = context.getString(R.string.recommended_location),
                         style = MaterialTheme.typography.titleSmall,
                         color = MaterialTheme.colorScheme.primary,
                         modifier = Modifier
@@ -771,7 +773,8 @@ fun ColumnScope.ShowHeaderItem(
 fun ColumnScope.ShowSearchBar(
     serverListViewModel: ServerListViewModel,
     basePreferenceHelper: BasePreferenceHelper,
-    navHostController: NavHostController) {
+    navHostController: NavHostController,
+    context: Context) {
 //    var isActive by remember { mutableStateOf(false) }
 //    val searchText = searchListViewModel.searchText.collectAsState().value
 
@@ -817,7 +820,7 @@ fun ColumnScope.ShowSearchBar(
         },
         placeholder = {
             Text(
-                text = "Search Location",
+                text = context.getString(R.string.search_location),
                 style = MaterialTheme.typography.displaySmall,
                 color = MaterialTheme.colorScheme.primary
             )
@@ -902,7 +905,7 @@ fun ColumnScope.ShowSearchBar(
                     horizontalAlignment = Alignment.Start
                 ) {
                     AddTextSettings(
-                        text = "Sort By",
+                        text = context.getString(R.string.sort_by),
                         size = 18.sp,
                         color = MaterialTheme.colorScheme.primary,
                         bottomPadding = 20.dp,
@@ -910,6 +913,15 @@ fun ColumnScope.ShowSearchBar(
                         style = MaterialTheme.typography.titleMedium
                     )
                     filterList.forEach { filter ->
+                        var filterListLingual: String = ""
+                        when (filter) {
+                            filterList[0] -> {
+                                filterListLingual = context.getString(R.string.popularity)
+                            }
+                            filterList[1] -> {
+                                filterListLingual = context.getString(R.string.alphabetically)
+                            }
+                        }
                         Row(
                             modifier = Modifier
                                 .fillMaxWidth()
@@ -939,7 +951,7 @@ fun ColumnScope.ShowSearchBar(
                                     selectedColor = colorResource(id = R.color.radio_button_blue),
                                     unselectedColor = colorResource(id = R.color.gray_icon)),
                             )
-                            Text(text = filter,
+                            Text(text = filterListLingual,
                                 modifier = Modifier.padding(start = 12.dp),
                                 color = MaterialTheme.colorScheme.primary,
                                 style = MaterialTheme.typography.bodySmall

+ 13 - 0
app/src/main/res/values-de/strings.xml

@@ -64,4 +64,17 @@
     <string name="no">NEIN</string>
     <string name="yes">Ja</string>
 
+    <!-- Server List Screen -->
+    <string name="select_location">Wählen Sie Standort aus</string>
+    <string name="search_location">Standort suchen</string>
+    <string name="all_locations">Alle Standorte</string>
+    <string name="locations">Standorte</string>
+    <string name="favorite_location">Lieblingsstandort</string>
+    <string name="smart_location">Intelligenter Standort</string>
+    <string name="recent_location">Aktueller Standort</string>
+    <string name="recommended_location">Empfohlener Standort</string>
+    <string name="sort_by">Sortieren nach</string>
+    <string name="popularity">Popularität</string>
+    <string name="alphabetically">Alphabetisch</string>
+
 </resources>

+ 13 - 0
app/src/main/res/values/strings.xml

@@ -569,4 +569,17 @@
     <string name="no">No</string>
     <string name="yes">Yes</string>
 
+    <!-- Server List Screen -->
+    <string name="select_location">Select Location</string>
+    <string name="search_location">Search Location</string>
+    <string name="all_locations">All Locations</string>
+    <string name="locations">locations</string>
+    <string name="favorite_location">Favorite Location</string>
+    <string name="smart_location">Smart Location</string>
+    <string name="recent_location">Recent Location</string>
+    <string name="recommended_location">Recommended Location</string>
+    <string name="sort_by">Sort By</string>
+    <string name="popularity">Popularity</string>
+    <string name="alphabetically">Alphabetically</string>
+
 </resources>