Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
marmelroy committed Aug 5, 2015
1 parent b3e06c5 commit feb8c0b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Localize/Localize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ public class Localize: NSObject {
currentLanguage = NSUserDefaults.standardUserDefaults().objectForKey(LCLCurrentLanguageKey) as! String
}
else {
currentLanguage = defaultLanguage()
currentLanguage = self.defaultLanguage()
}
return currentLanguage
}

public class func setCurrentLanguage(language: String) {
// TODO: Assert here to check if valid string
var selectedLanguage: String = String()
let availableLanguages : [String] = Localize.availableLanguages()
let availableLanguages : [String] = self.availableLanguages()
if (contains(availableLanguages, language)) {
selectedLanguage = language
}
else {
selectedLanguage = Localize.defaultLanguage()
selectedLanguage = self.defaultLanguage()
}
NSUserDefaults.standardUserDefaults().setObject(selectedLanguage, forKey: LCLCurrentLanguageKey)
NSUserDefaults.standardUserDefaults().synchronize()
Expand All @@ -58,7 +57,7 @@ public class Localize: NSObject {
class func defaultLanguage() -> String {
var defaultLanguage : String = String()
let preferredLanguage = NSBundle.mainBundle().preferredLocalizations.first! as! String
let availableLanguages : [String] = Localize.availableLanguages()
let availableLanguages : [String] = self.availableLanguages()
if (contains(availableLanguages, preferredLanguage)) {
defaultLanguage = preferredLanguage
}
Expand All @@ -69,7 +68,7 @@ public class Localize: NSObject {
}

public class func resetCurrentLanaguageToDefault() {
setCurrentLanguage(defaultLanguage())
setCurrentLanguage(self.defaultLanguage())
}
}

0 comments on commit feb8c0b

Please sign in to comment.