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

Localization pr #98

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Permission.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
7 changes: 7 additions & 0 deletions Permission.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -48,6 +49,7 @@
/* Begin PBXFileReference section */
3D42A7DA1D5F66B300236ABA /* SpeechRecognizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpeechRecognizer.swift; sourceTree = "<group>"; };
3DC217D21D6EFD4A00600DFE /* MediaLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaLibrary.swift; sourceTree = "<group>"; };
5641D9A91E292FB20010AF89 /* Permission.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Permission.bundle; sourceTree = "<group>"; };
3F21DC7C1E30B6DB00B3EF65 /* Siri.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Siri.swift; sourceTree = "<group>"; };
6C04FAF51CCA8F3A00B3F361 /* AddressBook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddressBook.swift; sourceTree = "<group>"; };
6D0069B31C1868E8002FDB42 /* PermissionSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionSet.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -126,6 +128,7 @@
6D0069B31C1868E8002FDB42 /* PermissionSet.swift */,
6D491E771C9CA90B00611006 /* PermissionStatus.swift */,
6D491E751C9CA7DE00611006 /* PermissionType.swift */,
5641D9A91E292FB20010AF89 /* Permission.bundle */,
);
path = Source;
sourceTree = "<group>";
Expand Down Expand Up @@ -257,6 +260,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
fr,
);
mainGroup = 6D86A9A81BEBDC7C00E3DD5A;
productRefGroup = 6D86A9B31BEBDC7D00E3DD5A /* Products */;
Expand All @@ -274,6 +278,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5641D9AA1E292FB20010AF89 /* Permission.bundle in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
36 changes: 36 additions & 0 deletions Source/Permission.bundle/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -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.";
36 changes: 36 additions & 0 deletions Source/Permission.bundle/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -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.";
42 changes: 42 additions & 0 deletions Source/Permission.bundle/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -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." = "Пожалуйста, разрешите доступ к вашим фото.";
22 changes: 11 additions & 11 deletions Source/PermissionAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions Source/Supporting Files/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(_:))
Expand Down