From c9753a898fea080a0d8270565c071eb215040cfe Mon Sep 17 00:00:00 2001 From: Zeno Foltin Date: Wed, 3 Mar 2021 18:39:52 +0000 Subject: [PATCH] Improve RTL support --- CountryPickerView/CountryPickerView.swift | 4 +- .../CountryPickerViewController.swift | 2 +- .../project.pbxproj | 5 ++ .../ar.lproj/LaunchScreen.strings | 1 + .../ar.lproj/Main.strings | 63 +++++++++++++++++++ 5 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/LaunchScreen.strings create mode 100644 CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/Main.strings diff --git a/CountryPickerView/CountryPickerView.swift b/CountryPickerView/CountryPickerView.swift index 5a6801b..9768b3f 100644 --- a/CountryPickerView/CountryPickerView.swift +++ b/CountryPickerView/CountryPickerView.swift @@ -125,9 +125,9 @@ public class CountryPickerView: NibView { countryDetailsLabel.font = font countryDetailsLabel.textColor = textColor if showCountryCodeInView && showPhoneCodeInView { - countryDetailsLabel.text = "(\(selectedCountry.code)) \(selectedCountry.phoneCode)" + countryDetailsLabel.text = "(\(selectedCountry.code)) \u{202A}\(selectedCountry.phoneCode)\u{202C}" } else if showCountryNameInView && showPhoneCodeInView { - countryDetailsLabel.text = "(\(selectedCountry.localizedName() ?? selectedCountry.name)) \(selectedCountry.phoneCode)" + countryDetailsLabel.text = "(\(selectedCountry.localizedName() ?? selectedCountry.name)) \u{202A}\(selectedCountry.phoneCode)\u{202C}" } else if showCountryCodeInView || showPhoneCodeInView || showCountryNameInView { countryDetailsLabel.text = showCountryCodeInView ? selectedCountry.code : showPhoneCodeInView ? selectedCountry.phoneCode diff --git a/CountryPickerView/CountryPickerViewController.swift b/CountryPickerView/CountryPickerViewController.swift index 10389d2..54a21e2 100644 --- a/CountryPickerView/CountryPickerViewController.swift +++ b/CountryPickerView/CountryPickerViewController.swift @@ -134,7 +134,7 @@ extension CountryPickerViewController { name = "\(name) (\(country.code))" } if dataSource.showPhoneCodeInList { - name = "\(name) (\(country.phoneCode))" + name = "\(name) (\u{202A}\(country.phoneCode)\u{202C})" } cell.imageView?.image = country.flag diff --git a/CountryPickerViewDemo/CountryPickerViewDemo.xcodeproj/project.pbxproj b/CountryPickerViewDemo/CountryPickerViewDemo.xcodeproj/project.pbxproj index 6f037e1..96606c0 100644 --- a/CountryPickerViewDemo/CountryPickerViewDemo.xcodeproj/project.pbxproj +++ b/CountryPickerViewDemo/CountryPickerViewDemo.xcodeproj/project.pbxproj @@ -36,6 +36,8 @@ 004CA3091F705DD600B690B8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 004CA30C1F705DD600B690B8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 004CA30E1F705DD600B690B8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 15254F7525F0032A000C5668 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Main.strings; sourceTree = ""; }; + 15254F7625F0032B000C5668 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/LaunchScreen.strings; sourceTree = ""; }; 459706724723319B379BF2E4 /* Pods-CountryPickerViewDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CountryPickerViewDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CountryPickerViewDemo/Pods-CountryPickerViewDemo.debug.xcconfig"; sourceTree = ""; }; 476008F23554AD41FFB937C1 /* Pods-CountryPickerViewDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CountryPickerViewDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-CountryPickerViewDemo/Pods-CountryPickerViewDemo.release.xcconfig"; sourceTree = ""; }; 9B8C8BC3DAF9C411DCD8D1C9 /* Pods_CountryPickerViewDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CountryPickerViewDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -149,6 +151,7 @@ English, en, Base, + ar, ); mainGroup = 004CA2F61F705DD600B690B8; productRefGroup = 004CA3001F705DD600B690B8 /* Products */; @@ -229,6 +232,7 @@ isa = PBXVariantGroup; children = ( 004CA3071F705DD600B690B8 /* Base */, + 15254F7525F0032A000C5668 /* ar */, ); name = Main.storyboard; sourceTree = ""; @@ -237,6 +241,7 @@ isa = PBXVariantGroup; children = ( 004CA30C1F705DD600B690B8 /* Base */, + 15254F7625F0032B000C5668 /* ar */, ); name = LaunchScreen.storyboard; sourceTree = ""; diff --git a/CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/LaunchScreen.strings b/CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/LaunchScreen.strings new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/LaunchScreen.strings @@ -0,0 +1 @@ + diff --git a/CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/Main.strings b/CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/Main.strings new file mode 100644 index 0000000..45d6a78 --- /dev/null +++ b/CountryPickerViewDemo/CountryPickerViewDemo/ar.lproj/Main.strings @@ -0,0 +1,63 @@ + +/* Class = "UILabel"; text = "CountryPickerView can also be used as an independent view."; ObjectID = "1RQ-vo-NB4"; */ +"1RQ-vo-NB4.text" = "CountryPickerView can also be used as an independent view."; + +/* Class = "UILabel"; text = "Show phone code in list"; ObjectID = "1UF-QN-m72"; */ +"1UF-QN-m72.text" = "Show phone code in list"; + +/* Class = "UITableViewSection"; headerTitle = "CUSTOMIZATION"; ObjectID = "40Z-Ay-ZrI"; */ +"40Z-Ay-ZrI.headerTitle" = "CUSTOMIZATION"; + +/* Class = "UILabel"; text = "The internal Country Picker can be used independently."; ObjectID = "8So-g0-xNg"; */ +"8So-g0-xNg.text" = "The internal Country Picker can be used independently."; + +/* Class = "UILabel"; text = "Show ONLY preferred countries section"; ObjectID = "8aM-7z-xIV"; */ +"8aM-7z-xIV.text" = "Show ONLY preferred countries section"; + +/* Class = "UIButton"; normalTitle = "Select a Country"; ObjectID = "Cvr-s2-9T2"; */ +"Cvr-s2-9T2.normalTitle" = "Select a Country"; + +/* Class = "UILabel"; text = "Show country code in list"; ObjectID = "EF5-yw-4gn"; */ +"EF5-yw-4gn.text" = "Show country code in list"; + +/* Class = "UILabel"; text = "Show phone code in view"; ObjectID = "Fga-9R-GVt"; */ +"Fga-9R-GVt.text" = "Show phone code in view"; + +/* Class = "UILabel"; text = "CountryPickerView can be used as the left view of a phone number input text field"; ObjectID = "H3z-cJ-GdF"; */ +"H3z-cJ-GdF.text" = "CountryPickerView can be used as the left view of a phone number input text field"; + +/* Class = "UISegmentedControl"; Jr1-AD-yBk.segmentTitles[0] = "Table View"; ObjectID = "Jr1-AD-yBk"; */ +"Jr1-AD-yBk.segmentTitles[0]" = "Table View"; + +/* Class = "UISegmentedControl"; Jr1-AD-yBk.segmentTitles[1] = "Navigation Bar"; ObjectID = "Jr1-AD-yBk"; */ +"Jr1-AD-yBk.segmentTitles[1]" = "Navigation Bar"; + +/* Class = "UISegmentedControl"; Jr1-AD-yBk.segmentTitles[2] = "Hidden"; ObjectID = "Jr1-AD-yBk"; */ +"Jr1-AD-yBk.segmentTitles[2]" = "Hidden"; + +/* Class = "UINavigationItem"; title = "CountryPickerView Demo"; ObjectID = "L8o-xe-Pfv"; */ +"L8o-xe-Pfv.title" = "CountryPickerView Demo"; + +/* Class = "UISegmentedControl"; SCL-Cv-BjI.segmentTitles[0] = "Push"; ObjectID = "SCL-Cv-BjI"; */ +"SCL-Cv-BjI.segmentTitles[0]" = "Push"; + +/* Class = "UISegmentedControl"; SCL-Cv-BjI.segmentTitles[1] = "Present"; ObjectID = "SCL-Cv-BjI"; */ +"SCL-Cv-BjI.segmentTitles[1]" = "Present"; + +/* Class = "UITableViewSection"; headerTitle = "USAGE"; ObjectID = "VxW-EB-0C6"; */ +"VxW-EB-0C6.headerTitle" = "USAGE"; + +/* Class = "UILabel"; text = "Click on the view to open picker"; ObjectID = "cVo-xn-9I4"; */ +"cVo-xn-9I4.text" = "Click on the view to open picker"; + +/* Class = "UILabel"; text = "SEARCH BAR POSITION"; ObjectID = "g5B-s5-Vai"; */ +"g5B-s5-Vai.text" = "SEARCH BAR POSITION"; + +/* Class = "UILabel"; text = "Show country code in view"; ObjectID = "geW-Qh-IPW"; */ +"geW-Qh-IPW.text" = "Show country code in view"; + +/* Class = "UILabel"; text = "Show preferred countries section"; ObjectID = "u3m-oh-NBx"; */ +"u3m-oh-NBx.text" = "Show preferred countries section"; + +/* Class = "UILabel"; text = "Show country name in view"; ObjectID = "zDT-4c-h2J"; */ +"zDT-4c-h2J.text" = "Show country name in view";