BartyCrouch.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // BartyCrouch.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2021/5/18.
  6. // Copyright © 2021 zoneland. All rights reserved.
  7. //
  8. import Foundation
  9. enum BartyCrouch {
  10. enum SupportedLanguage: String {
  11. // TODO: remove unsupported languages from the following cases list & add any missing languages
  12. case arabic = "ar"
  13. case chineseSimplified = "zh-Hans"
  14. case chineseTraditional = "zh-Hant"
  15. case english = "en"
  16. case french = "fr"
  17. case german = "de"
  18. case hindi = "hi"
  19. case italian = "it"
  20. case japanese = "ja"
  21. case korean = "ko"
  22. case malay = "ms"
  23. case portuguese = "pt-BR"
  24. case russian = "ru"
  25. case spanish = "es"
  26. case turkish = "tr"
  27. }
  28. static func translate(key: String, translations: [SupportedLanguage: String], comment: String? = nil) -> String {
  29. let typeName = String(describing: BartyCrouch.self)
  30. let methodName = #function
  31. print(
  32. "Warning: [BartyCrouch]",
  33. "Untransformed \(typeName).\(methodName) method call found with key '\(key)' and base translations '\(translations)'.",
  34. "Please ensure that BartyCrouch is installed and configured correctly."
  35. )
  36. // fall back in case something goes wrong with BartyCrouch transformation
  37. return "BC: TRANSFORMATION FAILED!"
  38. }
  39. }