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

Customizable web page login language #61

Merged
merged 9 commits into from
May 14, 2019
Prev Previous commit
Next Next commit
Change enum to a struct to allow future customization
  • Loading branch information
onevcat committed May 10, 2019
commit f16e91772137e7b49b819e2fb1f337bf624cffb1
73 changes: 51 additions & 22 deletions LineSDK/LineSDK/Login/LoginManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,6 @@ import Foundation
/// LINE authorization flow, and check the authorization status.
public class LoginManager {

/// Represents the language used in web page.
public enum WebPageLanguage: String {
case arabic = "ar"
case german = "de"
case english = "en"
case spanish = "es"
case french = "fr"
case indonesian = "id"
case italian = "it"
case japanese = "jp"
case korean = "ko"
case malay = "ms"
case portugueseBrazilian = "pt-BR"
case portugueseEuropean = "pt-PT"
case russian = "ru"
case thai = "th"
case turkish = "tr"
case vietnamese = "vi"
case chineseSimplified = "zh-Hans"
case chineseTraditional = "zh-Hant"
}

let lock = NSLock()

/// The shared instance of the login manager. Always use this instance to interact with the login process of
Expand Down Expand Up @@ -376,3 +354,54 @@ extension LoginManager {
try payload.verify(keyPath: \.nonce, expected: process.tokenIDNonce!)
}
}

extension LoginManager {
/// Represents the language used in web page.
public struct WebPageLanguage {
public let rawValue: String

/// Creates a web page language with a given raw string language code value.
///
/// - Parameter rawValue: The value represents the language code.
public init(rawValue: String) {
self.rawValue = rawValue
}

/// The Arabic langauge.
public static let arabic = WebPageLanguage(rawValue: "ar")
/// The German langauge.
public static let german = WebPageLanguage(rawValue: "de")
/// The English langauge.
public static let english = WebPageLanguage(rawValue: "en")
/// The Spanish langauge.
public static let spanish = WebPageLanguage(rawValue: "es")
/// The French langauge.
public static let french = WebPageLanguage(rawValue: "fr")
/// The Indonesian langauge.
public static let indonesian = WebPageLanguage(rawValue: "id")
/// The Italian langauge.
public static let italian = WebPageLanguage(rawValue: "it")
/// The Japanese langauge.
public static let japanese = WebPageLanguage(rawValue: "jp")
/// The Korean langauge.
public static let korean = WebPageLanguage(rawValue: "ko")
/// The Malay langauge.
public static let malay = WebPageLanguage(rawValue: "ms")
/// The Brazilian Portuguese langauge.
public static let portugueseBrazilian = WebPageLanguage(rawValue: "pt-BR")
/// The European Portuguese langauge.
public static let portugueseEuropean = WebPageLanguage(rawValue: "pt-PT")
/// The Russian langauge.
public static let russian = WebPageLanguage(rawValue: "ru")
/// The Thai langauge.
public static let thai = WebPageLanguage(rawValue: "th")
/// The Turkish langauge.
public static let turkish = WebPageLanguage(rawValue: "tr")
/// The Vietnamese langauge.
public static let vietnamese = WebPageLanguage(rawValue: "vi")
/// The SimplifiedC Chinese langauge.
onevcat marked this conversation as resolved.
Show resolved Hide resolved
onevcat marked this conversation as resolved.
Show resolved Hide resolved
public static let chineseSimplified = WebPageLanguage(rawValue: "zh-Hans")
/// The TraditionalC Chinese langauge.
onevcat marked this conversation as resolved.
Show resolved Hide resolved
public static let chineseTraditional = WebPageLanguage(rawValue: "zh-Hant")
}
}