Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift 4 support #35

Open
wants to merge 2 commits into
base: swift3
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions 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' }

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
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
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
}
}