From 952639d6ad8600eeacdf13e8f1995742cc773185 Mon Sep 17 00:00:00 2001 From: coder Date: Fri, 24 Aug 2018 13:12:48 +0400 Subject: [PATCH 1/2] swift 4 support --- .DS_Store | Bin 0 -> 6148 bytes Swifternalization.podspec | 8 ++++---- Swifternalization/Regex.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..42a3d451ad1d7a1cdc82d1927a9d25b3c0ce570e GIT binary patch literal 6148 zcmeHK&1w`u5U$>=I^%*&z(WKN4LNwpVS{0Vw_!~@35pZUAu;O=Gr9vqcbM(XfXl+* z1NZ=X_2)g*hscZMZdG@$By0pvvPczFe>K%r)iYlY{R04EIL)^KA^-?b2|FP+*9i5K zE=k9G2!*X-pnw__q);tIvttz*pt)Oz1R5ye4P2hT65ioF8uV*WSu;7!DxG2UMRr=1 z6VvaXi_Tj2#?4znc)J(&?)1V}$yhguNzHUJOzTl}KPmGfOY6fjH{*js?N`NFp`O)G zQ&ZGO6nvm{g#pe^vzKMjjH0`bwK8d`irUt5HI5HUmFs4xrz)S=cwgMw&r>tTI>BaK zNy~B=grjIH7~KKYjl4_1pI!HVXv) z##YunF5o8`e?ik(Qmaa_HJO715;%f5i|k9sSbB#U5LSE**p&8SD6w zg}jst;63bXxOb7V`(eiK(&H?Nd{uR literal 0 HcmV?d00001 diff --git a/Swifternalization.podspec b/Swifternalization.podspec index 43604a4..d8d79de 100644 --- a/Swifternalization.podspec +++ b/Swifternalization.podspec @@ -1,10 +1,10 @@ Pod::Spec.new do |s| s.name = "Swifternalization" - s.version = "1.3.2" + s.version = "2.0.0" s.summary = "Swift Framework which helps in localizing apps using JSON files." - s.homepage = "https://github.com/tomkowz/Swifternalization" + s.homepage = "https://github.com/hovhannest/Swifternalization" s.license = { :type => 'MIT', :file => 'LICENSE' } @@ -13,9 +13,9 @@ Pod::Spec.new do |s| s.platform = :ios, '8.0' - s.source = { :git => "https://github.com/tomkowz/Swifternalization.git", :tag => "v1.3.2" } + s.source = { :git => "https://github.com/hovhannest/Swifternalization.git", :tag => "v2.0.0" } s.source_files = 'Classes', 'Swifternalization/**/*.{swift,h}' s.requires_arc = true -end \ No newline at end of file +end diff --git a/Swifternalization/Regex.swift b/Swifternalization/Regex.swift index 150e957..12a5048 100644 --- a/Swifternalization/Regex.swift +++ b/Swifternalization/Regex.swift @@ -27,7 +27,7 @@ final class Regex { regexp(pattern)?.enumerateMatches(in: str, options: NSRegularExpression.MatchingOptions.reportCompletion, range: range, using: { result, flags, stop in if let result = result { if let capturingGroupIdx = capturingGroupIdx, result.numberOfRanges > capturingGroupIdx { - resultString = self.substring(str, range: result.rangeAt(capturingGroupIdx)) + resultString = self.substring(str, range: result.range(at: capturingGroupIdx)) } else { resultString = self.substring(str, range: result.range) } From b6e64c2738d529f8ce52fea511154bfa177048d7 Mon Sep 17 00:00:00 2001 From: coder Date: Mon, 27 Aug 2018 15:14:19 +0400 Subject: [PATCH 2/2] 2.0.0 added selectLanguage --- Swifternalization/Swifternalization.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Swifternalization/Swifternalization.swift b/Swifternalization/Swifternalization.swift index 32d3678..2664e51 100644 --- a/Swifternalization/Swifternalization.swift +++ b/Swifternalization/Swifternalization.swift @@ -25,7 +25,9 @@ localizations. Before calling any method that return localized string call `configure:`. */ final public class Swifternalization { + private static var _selectedLang: CountryCode = Bundle.main.preferredLocalizations.first! as CountryCode /** + Shared instance of Swifternalization used internally. */ private static let sharedInstance = Swifternalization() @@ -42,7 +44,11 @@ final public class Swifternalization { private var configured = false // MARK: Public Methods - + public class func setLanguage(lng:String) + { + _selectedLang = lng; + Swifternalization.configure() + } /** Call the method to configure Swifternalization. @@ -192,6 +198,7 @@ final public class Swifternalization { */ private func getPreferredLanguage(_ bundle: Bundle) -> CountryCode { // Get preferred language, the one which is set on user's device - return bundle.preferredLocalizations.first! as CountryCode + //return bundle.preferredLocalizations.first! as CountryCode + return Swifternalization._selectedLang } }