diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..42a3d45 Binary files /dev/null and b/.DS_Store differ 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) } 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 } }