Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.7 kB
1
Indexable
         if Locale.preferredLanguages.contains("en-GB") == true{
             
             var catDefaultSlot = MapboxSearchUI.DefaultCategoryDataProvider().categorySlots
             var catDefaultList = MapboxSearchUI.DefaultCategoryDataProvider().categoryList
             
             let newCateSlot = ["name":"Petrol", "iconName": "maki/fuel", "legacyName": "fuel", "canonicalId": "gas_station"]
             let newCateList = ["name":"Petrol Station", "iconName": "maki/fuel", "legacyName": "fuel", "canonicalId": "gas_station"]
             
             for singlgeCate in catDefaultSlot{
                 if singlgeCate.name == "Gas"{
                      catDefaultSlot.remove(element: singlgeCate)

                 }
             }
             
             for singlgeCate in catDefaultList{
                 if singlgeCate.name == "Gas Station"{
                     catDefaultList.remove(element: singlgeCate)
                 }
             }
             
             let jsonEncoder = JSONEncoder()
             let jsonDataSlot = try? jsonEncoder.encode(newCateSlot)
             let finalSlot = (try? JSONDecoder().decode(SearchCategory.self, from: jsonDataSlot!))!
             
             let jsonDataList = try? jsonEncoder.encode(newCateList)
             let finalList = (try? JSONDecoder().decode(SearchCategory.self, from: jsonDataList!))!
             
             
             catDefaultSlot.insert(finalSlot, at: 0)
             catDefaultList.insert(finalList, at: 0)
             config = Configuration(allowsFeedbackUI: false,categoryDataProvider: ConstantCategoryDataProvider(slots: catDefaultSlot, list: catDefaultList))
             self.searchController.configuration = config
         }