diff --git a/Permission.podspec b/Permission.podspec index 49d61e3..b802277 100644 --- a/Permission.podspec +++ b/Permission.podspec @@ -17,6 +17,7 @@ Pod::Spec.new do |s| s.subspec 'Core' do |co| co.source_files = "Source/**/*.{swift, h}" + co.resources = "Source/Permission.bundle" end s.subspec 'AddressBook' do |ab| diff --git a/Permission.xcodeproj/project.pbxproj b/Permission.xcodeproj/project.pbxproj index 04a199b..3567129 100644 --- a/Permission.xcodeproj/project.pbxproj +++ b/Permission.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 3D42A7DB1D5F66B300236ABA /* SpeechRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D42A7DA1D5F66B300236ABA /* SpeechRecognizer.swift */; }; 3DC217D31D6EFD4A00600DFE /* MediaLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DC217D21D6EFD4A00600DFE /* MediaLibrary.swift */; }; + 5641D9AA1E292FB20010AF89 /* Permission.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 5641D9A91E292FB20010AF89 /* Permission.bundle */; }; 3F21DC7E1E30E0B900B3EF65 /* Siri.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F21DC7C1E30B6DB00B3EF65 /* Siri.swift */; }; 6C04FAF61CCA8F3A00B3F361 /* AddressBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C04FAF51CCA8F3A00B3F361 /* AddressBook.swift */; }; 6D0069B41C1868E8002FDB42 /* PermissionSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0069B31C1868E8002FDB42 /* PermissionSet.swift */; }; @@ -48,6 +49,7 @@ /* Begin PBXFileReference section */ 3D42A7DA1D5F66B300236ABA /* SpeechRecognizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpeechRecognizer.swift; sourceTree = ""; }; 3DC217D21D6EFD4A00600DFE /* MediaLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaLibrary.swift; sourceTree = ""; }; + 5641D9A91E292FB20010AF89 /* Permission.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Permission.bundle; sourceTree = ""; }; 3F21DC7C1E30B6DB00B3EF65 /* Siri.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Siri.swift; sourceTree = ""; }; 6C04FAF51CCA8F3A00B3F361 /* AddressBook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddressBook.swift; sourceTree = ""; }; 6D0069B31C1868E8002FDB42 /* PermissionSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionSet.swift; sourceTree = ""; }; @@ -126,6 +128,7 @@ 6D0069B31C1868E8002FDB42 /* PermissionSet.swift */, 6D491E771C9CA90B00611006 /* PermissionStatus.swift */, 6D491E751C9CA7DE00611006 /* PermissionType.swift */, + 5641D9A91E292FB20010AF89 /* Permission.bundle */, ); path = Source; sourceTree = ""; @@ -257,6 +260,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + fr, ); mainGroup = 6D86A9A81BEBDC7C00E3DD5A; productRefGroup = 6D86A9B31BEBDC7D00E3DD5A /* Products */; @@ -274,6 +278,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5641D9AA1E292FB20010AF89 /* Permission.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -341,6 +346,7 @@ baseConfigurationReference = D08FF2891DC3AD2900F28088 /* PermissionFlags.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -393,6 +399,7 @@ baseConfigurationReference = D08FF2891DC3AD2900F28088 /* PermissionFlags.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; diff --git a/Source/Permission.bundle/en.lproj/Localizable.strings b/Source/Permission.bundle/en.lproj/Localizable.strings new file mode 100644 index 0000000..6ea55ef --- /dev/null +++ b/Source/Permission.bundle/en.lproj/Localizable.strings @@ -0,0 +1,36 @@ +/* + Localizable.strings + Permission + + Created by Gwendal Roué on 13/01/2017. + Copyright © 2017 delba. All rights reserved. +*/ + +"OK" = "OK"; +"Cancel" = "Cancel"; +"Settings" = "Settings"; +"Confirm" = "Confirm"; + +"Location is currently disabled" = "Location is currently disabled"; +"Permission for Location was denied" = "Permission for your location was denied"; +"Please enable access to Location in the Settings app." = "Please enable access to your location in the Settings app."; +"%@ would like to access your Location" = "%@ would like to access your location"; +"Please enable access to Location." = "Please enable access to your location."; + +"Motion is currently disabled" = "Motion is currently disabled"; +"Permission for Motion was denied" = "Permission to access your motions was denied"; +"Please enable access to Motion in the Settings app." = "Please enable access to your motions in the Settings app."; +"%@ would like to access your Motion" = "%@ would like to access your motions"; +"Please enable access to Motion." = "Please enable access to your motions."; + +"Notifications is currently disabled" = "Notifications is currently disabled"; +"Permission for Notifications was denied" = "Permission for notifications was denied"; +"Please enable access to Notifications in the Settings app." = "Please enable notifications in the Settings app."; +"%@ would like to access your Notifications" = "%@ would like to display notifications"; +"Please enable access to Notifications." = "Please allow notifications."; + +"Bluetooth is currently disabled" = "Bluetooth is currently disabled"; +"Permission for Bluetooth was denied" = "Permission for Bluetooth was denied"; +"Please enable access to Bluetooth in the Settings app." = "Please enable Bluetooth in the Settings app."; +"%@ would like to access your Bluetooth" = "%@ would like to use Bluetooth"; +"Please enable access to Bluetooth." = "Please enable Bluetooth."; diff --git a/Source/Permission.bundle/fr.lproj/Localizable.strings b/Source/Permission.bundle/fr.lproj/Localizable.strings new file mode 100644 index 0000000..00eca55 --- /dev/null +++ b/Source/Permission.bundle/fr.lproj/Localizable.strings @@ -0,0 +1,36 @@ +/* + Localizable.strings + Permission + + Created by Gwendal Roué on 13/01/2017. + Copyright © 2017 delba. All rights reserved. +*/ + +"OK" = "OK"; +"Cancel" = "Annuler"; +"Settings" = "Réglages"; +"Confirm" = "OK"; + +"Location is currently disabled" = "L’accès à votre position est désactivé"; +"Permission for Location was denied" = "L’accès à votre position est refusé."; +"Please enable access to Location in the Settings app." = "Veuillez autoriser l'accès à votre position dans l’application Réglages."; +"%@ would like to access your Location" = "%@ voudrait accéder à votre position"; +"Please enable access to Location." = "Veuillez autoriser l'accès à votre position."; + +"Motion is currently disabled" = "L’accès à vos mouvements est désactivé"; +"Permission for Motion was denied" = "L’accès à vos mouvements est refusé."; +"Please enable access to Motion in the Settings app." = "Veuillez autoriser l'accès à vos mouvements dans l’application Réglages."; +"%@ would like to access your Motion" = "%@ voudrait accéder à vos mouvements"; +"Please enable access to Motion." = "Veuillez autoriser l'accès à vos mouvements."; + +"Notifications is currently disabled" = "Les notifications sont désactivées"; +"Permission for Notifications was denied" = "Les notifications sont désactivées"; +"Please enable access to Notifications in the Settings app." = "Veuillez accepter les notifications dans l’application Réglages."; +"%@ would like to access your Notifications" = "%@ voudrait vous envoyer des notifications"; +"Please enable access to Notifications." = "Veuillez accepter les notifications."; + +"Bluetooth is currently disabled" = "Bluetooth est désactivé"; +"Permission for Bluetooth was denied" = "L’accès à Bluetooth est refusé."; +"Please enable access to Bluetooth in the Settings app." = "Veuillez activer Bluetooth dans l’application Réglages."; +"%@ would like to access your Bluetooth" = "%@ voudrait utiliser Bluetooth"; +"Please enable access to Bluetooth." = "Veuillez activer Bluetooth."; diff --git a/Source/Permission.bundle/ru.lproj/Localizable.strings b/Source/Permission.bundle/ru.lproj/Localizable.strings new file mode 100644 index 0000000..7e0e576 --- /dev/null +++ b/Source/Permission.bundle/ru.lproj/Localizable.strings @@ -0,0 +1,42 @@ +/* + Localizable.strings + Permission + + Created by Yaroslav Erohin on 15/01/2017. + Copyright © 2017 delba. All rights reserved. +*/ + +"OK" = "ОК"; +"Cancel" = "Отмена"; +"Settings" = "Настройки"; +"Confirm" = "Подтвердить"; + +"Location is currently disabled" = "Местоположение в данный момент недоступно."; +"Permission for Location was denied" = "Доступ к местоположению был запрещён."; +"Please enable access to Location in the Settings app." = "Пожалуйста, разрешите доступ к местоположению в настройках."; +"%@ would like to access your Location" = "%@ пытается запросить ваше местоположение."; +"Please enable access to Location." = "Пожалуйста, разрешите доступ к местоположению."; + +"Motion is currently disabled" = "Данные движения в данный момент недоступны."; +"Permission for Motion was denied" = "Доступ к данным движения был запрещён."; +"Please enable access to Motion in the Settings app." = "Пожалуйста, разрешите доступ к данным движения в настройках."; +"%@ would like to access your Motion" = "%@ пытается запросить данные движения."; +"Please enable access to Motion." = "Пожалуйста, разрешите доступ к вашим данным движения."; + +"Notifications is currently disabled" = "Уведомления в данный момент недоступны."; +"Permission for Notifications was denied" = "Отправка уведомлений была запрещёна."; +"Please enable access to Notifications in the Settings app." = "Пожалуйста, разрешите доступ к уведомлениям в настройках."; +"%@ would like to access your Notifications" = "%@ хочет отправлять вам уведомления."; +"Please enable access to Notifications." = "Пожалуйста, разрешите отправлять вам уведомления."; + +"Bluetooth is currently disabled" = "Bluetooth в данный момент недоступен."; +"Permission for Bluetooth was denied" = "Доступ к Bluetooth был запрещён."; +"Please enable access to Bluetooth in the Settings app." = "Пожалуйста, разрешите доступ к Bluetooth в настройках."; +"%@ would like to access your Bluetooth" = "%@ хочет использовать Bluetooth."; +"Please enable access to Bluetooth." = "Пожалуйста, разрешите доступ к Bluetooth."; + +"Photos is currently disabled" = "Библиотека фото в данный момент недоступна."; +"Permission for Photos was denied" = "Доступ к библиотеке фото был запрещён."; +"Please enable access to Photos in the Settings app." = "Пожалуйста, разрешите доступ к фото в настройках."; +"%@ would like to access your Photos" = "%@ запрашивает доступ к вашим фото."; +"Please enable access to Photos." = "Пожалуйста, разрешите доступ к вашим фото."; diff --git a/Source/PermissionAlert.swift b/Source/PermissionAlert.swift index 01cd2c0..4c6fbc2 100644 --- a/Source/PermissionAlert.swift +++ b/Source/PermissionAlert.swift @@ -89,9 +89,9 @@ internal class DisabledAlert: PermissionAlert { override init(permission: Permission) { super.init(permission: permission) - title = "\(permission) is currently disabled" - message = "Please enable access to \(permission) in the Settings app." - cancel = "OK" + title = "\(permission) is currently disabled".localized() + message = "Please enable access to \(permission) in the Settings app.".localized() + cancel = "OK".localized() } } @@ -112,10 +112,10 @@ internal class DeniedAlert: PermissionAlert { override init(permission: Permission) { super.init(permission: permission) - title = "Permission for \(permission) was denied" - message = "Please enable access to \(permission) in the Settings app." - cancel = "Cancel" - settings = "Settings" + title = "Permission for \(permission) was denied".localized() + message = "Please enable access to \(permission) in the Settings app.".localized() + cancel = "Cancel".localized() + settings = "Settings".localized() } @objc func settingsHandler() { @@ -149,10 +149,10 @@ internal class PrePermissionAlert: PermissionAlert { override init(permission: Permission) { super.init(permission: permission) - title = "\(Bundle.main.name) would like to access your \(permission)" - message = "Please enable access to \(permission)." - cancel = "Cancel" - confirm = "Confirm" + title = String(format: "%@ would like to access your \(permission)".localized(), Bundle.main.name) + message = "Please enable access to \(permission).".localized() + cancel = "Cancel".localized() + confirm = "Confirm".localized() } fileprivate func confirmHandler(_ action: UIAlertAction) { diff --git a/Source/Supporting Files/Utilities.swift b/Source/Supporting Files/Utilities.swift index cb884c4..250ec28 100644 --- a/Source/Supporting Files/Utilities.swift +++ b/Source/Supporting Files/Utilities.swift @@ -67,6 +67,17 @@ internal extension String { static let stateBluetoothManagerDetermined = "permission.stateBluetoothManagerDetermined" } +let permissionBundle: Bundle = { + let path = Bundle(for: Permission.self).path(forResource: "Permission", ofType: "bundle")! + return Bundle(path: path)! +}() + +internal extension String { + func localized() -> String { + return NSLocalizedString(self, tableName: "Localizable", bundle: permissionBundle, value: self, comment: "") + } +} + internal extension Selector { static let tapped = #selector(PermissionButton.tapped(_:)) static let highlight = #selector(PermissionButton.highlight(_:))