From b9589f39132d726879b9403a240dac06486d35ea Mon Sep 17 00:00:00 2001 From: George Nyame Date: Fri, 6 Aug 2021 14:15:43 -0600 Subject: [PATCH] French Localization Fix for Choose Your Country --- Package.swift | 3 ++- PhoneNumberKit.xcodeproj/project.pbxproj | 20 +++++++++++++++++++ .../Resources/en.lproj/Localizable.strings | 11 ++++++++++ .../Resources/fr-CA.lproj/Localizable.strings | 11 ++++++++++ .../UI/CountryCodePickerViewController.swift | 8 ++++---- 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 PhoneNumberKit/Resources/en.lproj/Localizable.strings create mode 100644 PhoneNumberKit/Resources/fr-CA.lproj/Localizable.strings diff --git a/Package.swift b/Package.swift index 78316e6..4ab834f 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,7 @@ import PackageDescription let package = Package( name: "PhoneNumberKit", + defaultLocalization: "en", platforms: [ .iOS(.v9), .macOS(.v10_10), .tvOS(.v9), .watchOS(.v2) ], @@ -20,7 +21,7 @@ let package = Package( "Info.plist", "Bundle+Resources.swift"], resources: [ - .process("Resources/PhoneNumberMetadata.json") + .process("Resources") ]), .testTarget(name: "PhoneNumberKitTests", dependencies: ["PhoneNumberKit"], diff --git a/PhoneNumberKit.xcodeproj/project.pbxproj b/PhoneNumberKit.xcodeproj/project.pbxproj index 783c527..be32a6a 100644 --- a/PhoneNumberKit.xcodeproj/project.pbxproj +++ b/PhoneNumberKit.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 0F2FB36B26BDA3E2000EEE23 /* Localizable.strings in Sources */ = {isa = PBXBuildFile; fileRef = 0F64F15726BD93C200598B72 /* Localizable.strings */; }; + 0F64F15526BD93C200598B72 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0F64F15726BD93C200598B72 /* Localizable.strings */; }; 11C2EF391D62BC3200052D44 /* NSRegularExpression+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11C2EF381D62BC3200052D44 /* NSRegularExpression+Swift.swift */; }; 1B0651171E2AD698006AE849 /* PhoneNumberFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0651161E2AD698006AE849 /* PhoneNumberFormatter.swift */; }; 1B1A4DD723007580006AE849 /* PhoneNumberFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0651161E2AD698006AE849 /* PhoneNumberFormatter.swift */; }; @@ -94,6 +96,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0F64F15626BD93C200598B72 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 0F64F15826BD93DB00598B72 /* fr-CA */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "fr-CA"; path = "fr-CA.lproj/Localizable.strings"; sourceTree = ""; }; 11C2EF381D62BC3200052D44 /* NSRegularExpression+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSRegularExpression+Swift.swift"; sourceTree = ""; }; 1B0651161E2AD698006AE849 /* PhoneNumberFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumberFormatter.swift; sourceTree = ""; }; 3417BD6A2210AC4900477EE7 /* MetadataParsing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetadataParsing.swift; sourceTree = ""; }; @@ -252,6 +256,7 @@ isa = PBXGroup; children = ( 3435CC951BBFF66F003F953B /* PhoneNumberMetadata.json */, + 0F64F15726BD93C200598B72 /* Localizable.strings */, ); path = Resources; sourceTree = ""; @@ -422,6 +427,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + "fr-CA", Base, ); mainGroup = 3424185A1BB6E5A000EE70E7; @@ -444,6 +450,7 @@ buildActionMask = 2147483647; files = ( 34CA34522380307300788D7D /* PhoneNumberMetadata.json in Resources */, + 0F64F15526BD93C200598B72 /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -486,6 +493,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0F2FB36B26BDA3E2000EEE23 /* Localizable.strings in Sources */, 11C2EF391D62BC3200052D44 /* NSRegularExpression+Swift.swift in Sources */, 34F26FBE2517DCB700B6AF4D /* Bundle+Resources.swift in Sources */, 342418821BB70F5200EE70E7 /* PhoneNumberParser.swift in Sources */, @@ -589,6 +597,18 @@ }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + 0F64F15726BD93C200598B72 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 0F64F15626BD93C200598B72 /* en */, + 0F64F15826BD93DB00598B72 /* fr-CA */, + ); + name = Localizable.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 342418761BB6E5A000EE70E7 /* Debug */ = { isa = XCBuildConfiguration; diff --git a/PhoneNumberKit/Resources/en.lproj/Localizable.strings b/PhoneNumberKit/Resources/en.lproj/Localizable.strings new file mode 100644 index 0000000..2588df5 --- /dev/null +++ b/PhoneNumberKit/Resources/en.lproj/Localizable.strings @@ -0,0 +1,11 @@ +/* + Localizable.strings + PhoneNumberKit + + Created by George Nyame on 2021-08-06. + Copyright © 2021 Roy Marmelstein. All rights reserved. +*/ + +"CHOOSE_YOUR_COUNTRY" = "Choose your country"; +"CURRENT" = "Current"; +"COMMON" = "Common"; diff --git a/PhoneNumberKit/Resources/fr-CA.lproj/Localizable.strings b/PhoneNumberKit/Resources/fr-CA.lproj/Localizable.strings new file mode 100644 index 0000000..cdbce15 --- /dev/null +++ b/PhoneNumberKit/Resources/fr-CA.lproj/Localizable.strings @@ -0,0 +1,11 @@ +/* + Localizable.strings + PhoneNumberKit + + Created by George Nyame on 2021-08-06. + Copyright © 2021 Roy Marmelstein. All rights reserved. +*/ + +"CHOOSE_YOUR_COUNTRY" = "Choisissez votre pays"; +"CURRENT" = "Actuel"; +"COMMON" = "Courant"; diff --git a/PhoneNumberKit/UI/CountryCodePickerViewController.swift b/PhoneNumberKit/UI/CountryCodePickerViewController.swift index 0727774..67ef3b0 100644 --- a/PhoneNumberKit/UI/CountryCodePickerViewController.swift +++ b/PhoneNumberKit/UI/CountryCodePickerViewController.swift @@ -95,7 +95,7 @@ public class CountryCodePickerViewController: UITableViewController { } func commonInit() { - self.title = NSLocalizedString("PhoneNumberKit.CountryCodePicker.Title", value: "Choose your country", comment: "Title of CountryCodePicker ViewController") + self.title = NSLocalizedString("CHOOSE_YOUR_COUNTRY", bundle: .module, comment: "Title of CountryCodePicker ViewController") tableView.register(Cell.self, forCellReuseIdentifier: Cell.reuseIdentifier) searchController.searchResultsUpdater = self @@ -154,11 +154,11 @@ public class CountryCodePickerViewController: UITableViewController { if isFiltering { return nil } else if section == 0, hasCurrent { - return NSLocalizedString("PhoneNumberKit.CountryCodePicker.Current", value: "Current", comment: "Name of \"Current\" section") + return NSLocalizedString("CURRENT", bundle: .module, comment: "Section Title of Current Section") } else if section == 0, !hasCurrent, hasCommon { - return NSLocalizedString("PhoneNumberKit.CountryCodePicker.Common", value: "Common", comment: "Name of \"Common\" section") + return NSLocalizedString("COMMON", bundle: .module, comment: "Section Title of Common Section") } else if section == 1, hasCurrent, hasCommon { - return NSLocalizedString("PhoneNumberKit.CountryCodePicker.Common", value: "Common", comment: "Name of \"Common\" section") + return NSLocalizedString("COMMON", bundle: .module, comment: "Section Title of Common Section") } return countries[section].first?.name.first.map(String.init) }