Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions Swifternalization.podspec
Original file line number Diff line number Diff line change
@@ -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' }

Expand All @@ -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
end
2 changes: 1 addition & 1 deletion Swifternalization/Regex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 9 additions & 2 deletions Swifternalization/Swifternalization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.

Expand Down Expand Up @@ -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
}
}