LocalisedString.swift 903 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // LocalisedString.swift
  3. // MinimedKit
  4. //
  5. // Created by Pete Schwamb on 3/19/23.
  6. //
  7. import Foundation
  8. private class LocalBundle {
  9. /// Returns the resource bundle associated with the current Swift module.
  10. static var main: Bundle = {
  11. if let mainResourceURL = Bundle.main.resourceURL,
  12. let bundle = Bundle(url: mainResourceURL.appendingPathComponent("MinimedKitUI_MinimedKitUI.bundle"))
  13. {
  14. return bundle
  15. }
  16. return Bundle(for: LocalBundle.self)
  17. }()
  18. }
  19. func LocalizedString(_ key: String, tableName: String? = nil, value: String? = nil, comment: String) -> String {
  20. if let value = value {
  21. return NSLocalizedString(key, tableName: tableName, bundle: LocalBundle.main, value: value, comment: comment)
  22. } else {
  23. return NSLocalizedString(key, tableName: tableName, bundle: LocalBundle.main, comment: comment)
  24. }
  25. }